coin-Cgl
CglProbing.hpp
Go to the documentation of this file.
1 // Copyright (C) 2002, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #ifndef CglProbing_H
4 #define CglProbing_H
5 
6 #include <string>
7 
8 #include "CglCutGenerator.hpp"
13  typedef struct {
14  //unsigned int zeroOne:1; // nonzero if affected variable is 0-1
15  //unsigned int whenAtUB:1; // nonzero if fixing happens when this variable at 1
16  //unsigned int affectedToUB:1; // nonzero if affected variable fixed to UB
17  //unsigned int affected:29; // If 0-1 then 0-1 sequence, otherwise true
18  unsigned int affected;
20 
22 class CglProbing : public CglCutGenerator {
23  friend void CglProbingUnitTest(const OsiSolverInterface * siP,
24  const std::string mpdDir );
25 
26 public:
27 
28 
96  virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
97  const CglTreeInfo info = CglTreeInfo()) const;
98  int generateCutsAndModify( const OsiSolverInterface & si, OsiCuts & cs,
99  CglTreeInfo * info);
101 
112  int snapshot ( const OsiSolverInterface & si,
113  char * possible=NULL,
114  bool withObjective=true);
116  void deleteSnapshot ( );
122  int createCliques( OsiSolverInterface & si,
123  int minimumSize=2, int maximumSize=100);
125  void deleteCliques();
127 
130  const double * tightLower() const;
133  const double * tightUpper() const;
135  const char * tightenBounds() const
136  { return tightenBounds_;}
138 
141  const double * relaxedRowLower() const;
144  const double * relaxedRowUpper() const;
146 
149  void setMode(int mode);
152  int getMode() const;
154 
157  void setMaxPass(int value);
160  int getMaxPass() const;
162  void setLogLevel(int value);
164  int getLogLevel() const;
166  void setMaxProbe(int value);
168  int getMaxProbe() const;
170  void setMaxLook(int value);
172  int getMaxLook() const;
174  void setMaxElements(int value);
176  int getMaxElements() const;
178  void setMaxPassRoot(int value);
180  int getMaxPassRoot() const;
182  void setMaxProbeRoot(int value);
184  int getMaxProbeRoot() const;
186  void setMaxLookRoot(int value);
188  int getMaxLookRoot() const;
190  void setMaxElementsRoot(int value);
192  int getMaxElementsRoot() const;
200  virtual bool mayGenerateRowCutsInTree() const;
202 
205  inline int numberThisTime() const
207  { return numberThisTime_;}
209  inline const int * lookedAt() const
210  { return lookedAt_;}
212 
215  void setRowCuts(int type);
219  int rowCuts() const;
221 
229  void setUsingObjective(int yesNo);
231  int getUsingObjective() const;
233 
236  void tightenThese(const OsiSolverInterface & solver, int number, const int * which);
239 
242  CglProbing ();
244 
246  CglProbing (
247  const CglProbing &);
248 
250  virtual CglCutGenerator * clone() const;
251 
253  CglProbing &
254  operator=(
255  const CglProbing& rhs);
256 
258  virtual
259  ~CglProbing ();
260 
262  virtual void refreshSolver(OsiSolverInterface * solver);
264  virtual std::string generateCpp( FILE * fp);
266 
267 private:
268 
269  // Private member methods
272  int probe( const OsiSolverInterface & si,
274  const OsiRowCutDebugger * debugger,
275  OsiCuts & cs,
276  double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
277  CoinPackedMatrix *columnCopy,const CoinBigIndex * rowStartPos,
278  const int * realRow, const double * rowLower, const double * rowUpper,
279  const char * intVar, double * minR, double * maxR, int * markR,
280  CglTreeInfo * info) const;
282  int probeCliques( const OsiSolverInterface & si,
283  const OsiRowCutDebugger * debugger,
284  OsiCuts & cs,
285  double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
286  CoinPackedMatrix *columnCopy, const int * realRow,
287  double * rowLower, double * rowUpper,
288  char * intVar, double * minR, double * maxR, int * markR,
289  CglTreeInfo * info) const;
291  int probeSlacks( const OsiSolverInterface & si,
292  const OsiRowCutDebugger * debugger,
293  OsiCuts & cs,
294  double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
295  CoinPackedMatrix *columnCopy,
296  double * rowLower, double * rowUpper,
297  char * intVar, double * minR, double * maxR,int * markR,
298  CglTreeInfo * info) const;
301  int gutsOfGenerateCuts( const OsiSolverInterface & si,
302  OsiCuts & cs,
303  double * rowLower, double * rowUpper,
304  double * colLower, double * colUpper,
305  CglTreeInfo * info) const;
307  void setupRowCliqueInformation(const OsiSolverInterface & si);
310  int tighten(double *colLower, double * colUpper,
311  const int *column, const double *rowElements,
312  const CoinBigIndex *rowStart,const CoinBigIndex * rowStartPos,
313  const int * rowLength,
314  double *rowLower, double *rowUpper,
315  int nRows,int nCols,char * intVar,int maxpass,
316  double tolerance) const;
318  void tighten2(double *colLower, double * colUpper,
319  const int *column, const double *rowElements,
320  const CoinBigIndex *rowStart,
321  const int * rowLength,
322  double *rowLower, double *rowUpper,
323  double * minR, double * maxR, int * markR,
324  int nRows) const;
326 
327  // Private member data
328 
331 
334  CoinPackedMatrix * rowCopy_;
337  CoinPackedMatrix * columnCopy_;
339  double * rowLower_;
341  double * rowUpper_;
343  mutable double * colLower_;
345  mutable double * colUpper_;
347  mutable int numberRows_;
349  mutable int numberColumns_;
355  int mode_;
360  mutable int rowCuts_;
362  int maxPass_;
386  mutable int numberThisTime_;
388  mutable int totalTimesCalled_;
390  mutable int * lookedAt_;
392  typedef struct disaggregation_struct_tag {
393  int sequence; // integer variable
394  // index will be NULL if no probing done yet
395  int length; // length of newValue
396  disaggregationAction * index; // columns whose bounds will be changed
397  } disaggregation;
403  typedef struct {
404  unsigned int equality:1; // nonzero if clique is ==
405  } cliqueType;
431 };
433 { return dis.affected&0x1fffffff;}
435  int affected)
436 { dis.affected = affected|(dis.affected&0xe0000000);}
437 #ifdef NDEBUG
438 inline bool zeroOneInDisaggregation(const disaggregationAction & )
439 { return true;}
440 #else
442 //{ return (dis.affected&0x80000000)!=0;}
443 { assert ((dis.affected&0x80000000)!=0); return true;}
444 #endif
445 inline void setZeroOneInDisaggregation(disaggregationAction & dis,bool zeroOne)
446 { dis.affected = (zeroOne ? 0x80000000 : 0)|(dis.affected&0x7fffffff);}
448 { return (dis.affected&0x40000000)!=0;}
449 inline void setWhenAtUBInDisaggregation(disaggregationAction & dis,bool whenAtUB)
450 { dis.affected = (whenAtUB ? 0x40000000 : 0)|(dis.affected&0xbfffffff);}
452 { return (dis.affected&0x20000000)!=0;}
453 inline void setAffectedToUBInDisaggregation(disaggregationAction & dis,bool affectedToUB)
454 { dis.affected = (affectedToUB ? 0x20000000 : 0)|(dis.affected&0xdfffffff);}
455 
456 //#############################################################################
462 void CglProbingUnitTest(const OsiSolverInterface * siP,
463  const std::string mpdDir );
466 
467 public:
468 
474  virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
475  const CglTreeInfo info = CglTreeInfo()) const;
477 
480  CglImplication ();
482 
485 
488  const CglImplication &);
489 
491  virtual CglCutGenerator * clone() const;
492 
495  operator=(
496  const CglImplication& rhs);
497 
499  virtual
500  ~CglImplication ();
502  virtual std::string generateCpp( FILE * fp);
504 
506  inline void setProbingInfo(CglTreeProbingInfo * info)
508  { probingInfo_=info;}
510 
511 private:
517 };
518 #endif