Cgl trunk
CglLandPValidator.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2005-2009, Pierre Bonami and others.  All Rights Reserved.
00002 // Author:   Pierre Bonami
00003 //           Tepper School of Business
00004 //           Carnegie Mellon University, Pittsburgh, PA 15213
00005 // Date:     11/22/05
00006 //
00007 // $Id$
00008 //
00009 // This code is licensed under the terms of the Eclipse Public License (EPL).
00010 //---------------------------------------------------------------------------
00011 
00012 #ifndef CglLandPValidator_H
00013 #define CglLandPValidator_H
00014 #include "OsiSolverInterface.hpp"
00015 #include "CglParam.hpp"
00016 #include <vector>
00017 
00019 //[5] = {"Accepted", "violation too small", "small coefficient too small", "big dynamic","too dense"}
00020 
00021 
00022 namespace LAP
00023 {
00024 
00026 class Validator
00027 {
00028 public:
00030     enum RejectionsReasons
00031     {
00032         NoneAccepted=0 ,
00033         SmallViolation ,
00034         SmallCoefficient ,
00035         BigDynamic ,
00036         DenseCut,
00037         EmptyCut,
00038         DummyEnd
00039     };
00040 
00042     Validator(double maxFillIn = 1.,
00043               double maxRatio = 1e8,
00044               double minViolation = 0,
00045               bool scale = false,
00046               double rhsScale = 1);
00047 
00049     int cleanCut(OsiRowCut & aCut, const double * solCut,const OsiSolverInterface &si, const CglParam & par,
00050                  const double * colLower, const double * colUpper) const;
00052     int cleanCut2(OsiRowCut & aCut, const double * solCut, const OsiSolverInterface &si, const CglParam & par,
00053                   const double * colLower, const double * colUpper) const;
00055     int operator()(OsiRowCut & aCut, const double * solCut,const OsiSolverInterface &si, const CglParam & par,
00056                    const double * colLower, const double * colUpper) const
00057     {
00058         return cleanCut(aCut, solCut, si, par, colLower, colUpper);
00059     }
00062     void setMaxFillIn(double value)
00063     {
00064         maxFillIn_ = value;
00065     }
00066     void setMaxRatio(double value)
00067     {
00068         maxRatio_ = value;
00069     }
00070     void setMinViolation(double value)
00071     {
00072         minViolation_ = value;
00073     }
00074 
00075     void setRhsScale(double v)
00076     {
00077         rhsScale_ = v;
00078     }
00082     double getMaxFillIn()
00083     {
00084         return maxFillIn_;
00085     }
00086     double getMaxRatio()
00087     {
00088         return maxRatio_;
00089     }
00090     double getMinViolation()
00091     {
00092         return minViolation_;
00093     }
00096     const std::string& failureString(RejectionsReasons code) const
00097     {
00098         return rejections_[static_cast<int> (code)];
00099     }
00100     const std::string& failureString(int code) const
00101     {
00102         return rejections_[ code];
00103     }
00104     int numRejected(RejectionsReasons code)const
00105     {
00106         return numRejected_[static_cast<int> (code)];
00107     }
00108     int numRejected(int code)const
00109     {
00110         return numRejected_[ code];
00111     }
00112 private:
00113     static void fillRejectionReasons();
00115     double maxFillIn_;
00117     double maxRatio_;
00119     double minViolation_;
00121     bool scale_;
00123     double rhsScale_;
00125     static std::vector<std::string> rejections_;
00127     mutable std::vector<int> numRejected_;
00128 };
00129 
00130 }/* Ends namespace LAP.*/
00131 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines