Cgl  0.58.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CglProbing.hpp
Go to the documentation of this file.
1 // $Id: CglProbing.hpp 1123 2013-04-06 20:47:24Z stefan $
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CglProbing_H
7 #define CglProbing_H
8 
9 #include <string>
10 
11 #include "CglCutGenerator.hpp"
16  typedef struct {
17  //unsigned int zeroOne:1; // nonzero if affected variable is 0-1
18  //unsigned int whenAtUB:1; // nonzero if fixing happens when this variable at 1
19  //unsigned int affectedToUB:1; // nonzero if affected variable fixed to UB
20  //unsigned int affected:29; // If 0-1 then 0-1 sequence, otherwise true
21  unsigned int affected;
23 
25 class CglProbing : public CglCutGenerator {
26  friend void CglProbingUnitTest(const OsiSolverInterface * siP,
27  const std::string mpdDir );
28 
29 public:
30 
31 
99  virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
100  const CglTreeInfo info = CglTreeInfo());
101  int generateCutsAndModify( const OsiSolverInterface & si, OsiCuts & cs,
102  CglTreeInfo * info);
104 
115  int snapshot ( const OsiSolverInterface & si,
116  char * possible=NULL,
117  bool withObjective=true);
119  void deleteSnapshot ( );
125  int createCliques( OsiSolverInterface & si,
126  int minimumSize=2, int maximumSize=100);
128  void deleteCliques();
130 
133  const double * tightLower() const;
136  const double * tightUpper() const;
138  const char * tightenBounds() const
139  { return tightenBounds_;}
141 
144  const double * relaxedRowLower() const;
147  const double * relaxedRowUpper() const;
149 
152  void setMode(int mode);
155  int getMode() const;
157 
160  void setMaxPass(int value);
163  int getMaxPass() const;
165  void setLogLevel(int value);
167  int getLogLevel() const;
169  void setMaxProbe(int value);
171  int getMaxProbe() const;
173  void setMaxLook(int value);
175  int getMaxLook() const;
177  void setMaxElements(int value);
179  int getMaxElements() const;
181  void setMaxPassRoot(int value);
183  int getMaxPassRoot() const;
185  void setMaxProbeRoot(int value);
187  int getMaxProbeRoot() const;
189  void setMaxLookRoot(int value);
191  int getMaxLookRoot() const;
193  void setMaxElementsRoot(int value);
195  int getMaxElementsRoot() const;
203  virtual bool mayGenerateRowCutsInTree() const;
205 
208  inline int numberThisTime() const
210  { return numberThisTime_;}
212  inline const int * lookedAt() const
213  { return lookedAt_;}
215 
218  void setRowCuts(int type);
222  int rowCuts() const;
224 
232  void setUsingObjective(int yesNo);
234  int getUsingObjective() const;
236 
239  void tightenThese(const OsiSolverInterface & solver, int number, const int * which);
242 
245  CglProbing ();
247 
249  CglProbing (
250  const CglProbing &);
251 
253  virtual CglCutGenerator * clone() const;
254 
256  CglProbing &
257  operator=(
258  const CglProbing& rhs);
259 
261  virtual
262  ~CglProbing ();
263 
265  virtual void refreshSolver(OsiSolverInterface * solver);
267  virtual std::string generateCpp( FILE * fp);
269 
270 private:
271 
272  // Private member methods
275  int probe( const OsiSolverInterface & si,
277  const OsiRowCutDebugger * debugger,
278  OsiCuts & cs,
279  double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
280  CoinPackedMatrix *columnCopy,const CoinBigIndex * rowStartPos,
281  const int * realRow, const double * rowLower, const double * rowUpper,
282  const char * intVar, double * minR, double * maxR, int * markR,
283  CglTreeInfo * info);
285  int probeCliques( const OsiSolverInterface & si,
286  const OsiRowCutDebugger * debugger,
287  OsiCuts & cs,
288  double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
289  CoinPackedMatrix *columnCopy, const int * realRow,
290  double * rowLower, double * rowUpper,
291  char * intVar, double * minR, double * maxR, int * markR,
292  CglTreeInfo * info);
294  int probeSlacks( const OsiSolverInterface & si,
295  const OsiRowCutDebugger * debugger,
296  OsiCuts & cs,
297  double * colLower, double * colUpper, CoinPackedMatrix *rowCopy,
298  CoinPackedMatrix *columnCopy,
299  double * rowLower, double * rowUpper,
300  char * intVar, double * minR, double * maxR,int * markR,
301  CglTreeInfo * info);
304  int gutsOfGenerateCuts( const OsiSolverInterface & si,
305  OsiCuts & cs,
306  double * rowLower, double * rowUpper,
307  double * colLower, double * colUpper,
308  CglTreeInfo * info);
310  void setupRowCliqueInformation(const OsiSolverInterface & si);
313  int tighten(double *colLower, double * colUpper,
314  const int *column, const double *rowElements,
315  const CoinBigIndex *rowStart,const CoinBigIndex * rowStartPos,
316  const int * rowLength,
317  double *rowLower, double *rowUpper,
318  int nRows,int nCols,char * intVar,int maxpass,
319  double tolerance);
321  void tighten2(double *colLower, double * colUpper,
322  const int *column, const double *rowElements,
323  const CoinBigIndex *rowStart,
324  const int * rowLength,
325  double *rowLower, double *rowUpper,
326  double * minR, double * maxR, int * markR,
327  int nRows);
329 
330  // Private member data
331 
332  struct disaggregation_struct_tag ;
334 
337  CoinPackedMatrix * rowCopy_;
340  CoinPackedMatrix * columnCopy_;
342  double * rowLower_;
344  double * rowUpper_;
346  double * colLower_;
348  double * colUpper_;
350  int numberRows_;
352  int numberColumns_;
354  double primalTolerance_;
358  int mode_;
363  int rowCuts_;
365  int maxPass_;
367  int logLevel_;
369  int maxProbe_;
371  int maxStack_;
373  int maxElements_;
375  int maxPassRoot_;
377  int maxProbeRoot_;
379  int maxStackRoot_;
381  int maxElementsRoot_;
383  int usingObjective_;
385  int numberIntegers_;
387  int number01Integers_;
389  int numberThisTime_;
391  int totalTimesCalled_;
393  int * lookedAt_;
395  typedef struct disaggregation_struct_tag {
396  int sequence; // integer variable
397  // index will be NULL if no probing done yet
398  int length; // length of newValue
399  disaggregationAction * index; // columns whose bounds will be changed
400  } disaggregation;
401  disaggregation * cutVector_;
404  int numberCliques_;
406  typedef struct {
407  unsigned int equality:1; // nonzero if clique is ==
408  } cliqueType;
409  cliqueType * cliqueType_;
411  int * cliqueStart_;
413  cliqueEntry * cliqueEntry_;
416  int * oneFixStart_;
419  int * zeroFixStart_;
421  int * endFixStart_;
423  int * whichClique_;
428  cliqueEntry * cliqueRow_;
430  int * cliqueRowStart_;
432  char * tightenBounds_;
434 };
436 { return dis.affected&0x1fffffff;}
438  int affected)
439 { dis.affected = affected|(dis.affected&0xe0000000);}
440 #ifdef NDEBUG
441 inline bool zeroOneInDisaggregation(const disaggregationAction & )
442 { return true;}
443 #else
445 //{ return (dis.affected&0x80000000)!=0;}
446 { assert ((dis.affected&0x80000000)!=0); return true;}
447 #endif
448 inline void setZeroOneInDisaggregation(disaggregationAction & dis,bool zeroOne)
449 { dis.affected = (zeroOne ? 0x80000000 : 0)|(dis.affected&0x7fffffff);}
451 { return (dis.affected&0x40000000)!=0;}
452 inline void setWhenAtUBInDisaggregation(disaggregationAction & dis,bool whenAtUB)
453 { dis.affected = (whenAtUB ? 0x40000000 : 0)|(dis.affected&0xbfffffff);}
455 { return (dis.affected&0x20000000)!=0;}
456 inline void setAffectedToUBInDisaggregation(disaggregationAction & dis,bool affectedToUB)
457 { dis.affected = (affectedToUB ? 0x20000000 : 0)|(dis.affected&0xdfffffff);}
458 
459 //#############################################################################
465 void CglProbingUnitTest(const OsiSolverInterface * siP,
466  const std::string mpdDir );
469 
470 public:
471 
477  virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
478  const CglTreeInfo info = CglTreeInfo());
480 
483  CglImplication ();
485 
488 
491  const CglImplication &);
492 
494  virtual CglCutGenerator * clone() const;
495 
498  operator=(
499  const CglImplication& rhs);
500 
502  virtual
503  ~CglImplication ();
505  virtual std::string generateCpp( FILE * fp);
507 
509  inline void setProbingInfo(CglTreeProbingInfo * info)
511  { probingInfo_=info;}
513 
514 private:
517  CglTreeProbingInfo * probingInfo_;
520 };
521 #endif
int getMode() const
Get.
int getMaxPassRoot() const
Get maximum number of passes per node (root node)
int getMaxLook() const
Get maximum number of variables to look at in one probe.
This just uses implication info.
Definition: CglProbing.hpp:468
void setMaxElements(int value)
Set maximum number of elements in row for it to be considered.
int getMaxProbe() const
Get maximum number of unsatisfied variables to look at.
void setMaxLookRoot(int value)
Set maximum number of variables to look at in one probe (root node)
void setMaxPass(int value)
Set maximum number of passes per node.
virtual CglCutGenerator * clone() const
Clone.
void setWhenAtUBInDisaggregation(disaggregationAction &dis, bool whenAtUB)
Definition: CglProbing.hpp:452
const double * relaxedRowLower() const
Lower.
virtual std::string generateCpp(FILE *fp)
Create C++ lines to get to current state.
Information about where the cut generator is invoked from.
Definition: CglTreeInfo.hpp:15
CglImplication & operator=(const CglImplication &rhs)
Assignment operator.
void setMode(int mode)
Set.
const int * lookedAt() const
Which ones looked at this time.
Definition: CglProbing.hpp:212
CglImplication()
Default constructor.
void setAffectedInDisaggregation(disaggregationAction &dis, int affected)
Definition: CglProbing.hpp:437
const char * tightenBounds() const
Array which says tighten continuous.
Definition: CglProbing.hpp:138
void deleteSnapshot()
Deletes snapshot.
int createCliques(OsiSolverInterface &si, int minimumSize=2, int maximumSize=100)
Creates cliques for use by probing.
const double * tightUpper() const
Upper.
Derived class to pick up probing info.
Definition: CglTreeInfo.hpp:79
void setProbingInfo(CglTreeProbingInfo *info)
Set implication.
Definition: CglProbing.hpp:510
void setMaxLook(int value)
Set maximum number of variables to look at in one probe.
virtual CglCutGenerator * clone() const
Clone.
void setMaxElementsRoot(int value)
Set maximum number of elements in row for it to be considered (root node)
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate cuts from implication table Insert generated cuts into the cut set cs.
unsigned int affected
Definition: CglProbing.hpp:21
bool zeroOneInDisaggregation(const disaggregationAction &dis)
Definition: CglProbing.hpp:444
void setMaxProbe(int value)
Set maximum number of unsatisfied variables to look at.
Cut Generator Base Class.
virtual bool mayGenerateRowCutsInTree() const
Returns true if may generate Row cuts in tree (rather than root node).
friend struct CglProbing::disaggregation_struct_tag
Definition: CglProbing.hpp:332
Only useful type of disaggregation is most normal For now just done for 0-1 variables Can be used for...
Definition: CglProbing.hpp:16
CglProbing()
Default constructor.
bool affectedToUBInDisaggregation(const disaggregationAction &dis)
Definition: CglProbing.hpp:454
const double * relaxedRowUpper() const
Upper.
int rowCuts() const
Get.
int getUsingObjective() const
Get.
virtual std::string generateCpp(FILE *fp)
Create C++ lines to get to current state.
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate probing/disaggregation cuts for the model of the solver interface, si.
void setZeroOneInDisaggregation(disaggregationAction &dis, bool zeroOne)
Definition: CglProbing.hpp:448
void CglProbingUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglProbing class.
int getMaxLookRoot() const
Get maximum number of variables to look at in one probe (root node)
int getMaxElements() const
Get maximum number of elements in row for it to be considered.
int numberThisTime() const
Number looked at this time.
Definition: CglProbing.hpp:209
const double * tightLower() const
Lower.
virtual ~CglImplication()
Destructor.
int getLogLevel() const
Get log level.
void setLogLevel(int value)
Set log level - 0 none, 1 - a bit, 2 - more details.
void setAffectedToUBInDisaggregation(disaggregationAction &dis, bool affectedToUB)
Definition: CglProbing.hpp:456
virtual void refreshSolver(OsiSolverInterface *solver)
This can be used to refresh any inforamtion.
void tightenThese(const OsiSolverInterface &solver, int number, const int *which)
Mark variables to be tightened.
int getMaxPass() const
Get maximum number of passes per node.
int snapshot(const OsiSolverInterface &si, char *possible=NULL, bool withObjective=true)
Create a copy of matrix which is to be used this is to speed up process and to give global cuts Can g...
void setUsingObjective(int yesNo)
Set 0 don&#39;t 1 do -1 don&#39;t even think about it.
friend void CglProbingUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglProbing class.
bool whenAtUBInDisaggregation(const disaggregationAction &dis)
Definition: CglProbing.hpp:450
int generateCutsAndModify(const OsiSolverInterface &si, OsiCuts &cs, CglTreeInfo *info)
void setMaxProbeRoot(int value)
Set maximum number of unsatisfied variables to look at (root node)
void setRowCuts(int type)
Set 0 no cuts, 1 just disaggregation type, 2 coefficient ( 3 both)
int getMaxElementsRoot() const
Get maximum number of elements in row for it to be considered (root node)
int affectedInDisaggregation(const disaggregationAction &dis)
Definition: CglProbing.hpp:435
virtual ~CglProbing()
Destructor.
Probing Cut Generator Class.
Definition: CglProbing.hpp:25
void setMaxPassRoot(int value)
Set maximum number of passes per node (root node)
CglProbing & operator=(const CglProbing &rhs)
Assignment operator.
void deleteCliques()
Delete all clique information.
int getMaxProbeRoot() const
Get maximum number of unsatisfied variables to look at (root node)