00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef CglResidualCapacity_H
00013 #define CglResidualCapacity_H
00014
00015 #include <iostream>
00016 #include <fstream>
00017
00018
00019 #include "CoinError.hpp"
00020
00021 #include "CglCutGenerator.hpp"
00022
00023
00024
00025 #ifndef CGL_DEBUG
00026 #define CGL_DEBUG 0
00027 #endif
00028
00029
00030
00031
00032
00033
00034
00035
00047 class CglResidualCapacity : public CglCutGenerator {
00048
00049 friend void CglResidualCapacityUnitTest(const OsiSolverInterface * siP,
00050 const std::string mpdDir );
00051
00052
00053 private:
00054
00055
00056 enum RowType {
00060 ROW_L,
00064 ROW_G,
00067 ROW_BOTH,
00070 ROW_OTHER
00071 };
00072
00073
00074 public:
00077
00078 void setEpsilon(double value);
00080 double getEpsilon() const;
00082 void setTolerance(double value);
00084 double getTolerance() const;
00086 void setDoPreproc(int value);
00088 bool getDoPreproc() const;
00090
00097 virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
00098 const CglTreeInfo info = CglTreeInfo()) const;
00100
00101
00104
00105 CglResidualCapacity ();
00106
00108 CglResidualCapacity ( const double tolerance );
00109
00111 CglResidualCapacity (
00112 const CglResidualCapacity &);
00113
00115 virtual CglCutGenerator * clone() const;
00116
00118 CglResidualCapacity &
00119 operator=(
00120 const CglResidualCapacity& rhs);
00121
00123 virtual
00124 ~CglResidualCapacity ();
00126 virtual void refreshPrep();
00128
00129
00130
00131 private:
00132
00133
00134
00135
00136 void gutsOfConstruct ( const double tolerance);
00137
00138
00139 void gutsOfDelete();
00140
00141
00142 void gutsOfCopy (const CglResidualCapacity& rhs);
00143
00144
00145
00146
00147 void resCapPreprocess(const OsiSolverInterface& si) const;
00148
00149
00150 RowType determineRowType(const OsiSolverInterface& si,
00151 const int rowLen, const int* ind,
00152 const double* coef, const char sense,
00153 const double rhs,
00154 const double* colLowerBound,
00155 const double* colUpperBound) const;
00156
00157 bool treatAsLessThan(const OsiSolverInterface& si,
00158 const int rowLen, const int* ind,
00159 const double* coef,
00160 const double rhs,
00161 const double* colLowerBound,
00162 const double* colUpperBound) const;
00163
00164
00165 void generateResCapCuts( const OsiSolverInterface& si,
00166 const double* xlp,
00167 const double* colUpperBound,
00168 const double* colLowerBound,
00169 const CoinPackedMatrix& matrixByRow,
00170 const double* LHS,
00171 const double* coefByRow,
00172 const int* colInds,
00173 const int* rowStarts,
00174 const int* rowLengths,
00175 OsiCuts& cs ) const;
00176
00177
00178
00179 bool resCapSeparation(const OsiSolverInterface& si,
00180 const int rowLen, const int* ind,
00181 const double* coef,
00182 const double rhs,
00183 const double *xlp,
00184 const double* colUpperBound,
00185 const double* colLowerBound,
00186 OsiRowCut& resCapCut) const;
00187
00188
00189
00190 private:
00191
00192
00194 double EPSILON_;
00197 double TOLERANCE_;
00205 int doPreproc_;
00206
00207 mutable int numRows_;
00208
00209 mutable int numCols_;
00210
00211 mutable bool doneInitPre_;
00212
00213 mutable RowType* rowTypes_;
00214
00215 mutable int* indRows_;
00216
00217 mutable char * sense_;
00218
00219 mutable double * RHS_;
00220
00221 mutable int numRowL_;
00222
00223 mutable int* indRowL_;
00224
00225 mutable int numRowG_;
00226
00227 mutable int* indRowG_;
00228 };
00229
00230
00236 void CglResidualCapacityUnitTest(const OsiSolverInterface * siP,
00237 const std::string mpdDir);
00238
00239
00240 #endif