00001
00002
00003 #ifndef CglProbing_H
00004 #define CglProbing_H
00005
00006 #include <string>
00007
00008 #include "CglCutGenerator.hpp"
00013 typedef struct {
00014
00015
00016
00017
00018 unsigned int affected;
00019 } disaggregationAction;
00020
00022 class CglProbing : public CglCutGenerator {
00023 friend void CglProbingUnitTest(const OsiSolverInterface * siP,
00024 const std::string mpdDir );
00025
00026 public:
00027
00028
00096 virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
00097 const CglTreeInfo info = CglTreeInfo()) const;
00098 int generateCutsAndModify( const OsiSolverInterface & si, OsiCuts & cs,
00099 CglTreeInfo * info);
00101
00112 int snapshot ( const OsiSolverInterface & si,
00113 char * possible=NULL,
00114 bool withObjective=true);
00116 void deleteSnapshot ( );
00122 int createCliques( OsiSolverInterface & si,
00123 int minimumSize=2, int maximumSize=100);
00125 void deleteCliques();
00127
00130
00131 const double * tightLower() const;
00133 const double * tightUpper() const;
00135 const char * tightenBounds() const
00136 { return tightenBounds_;}
00138
00141
00142 const double * relaxedRowLower() const;
00144 const double * relaxedRowUpper() const;
00146
00149
00150 void setMode(int mode);
00152 int getMode() const;
00154
00157
00158 void setMaxPass(int value);
00160 int getMaxPass() const;
00162 void setLogLevel(int value);
00164 int getLogLevel() const;
00166 void setMaxProbe(int value);
00168 int getMaxProbe() const;
00170 void setMaxLook(int value);
00172 int getMaxLook() const;
00174 void setMaxElements(int value);
00176 int getMaxElements() const;
00178 void setMaxPassRoot(int value);
00180 int getMaxPassRoot() const;
00182 void setMaxProbeRoot(int value);
00184 int getMaxProbeRoot() const;
00186 void setMaxLookRoot(int value);
00188 int getMaxLookRoot() const;
00190 void setMaxElementsRoot(int value);
00192 int getMaxElementsRoot() const;
00200 virtual bool mayGenerateRowCutsInTree() const;
00202
00205
00206 inline int numberThisTime() const
00207 { return numberThisTime_;}
00209 inline const int * lookedAt() const
00210 { return lookedAt_;}
00212
00215
00216
00217 void setRowCuts(int type);
00219 int rowCuts() const;
00221
00229 void setUsingObjective(int yesNo);
00231 int getUsingObjective() const;
00233
00236
00237 void tightenThese(const OsiSolverInterface & solver, int number, const int * which);
00239
00242
00243 CglProbing ();
00244
00246 CglProbing (
00247 const CglProbing &);
00248
00250 virtual CglCutGenerator * clone() const;
00251
00253 CglProbing &
00254 operator=(
00255 const CglProbing& rhs);
00256
00258 virtual
00259 ~CglProbing ();
00260
00262 virtual void refreshSolver(OsiSolverInterface * solver);
00264 virtual std::string generateCpp( FILE * fp);
00266
00267 private:
00268
00269
00272
00273 int probe( const OsiSolverInterface & si,
00274 const OsiRowCutDebugger * debugger,
00275 OsiCuts & cs,
00276 double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
00277 CoinPackedMatrix *columnCopy,const CoinBigIndex * rowStartPos,
00278 const int * realRow, const double * rowLower, const double * rowUpper,
00279 const char * intVar, double * minR, double * maxR, int * markR,
00280 CglTreeInfo * info) const;
00282 int probeCliques( const OsiSolverInterface & si,
00283 const OsiRowCutDebugger * debugger,
00284 OsiCuts & cs,
00285 double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
00286 CoinPackedMatrix *columnCopy, const int * realRow,
00287 double * rowLower, double * rowUpper,
00288 char * intVar, double * minR, double * maxR, int * markR,
00289 CglTreeInfo * info) const;
00291 int probeSlacks( const OsiSolverInterface & si,
00292 const OsiRowCutDebugger * debugger,
00293 OsiCuts & cs,
00294 double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
00295 CoinPackedMatrix *columnCopy,
00296 double * rowLower, double * rowUpper,
00297 char * intVar, double * minR, double * maxR,int * markR,
00298 CglTreeInfo * info) const;
00301 int gutsOfGenerateCuts( const OsiSolverInterface & si,
00302 OsiCuts & cs,
00303 double * rowLower, double * rowUpper,
00304 double * colLower, double * colUpper,
00305 CglTreeInfo * info) const;
00307 void setupRowCliqueInformation(const OsiSolverInterface & si);
00310 int tighten(double *colLower, double * colUpper,
00311 const int *column, const double *rowElements,
00312 const CoinBigIndex *rowStart,const CoinBigIndex * rowStartPos,
00313 const int * rowLength,
00314 double *rowLower, double *rowUpper,
00315 int nRows,int nCols,char * intVar,int maxpass,
00316 double tolerance) const;
00318 void tighten2(double *colLower, double * colUpper,
00319 const int *column, const double *rowElements,
00320 const CoinBigIndex *rowStart,
00321 const int * rowLength,
00322 double *rowLower, double *rowUpper,
00323 double * minR, double * maxR, int * markR,
00324 int nRows) const;
00326
00327
00328
00329 struct disaggregation_struct_tag ;
00330 friend struct CglProbing::disaggregation_struct_tag ;
00331
00334
00335 CoinPackedMatrix * rowCopy_;
00337 CoinPackedMatrix * columnCopy_;
00339 double * rowLower_;
00341 double * rowUpper_;
00343 mutable double * colLower_;
00345 mutable double * colUpper_;
00347 mutable int numberRows_;
00349 mutable int numberColumns_;
00351 double primalTolerance_;
00355 int mode_;
00360 mutable int rowCuts_;
00362 int maxPass_;
00364 int logLevel_;
00366 int maxProbe_;
00368 int maxStack_;
00370 int maxElements_;
00372 int maxPassRoot_;
00374 int maxProbeRoot_;
00376 int maxStackRoot_;
00378 int maxElementsRoot_;
00380 int usingObjective_;
00382 int numberIntegers_;
00384 int number01Integers_;
00386 mutable int numberThisTime_;
00388 mutable int totalTimesCalled_;
00390 mutable int * lookedAt_;
00392 typedef struct disaggregation_struct_tag {
00393 int sequence;
00394
00395 int length;
00396 disaggregationAction * index;
00397 } disaggregation;
00398 disaggregation * cutVector_;
00401 int numberCliques_;
00403 typedef struct {
00404 unsigned int equality:1;
00405 } cliqueType;
00406 cliqueType * cliqueType_;
00408 int * cliqueStart_;
00410 cliqueEntry * cliqueEntry_;
00413 int * oneFixStart_;
00416 int * zeroFixStart_;
00418 int * endFixStart_;
00420 int * whichClique_;
00425 cliqueEntry * cliqueRow_;
00427 int * cliqueRowStart_;
00429 char * tightenBounds_;
00431 };
00432 inline int affectedInDisaggregation(const disaggregationAction & dis)
00433 { return dis.affected&0x1fffffff;}
00434 inline void setAffectedInDisaggregation(disaggregationAction & dis,
00435 int affected)
00436 { dis.affected = affected|(dis.affected&0xe0000000);}
00437 #ifdef NDEBUG
00438 inline bool zeroOneInDisaggregation(const disaggregationAction & )
00439 { return true;}
00440 #else
00441 inline bool zeroOneInDisaggregation(const disaggregationAction & dis)
00442
00443 { assert ((dis.affected&0x80000000)!=0); return true;}
00444 #endif
00445 inline void setZeroOneInDisaggregation(disaggregationAction & dis,bool zeroOne)
00446 { dis.affected = (zeroOne ? 0x80000000 : 0)|(dis.affected&0x7fffffff);}
00447 inline bool whenAtUBInDisaggregation(const disaggregationAction & dis)
00448 { return (dis.affected&0x40000000)!=0;}
00449 inline void setWhenAtUBInDisaggregation(disaggregationAction & dis,bool whenAtUB)
00450 { dis.affected = (whenAtUB ? 0x40000000 : 0)|(dis.affected&0xbfffffff);}
00451 inline bool affectedToUBInDisaggregation(const disaggregationAction & dis)
00452 { return (dis.affected&0x20000000)!=0;}
00453 inline void setAffectedToUBInDisaggregation(disaggregationAction & dis,bool affectedToUB)
00454 { dis.affected = (affectedToUB ? 0x20000000 : 0)|(dis.affected&0xdfffffff);}
00455
00456
00462 void CglProbingUnitTest(const OsiSolverInterface * siP,
00463 const std::string mpdDir );
00465 class CglImplication : public CglCutGenerator {
00466
00467 public:
00468
00474 virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
00475 const CglTreeInfo info = CglTreeInfo()) const;
00477
00480
00481 CglImplication ();
00482
00484 CglImplication (CglTreeProbingInfo * info);
00485
00487 CglImplication (
00488 const CglImplication &);
00489
00491 virtual CglCutGenerator * clone() const;
00492
00494 CglImplication &
00495 operator=(
00496 const CglImplication& rhs);
00497
00499 virtual
00500 ~CglImplication ();
00502 virtual std::string generateCpp( FILE * fp);
00504
00506
00507 inline void setProbingInfo(CglTreeProbingInfo * info)
00508 { probingInfo_=info;}
00510
00511 private:
00514
00515 CglTreeProbingInfo * probingInfo_;
00517 };
00518 #endif