00001
00002
00003 #ifndef CglProbing_H
00004 #define CglProbing_H
00005
00006 #include <string>
00007
00008 #include "CglCutGenerator.hpp"
00009
00011 class CglProbing : public CglCutGenerator {
00012 friend void CglProbingUnitTest(const OsiSolverInterface * siP,
00013 const std::string mpdDir );
00014
00015 public:
00016
00017
00085 virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
00086 const CglTreeInfo info = CglTreeInfo()) const;
00087 int generateCutsAndModify( const OsiSolverInterface & si, OsiCuts & cs,
00088 CglTreeInfo * info);
00090
00101 int snapshot ( const OsiSolverInterface & si,
00102 char * possible=NULL,
00103 bool withObjective=true);
00105 void deleteSnapshot ( );
00111 int createCliques( OsiSolverInterface & si,
00112 int minimumSize=2, int maximumSize=100, bool extendCliques=false);
00114 void deleteCliques();
00116
00119
00120 const double * tightLower() const;
00122 const double * tightUpper() const;
00124 const char * tightenBounds() const
00125 { return tightenBounds_;}
00127
00130
00131 const double * relaxedRowLower() const;
00133 const double * relaxedRowUpper() const;
00135
00138
00139 void setMode(int mode);
00141 int getMode() const;
00143
00146
00147 void setMaxPass(int value);
00149 int getMaxPass() const;
00151 void setLogLevel(int value);
00153 int getLogLevel() const;
00155 void setMaxProbe(int value);
00157 int getMaxProbe() const;
00159 void setMaxLook(int value);
00161 int getMaxLook() const;
00163 void setMaxElements(int value);
00165 int getMaxElements() const;
00167 void setMaxPassRoot(int value);
00169 int getMaxPassRoot() const;
00171 void setMaxProbeRoot(int value);
00173 int getMaxProbeRoot() const;
00175 void setMaxLookRoot(int value);
00177 int getMaxLookRoot() const;
00179 void setMaxElementsRoot(int value);
00181 int getMaxElementsRoot() const;
00189 virtual bool mayGenerateRowCutsInTree() const;
00191
00194
00195 inline int numberThisTime() const
00196 { return numberThisTime_;}
00198 inline const int * lookedAt() const
00199 { return lookedAt_;}
00201
00204
00205
00206 void setRowCuts(int type);
00208 int rowCuts() const;
00210
00218 void setUsingObjective(int yesNo);
00220 int getUsingObjective() const;
00222
00225
00226 void tightenThese(const OsiSolverInterface & solver, int number, const int * which);
00228
00231
00232 CglProbing ();
00233
00235 CglProbing (
00236 const CglProbing &);
00237
00239 virtual CglCutGenerator * clone() const;
00240
00242 CglProbing &
00243 operator=(
00244 const CglProbing& rhs);
00245
00247 virtual
00248 ~CglProbing ();
00249
00251 virtual void refreshSolver(OsiSolverInterface * solver);
00253 virtual std::string generateCpp( FILE * fp);
00255
00256 private:
00257
00258
00261
00262 int probe( const OsiSolverInterface & si,
00263 const OsiRowCutDebugger * debugger,
00264 OsiCuts & cs,
00265 double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
00266 CoinPackedMatrix *columnCopy,const CoinBigIndex * rowStartPos,
00267 const int * realRow, const double * rowLower, const double * rowUpper,
00268 const char * intVar, double * minR, double * maxR, int * markR,
00269 CglTreeInfo * info) const;
00271 int probeCliques( const OsiSolverInterface & si,
00272 const OsiRowCutDebugger * debugger,
00273 OsiCuts & cs,
00274 double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
00275 CoinPackedMatrix *columnCopy, const int * realRow,
00276 double * rowLower, double * rowUpper,
00277 char * intVar, double * minR, double * maxR, int * markR,
00278 CglTreeInfo * info) const;
00280 int probeSlacks( const OsiSolverInterface & si,
00281 const OsiRowCutDebugger * debugger,
00282 OsiCuts & cs,
00283 double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
00284 CoinPackedMatrix *columnCopy,
00285 double * rowLower, double * rowUpper,
00286 char * intVar, double * minR, double * maxR,int * markR,
00287 CglTreeInfo * info) const;
00290 int gutsOfGenerateCuts( const OsiSolverInterface & si,
00291 OsiCuts & cs,
00292 double * rowLower, double * rowUpper,
00293 double * colLower, double * colUpper,
00294 CglTreeInfo * info) const;
00296 void setupRowCliqueInformation(const OsiSolverInterface & si);
00299 int tighten(double *colLower, double * colUpper,
00300 const int *column, const double *rowElements,
00301 const CoinBigIndex *rowStart,const CoinBigIndex * rowStartPos,
00302 const int * rowLength,
00303 double *rowLower, double *rowUpper,
00304 int nRows,int nCols,char * intVar,int maxpass,
00305 double tolerance) const;
00307 void tighten2(double *colLower, double * colUpper,
00308 const int *column, const double *rowElements,
00309 const CoinBigIndex *rowStart,const CoinBigIndex * rowStartPos,
00310 const int * rowLength,
00311 double *rowLower, double *rowUpper,
00312 double * minR, double * maxR, int * markR,
00313 int nRows,int nCols) const;
00315
00316
00317
00318 struct disaggregation_struct_tag ;
00319 friend struct CglProbing::disaggregation_struct_tag ;
00320
00323
00324 CoinPackedMatrix * rowCopy_;
00326 CoinPackedMatrix * columnCopy_;
00328 double * rowLower_;
00330 double * rowUpper_;
00332 double * colLower_;
00334 double * colUpper_;
00336 mutable int numberRows_;
00338 mutable int numberColumns_;
00340 double primalTolerance_;
00344 int mode_;
00349 mutable int rowCuts_;
00351 int maxPass_;
00353 int logLevel_;
00355 int maxProbe_;
00357 int maxStack_;
00359 int maxElements_;
00361 int maxPassRoot_;
00363 int maxProbeRoot_;
00365 int maxStackRoot_;
00367 int maxElementsRoot_;
00369 int usingObjective_;
00371 int numberIntegers_;
00373 int number01Integers_;
00375 mutable int numberThisTime_;
00377 mutable int totalTimesCalled_;
00379 mutable int * lookedAt_;
00384 typedef struct {
00385 unsigned int zeroOne:1;
00386 unsigned int whenAtUB:1;
00387 unsigned int affectedToUB:1;
00388 unsigned int affected:29;
00389 } disaggregationAction;
00391 typedef struct disaggregation_struct_tag {
00392 int sequence;
00393
00394 int length;
00395 disaggregationAction * index;
00396 } disaggregation;
00397 disaggregation * cutVector_;
00400 int numberCliques_;
00402 typedef struct {
00403 unsigned int equality:1;
00404 } cliqueType;
00405 cliqueType * cliqueType_;
00407 int * cliqueStart_;
00409 typedef struct {
00410 unsigned int oneFixes:1;
00411 unsigned int sequence:31;
00412 } cliqueEntry;
00413 cliqueEntry * cliqueEntry_;
00416 int * oneFixStart_;
00419 int * zeroFixStart_;
00421 int * endFixStart_;
00423 int * whichClique_;
00428 cliqueEntry * cliqueRow_;
00430 int * cliqueRowStart_;
00432 char * tightenBounds_;
00434 };
00435
00436
00442 void CglProbingUnitTest(const OsiSolverInterface * siP,
00443 const std::string mpdDir );
00445 class CglImplication : public CglCutGenerator {
00446
00447 public:
00448
00454 virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
00455 const CglTreeInfo info = CglTreeInfo()) const;
00457
00460
00461 CglImplication ();
00462
00464 CglImplication (CglTreeProbingInfo * info);
00465
00467 CglImplication (
00468 const CglImplication &);
00469
00471 virtual CglCutGenerator * clone() const;
00472
00474 CglImplication &
00475 operator=(
00476 const CglImplication& rhs);
00477
00479 virtual
00480 ~CglImplication ();
00482 virtual std::string generateCpp( FILE * fp);
00484
00486
00487 inline void setProbingInfo(CglTreeProbingInfo * info)
00488 { probingInfo_=info;}
00490
00491 private:
00494
00495 CglTreeProbingInfo * probingInfo_;
00497 };
00498 #endif