- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/svn-release/Alps-1.5.0/Cgl/src/CglProbing/CglProbing.hpp

Go to the documentation of this file.

    00001 // $Id: CglProbing.hpp 1201 2014-03-07 17:24:04Z forrest $
    00002 // Copyright (C) 2002, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
    00005
    00006 #ifndef CglProbing_H
    00007 #define CglProbing_H
    00008
    00009 #include <string>
    00010
    00011 #include "CglCutGenerator.hpp"
    00016   typedef struct {
    00017     //unsigned int zeroOne:1; // nonzero if affected variable is 0-1
    00018     //unsigned int whenAtUB:1; // nonzero if fixing happens when this variable at 1
    00019     //unsigned int affectedToUB:1; // nonzero if affected variable fixed to UB
    00020     //unsigned int affected:29; // If 0-1 then 0-1 sequence, otherwise true
    00021     unsigned int affected;
    00022   } disaggregationAction;
    00023
    00025 class CglProbing : public CglCutGenerator {
    00026    friend void CglProbingUnitTest(const OsiSolverInterface * siP,
    00027                                   const std::string mpdDir );
    00028
    00029 public:
    00030
    00031
    00099   virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
    00100                              const CglTreeInfo info = CglTreeInfo());
    00101   int generateCutsAndModify( const OsiSolverInterface & si, OsiCuts & cs,
    00102                              CglTreeInfo * info);
    00104
    00115   int snapshot ( const OsiSolverInterface & si,
    00116                   char * possible=NULL,
    00117                   bool withObjective=true);
    00119   void deleteSnapshot ( );
    00125   int createCliques( OsiSolverInterface & si,
    00126                     int minimumSize=2, int maximumSize=100);
    00128   void deleteCliques();
    00132   OsiSolverInterface * cliqueModel(const OsiSolverInterface * model,
    00133                                    int type);
    00135
    00138
    00139   const double * tightLower() const;
    00141   const double * tightUpper() const;
    00143   const char * tightenBounds() const
    00144   { return tightenBounds_;}
    00146
    00149
    00150   const double * relaxedRowLower() const;
    00152   const double * relaxedRowUpper() const;
    00154
    00157
    00158   void setMode(int mode);
    00160   int getMode() const;
    00162
    00165
    00166   void setMaxPass(int value);
    00168   int getMaxPass() const;
    00170   void setLogLevel(int value);
    00172   int getLogLevel() const;
    00174   void setMaxProbe(int value);
    00176   int getMaxProbe() const;
    00178   void setMaxLook(int value);
    00180   int getMaxLook() const;
    00182   void setMaxElements(int value);
    00184   int getMaxElements() const;
    00186   void setMaxPassRoot(int value);
    00188   int getMaxPassRoot() const;
    00190   void setMaxProbeRoot(int value);
    00192   int getMaxProbeRoot() const;
    00194   void setMaxLookRoot(int value);
    00196   int getMaxLookRoot() const;
    00198   void setMaxElementsRoot(int value);
    00200   int getMaxElementsRoot() const;
    00208   virtual bool mayGenerateRowCutsInTree() const;
    00210
    00213
    00214   inline int numberThisTime() const
    00215   { return numberThisTime_;}
    00217   inline const int * lookedAt() const
    00218   { return lookedAt_;}
    00220
    00223
    00224
    00225   void setRowCuts(int type);
    00227   int rowCuts() const;
    00229
    00230   typedef struct {
    00231     unsigned int equality:1; //  nonzero if clique is ==
    00232   } CliqueType;
    00233
    00236
    00237   inline int numberCliques() const
    00238   { return numberCliques_;}
    00240   inline CliqueType * cliqueType() const
    00241   { return cliqueType_;}
    00243   inline int * cliqueStart() const
    00244   { return cliqueStart_;}
    00246   inline CliqueEntry * cliqueEntry() const
    00247   { return cliqueEntry_;}
    00249
    00257   void setUsingObjective(int yesNo);
    00259   int getUsingObjective() const;
    00261
    00264
    00265   void tightenThese(const OsiSolverInterface & solver, int number, const int * which);
    00267
    00270
    00271   CglProbing ();
    00272
    00274   CglProbing (
    00275     const CglProbing &);
    00276
    00278   virtual CglCutGenerator * clone() const;
    00279
    00281   CglProbing &
    00282     operator=(
    00283     const CglProbing& rhs);
    00284
    00286   virtual
    00287     ~CglProbing ();
    00288
    00290   virtual void refreshSolver(OsiSolverInterface * solver);
    00292   virtual std::string generateCpp( FILE * fp);
    00294
    00295 private:
    00296
    00297  // Private member methods
    00300
    00301   int probe( const OsiSolverInterface & si,
    00302              const OsiRowCutDebugger * debugger,
    00303              OsiCuts & cs,
    00304              double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
    00305              CoinPackedMatrix *columnCopy,const CoinBigIndex * rowStartPos,
    00306              const int * realRow, const double * rowLower, const double * rowUpper,
    00307              const char * intVar, double * minR, double * maxR, int * markR,
    00308              CglTreeInfo * info);
    00310   int probeCliques( const OsiSolverInterface & si,
    00311              const OsiRowCutDebugger * debugger,
    00312              OsiCuts & cs,
    00313              double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
    00314                     CoinPackedMatrix *columnCopy, const int * realRow,
    00315              double * rowLower, double * rowUpper,
    00316              char * intVar, double * minR, double * maxR, int * markR,
    00317              CglTreeInfo * info);
    00319   int probeSlacks( const OsiSolverInterface & si,
    00320                     const OsiRowCutDebugger * debugger,
    00321                     OsiCuts & cs,
    00322                     double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
    00323                    CoinPackedMatrix *columnCopy,
    00324                     double * rowLower, double * rowUpper,
    00325                     char * intVar, double * minR, double * maxR,int * markR,
    00326                      CglTreeInfo * info);
    00329   int gutsOfGenerateCuts( const OsiSolverInterface & si,
    00330                           OsiCuts & cs,
    00331                           double * rowLower, double * rowUpper,
    00332                           double * colLower, double * colUpper,
    00333                            CglTreeInfo * info);
    00335   void setupRowCliqueInformation(const OsiSolverInterface & si);
    00338   int tighten(double *colLower, double * colUpper,
    00339               const int *column, const double *rowElements,
    00340               const CoinBigIndex *rowStart,const CoinBigIndex * rowStartPos,
    00341               const int * rowLength,
    00342               double *rowLower, double *rowUpper,
    00343               int nRows,int nCols,char * intVar,int maxpass,
    00344               double tolerance);
    00346   void tighten2(double *colLower, double * colUpper,
    00347                 const int *column, const double *rowElements,
    00348                 const CoinBigIndex *rowStart,
    00349                 const int * rowLength,
    00350                 double *rowLower, double *rowUpper,
    00351                 double * minR, double * maxR, int * markR,
    00352                 int nRows);
    00354
    00355   // Private member data
    00356
    00357   struct disaggregation_struct_tag ;
    00358   friend struct CglProbing::disaggregation_struct_tag ;
    00359
    00362
    00363   CoinPackedMatrix * rowCopy_;
    00365   CoinPackedMatrix * columnCopy_;
    00367   double * rowLower_;
    00369   double * rowUpper_;
    00371   double * colLower_;
    00373   double * colUpper_;
    00375   int numberRows_;
    00377   int numberColumns_;
    00379   double primalTolerance_;
    00383   int mode_;
    00388   int rowCuts_;
    00390   int maxPass_;
    00392   int logLevel_;
    00394   int maxProbe_;
    00396   int maxStack_;
    00398   int maxElements_;
    00400   int maxPassRoot_;
    00402   int maxProbeRoot_;
    00404   int maxStackRoot_;
    00406   int maxElementsRoot_;
    00408   int usingObjective_;
    00410   int numberIntegers_;
    00412   int number01Integers_;
    00414   int numberThisTime_;
    00416   int totalTimesCalled_;
    00418   int * lookedAt_;
    00420   typedef struct disaggregation_struct_tag {
    00421     int sequence; // integer variable
    00422     // index will be NULL if no probing done yet
    00423     int length; // length of newValue
    00424     disaggregationAction * index; // columns whose bounds will be changed
    00425   } disaggregation;
    00426   disaggregation * cutVector_;
    00429   int numberCliques_;
    00431   CliqueType * cliqueType_;
    00433   int * cliqueStart_;
    00435   CliqueEntry * cliqueEntry_;
    00438   int * oneFixStart_;
    00441   int * zeroFixStart_;
    00443   int * endFixStart_;
    00445   int * whichClique_;
    00450   CliqueEntry * cliqueRow_;
    00452   int * cliqueRowStart_;
    00454   char * tightenBounds_;
    00456 };
    00457 inline int affectedInDisaggregation(const disaggregationAction & dis)
    00458 { return dis.affected&0x1fffffff;}
    00459 inline void setAffectedInDisaggregation(disaggregationAction & dis,
    00460                                            int affected)
    00461 { dis.affected = affected|(dis.affected&0xe0000000);}
    00462 #ifdef NDEBUG
    00463 inline bool zeroOneInDisaggregation(const disaggregationAction & )
    00464 { return true;}
    00465 #else
    00466 inline bool zeroOneInDisaggregation(const disaggregationAction & dis)
    00467 //{ return (dis.affected&0x80000000)!=0;}
    00468 { assert ((dis.affected&0x80000000)!=0); return true;}
    00469 #endif
    00470 inline void setZeroOneInDisaggregation(disaggregationAction & dis,bool zeroOne)
    00471 { dis.affected = (zeroOne ? 0x80000000 : 0)|(dis.affected&0x7fffffff);}
    00472 inline bool whenAtUBInDisaggregation(const disaggregationAction & dis)
    00473 { return (dis.affected&0x40000000)!=0;}
    00474 inline void setWhenAtUBInDisaggregation(disaggregationAction & dis,bool whenAtUB)
    00475 { dis.affected = (whenAtUB ? 0x40000000 : 0)|(dis.affected&0xbfffffff);}
    00476 inline bool affectedToUBInDisaggregation(const disaggregationAction & dis)
    00477 { return (dis.affected&0x20000000)!=0;}
    00478 inline void setAffectedToUBInDisaggregation(disaggregationAction & dis,bool affectedToUB)
    00479 { dis.affected = (affectedToUB ? 0x20000000 : 0)|(dis.affected&0xdfffffff);}
    00480
    00481 //#############################################################################
    00487 void CglProbingUnitTest(const OsiSolverInterface * siP,
    00488                         const std::string mpdDir );
    00490 class CglImplication : public CglCutGenerator {
    00491
    00492 public:
    00493
    00499   virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
    00500                              const CglTreeInfo info = CglTreeInfo());
    00502
    00505
    00506   CglImplication ();
    00507
    00509   CglImplication (CglTreeProbingInfo * info);
    00510
    00512   CglImplication (
    00513     const CglImplication &);
    00514
    00516   virtual CglCutGenerator * clone() const;
    00517
    00519   CglImplication &
    00520     operator=(
    00521     const CglImplication& rhs);
    00522
    00524   virtual
    00525     ~CglImplication ();
    00527   virtual std::string generateCpp( FILE * fp);
    00529
    00531
    00532   inline void setProbingInfo(CglTreeProbingInfo * info)
    00533   { probingInfo_=info;}
    00535
    00536 private:
    00539
    00540   CglTreeProbingInfo * probingInfo_;
    00542 };
    00543 #endif