Cbc  2.9.9
CbcCutGenerator.hpp
Go to the documentation of this file.
1 /* $Id: CbcCutGenerator.hpp 2081 2014-09-25 11:31:17Z forrest $ */
2 // Copyright (C) 2003, 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 CbcCutGenerator_H
7 #define CbcCutGenerator_H
8 
9 #include "OsiSolverInterface.hpp"
10 #include "OsiCuts.hpp"
11 #include "CglCutGenerator.hpp"
12 #include "CbcCutModifier.hpp"
13 
14 class CbcModel;
15 class OsiRowCut;
16 class OsiRowCutDebugger;
17 
18 //#############################################################################
19 
50 
51 public:
52 
71  bool generateCuts( OsiCuts &cs, int fullScan, OsiSolverInterface * solver,
72  CbcNode * node);
74 
75 
78  CbcCutGenerator ();
80 
82  CbcCutGenerator(CbcModel * model, CglCutGenerator * generator,
83  int howOften = 1, const char * name = NULL,
84  bool normal = true, bool atSolution = false,
85  bool infeasible = false, int howOftenInsub = -100,
86  int whatDepth = -1, int whatDepthInSub = -1, int switchOffIfLessThan = 0);
87 
90 
93 
97 
105  void refreshModel(CbcModel * model);
106 
108  inline const char * cutGeneratorName() const {
109  return generatorName_;
110  }
111 
113  void generateTuning( FILE * fp);
128  void setHowOften(int value) ;
129 
131  inline int howOften() const {
132  return whenCutGenerator_;
133  }
135  inline int howOftenInSub() const {
136  return whenCutGeneratorInSub_;
137  }
139  inline int inaccuracy() const {
140  return inaccuracy_;
141  }
143  inline void setInaccuracy(int level) {
144  inaccuracy_ = level;
145  }
146 
157  void setWhatDepth(int value) ;
159  void setWhatDepthInSub(int value) ;
161  inline int whatDepth() const {
162  return depthCutGenerator_;
163  }
165  inline int whatDepthInSub() const {
166  return depthCutGeneratorInSub_;
167  }
169  inline void setMaximumTries(int value)
170  { maximumTries_ = value;}
172  inline int maximumTries() const
173  { return maximumTries_;}
174 
176  inline int switches() const {
177  return switches_;
178  }
180  inline void setSwitches(int value) {
181  switches_ = value;
182  }
184  inline bool normal() const {
185  return (switches_&1) != 0;
186  }
188  inline void setNormal(bool value) {
189  switches_ &= ~1;
190  switches_ |= value ? 1 : 0;
191  }
193  inline bool atSolution() const {
194  return (switches_&2) != 0;
195  }
197  inline void setAtSolution(bool value) {
198  switches_ &= ~2;
199  switches_ |= value ? 2 : 0;
200  }
204  inline bool whenInfeasible() const {
205  return (switches_&4) != 0;
206  }
210  inline void setWhenInfeasible(bool value) {
211  switches_ &= ~4;
212  switches_ |= value ? 4 : 0;
213  }
215  inline bool timing() const {
216  return (switches_&64) != 0;
217  }
219  inline void setTiming(bool value) {
220  switches_ &= ~64;
221  switches_ |= value ? 64 : 0;
222  timeInCutGenerator_ = 0.0;
223  }
225  inline double timeInCutGenerator() const {
226  return timeInCutGenerator_;
227  }
228  inline void incrementTimeInCutGenerator(double value) {
229  timeInCutGenerator_ += value;
230  }
232  inline CglCutGenerator * generator() const {
233  return generator_;
234  }
236  inline int numberTimesEntered() const {
237  return numberTimes_;
238  }
239  inline void setNumberTimesEntered(int value) {
240  numberTimes_ = value;
241  }
242  inline void incrementNumberTimesEntered(int value = 1) {
243  numberTimes_ += value;
244  }
246  inline int numberCutsInTotal() const {
247  return numberCuts_;
248  }
249  inline void setNumberCutsInTotal(int value) {
250  numberCuts_ = value;
251  }
252  inline void incrementNumberCutsInTotal(int value = 1) {
253  numberCuts_ += value;
254  }
256  inline int numberElementsInTotal() const {
257  return numberElements_;
258  }
259  inline void setNumberElementsInTotal(int value) {
260  numberElements_ = value;
261  }
262  inline void incrementNumberElementsInTotal(int value = 1) {
263  numberElements_ += value;
264  }
266  inline int numberColumnCuts() const {
267  return numberColumnCuts_;
268  }
269  inline void setNumberColumnCuts(int value) {
270  numberColumnCuts_ = value;
271  }
272  inline void incrementNumberColumnCuts(int value = 1) {
273  numberColumnCuts_ += value;
274  }
276  inline int numberCutsActive() const {
277  return numberCutsActive_;
278  }
279  inline void setNumberCutsActive(int value) {
280  numberCutsActive_ = value;
281  }
282  inline void incrementNumberCutsActive(int value = 1) {
283  numberCutsActive_ += value;
284  }
285  inline void setSwitchOffIfLessThan(int value) {
286  switchOffIfLessThan_ = value;
287  }
288  inline int switchOffIfLessThan() const {
289  return switchOffIfLessThan_;
290  }
292  inline bool needsOptimalBasis() const {
293  return (switches_&128) != 0;
294  }
296  inline void setNeedsOptimalBasis(bool yesNo) {
297  switches_ &= ~128;
298  switches_ |= yesNo ? 128 : 0;
299  }
301  inline bool mustCallAgain() const {
302  return (switches_&8) != 0;
303  }
305  inline void setMustCallAgain(bool yesNo) {
306  switches_ &= ~8;
307  switches_ |= yesNo ? 8 : 0;
308  }
310  inline bool switchedOff() const {
311  return (switches_&16) != 0;
312  }
314  inline void setSwitchedOff(bool yesNo) {
315  switches_ &= ~16;
316  switches_ |= yesNo ? 16 : 0;
317  }
319  inline bool ineffectualCuts() const {
320  return (switches_&512) != 0;
321  }
323  inline void setIneffectualCuts(bool yesNo) {
324  switches_ &= ~512;
325  switches_ |= yesNo ? 512 : 0;
326  }
328  inline bool whetherToUse() const {
329  return (switches_&1024) != 0;
330  }
332  inline void setWhetherToUse(bool yesNo) {
333  switches_ &= ~1024;
334  switches_ |= yesNo ? 1024 : 0;
335  }
337  inline bool whetherInMustCallAgainMode() const {
338  return (switches_&2048) != 0;
339  }
341  inline void setWhetherInMustCallAgainMode(bool yesNo) {
342  switches_ &= ~2048;
343  switches_ |= yesNo ? 2048 : 0;
344  }
346  inline bool whetherCallAtEnd() const {
347  return (switches_&4096) != 0;
348  }
350  inline void setWhetherCallAtEnd(bool yesNo) {
351  switches_ &= ~4096;
352  switches_ |= yesNo ? 4096 : 0;
353  }
355  inline bool needsRefresh() const {
356  return (switches_&8192) != 0;
357  }
359  inline void setNeedsRefresh(bool yesNo) {
360  switches_ &= ~8192;
361  switches_ |= yesNo ? 8192 : 0;
362  }
364  inline int numberCutsAtRoot() const {
365  return numberCutsAtRoot_;
366  }
367  inline void setNumberCutsAtRoot(int value) {
368  numberCutsAtRoot_ = value;
369  }
371  inline int numberActiveCutsAtRoot() const {
372  return numberActiveCutsAtRoot_;
373  }
374  inline void setNumberActiveCutsAtRoot(int value) {
375  numberActiveCutsAtRoot_ = value;
376  }
378  inline int numberShortCutsAtRoot() const {
379  return numberShortCutsAtRoot_;
380  }
381  inline void setNumberShortCutsAtRoot(int value) {
382  numberShortCutsAtRoot_ = value;
383  }
385  inline void setModel(CbcModel * model) {
386  model_ = model;
387  }
389  inline bool globalCutsAtRoot() const {
390  return (switches_&32) != 0;
391  }
393  inline void setGlobalCutsAtRoot(bool yesNo) {
394  switches_ &= ~32;
395  switches_ |= yesNo ? 32 : 0;
396  }
398  inline bool globalCuts() const {
399  return (switches_&256) != 0;
400  }
402  inline void setGlobalCuts(bool yesNo) {
403  switches_ &= ~256;
404  switches_ |= yesNo ? 256 : 0;
405  }
407  void addStatistics(const CbcCutGenerator * other);
409  void scaleBackStatistics(int factor);
411 
412 private:
415 
416  OsiCuts savedCuts_;
419  double timeInCutGenerator_;
421  CbcModel *model_;
422 
423  // The CglCutGenerator object
424  CglCutGenerator * generator_;
425 
427  char * generatorName_;
428 
432  int whenCutGenerator_;
436  int whenCutGeneratorInSub_;
439  int switchOffIfLessThan_;
440 
444  int depthCutGenerator_;
445 
450  int depthCutGeneratorInSub_;
451 
453  int inaccuracy_;
455  int numberTimes_;
457  int numberCuts_;
459  int numberElements_;
461  int numberColumnCuts_;
463  int numberCutsActive_;
465  int numberCutsAtRoot_;
467  int numberActiveCutsAtRoot_;
469  int numberShortCutsAtRoot_;
471  int switches_;
473  int maximumTries_;
474 };
475 
476 // How often to do if mostly switched off (A)
477 # define SCANCUTS 1000
478 // How often to do if mostly switched off (probing B)
479 # define SCANCUTS_PROBING 1000
480 
481 #endif
482 
CbcCutGenerator::setGlobalCuts
void setGlobalCuts(bool yesNo)
Set whether global cuts.
Definition: CbcCutGenerator.hpp:402
CbcCutGenerator::setGlobalCutsAtRoot
void setGlobalCutsAtRoot(bool yesNo)
Set whether global cuts at root.
Definition: CbcCutGenerator.hpp:393
CbcCutGenerator::numberCutsAtRoot
int numberCutsAtRoot() const
Number of cuts generated at root.
Definition: CbcCutGenerator.hpp:364
CbcCutGenerator::cutGeneratorName
const char * cutGeneratorName() const
return name of generator
Definition: CbcCutGenerator.hpp:108
CbcCutGenerator::setHowOften
void setHowOften(int value)
Set the cut generation interval.
CbcCutGenerator::numberCutsInTotal
int numberCutsInTotal() const
Total number of cuts added.
Definition: CbcCutGenerator.hpp:246
CbcCutGenerator::incrementNumberElementsInTotal
void incrementNumberElementsInTotal(int value=1)
Definition: CbcCutGenerator.hpp:262
CbcCutGenerator::setWhenInfeasible
void setWhenInfeasible(bool value)
Set whether the cut generator should be called when the subproblem is found to be infeasible.
Definition: CbcCutGenerator.hpp:210
CbcCutGenerator::CbcCutGenerator
CbcCutGenerator()
Default constructor.
CbcCutGenerator::setNumberActiveCutsAtRoot
void setNumberActiveCutsAtRoot(int value)
Definition: CbcCutGenerator.hpp:374
CbcCutGenerator::inaccuracy
int inaccuracy() const
Get level of cut inaccuracy (0 means exact e.g. cliques)
Definition: CbcCutGenerator.hpp:139
CbcCutGenerator::setNeedsOptimalBasis
void setNeedsOptimalBasis(bool yesNo)
Set if optimal basis needed.
Definition: CbcCutGenerator.hpp:296
CbcCutGenerator::setWhatDepth
void setWhatDepth(int value)
Set the cut generation depth.
CbcCutGenerator::setNumberShortCutsAtRoot
void setNumberShortCutsAtRoot(int value)
Definition: CbcCutGenerator.hpp:381
CbcCutGenerator::whetherInMustCallAgainMode
bool whetherInMustCallAgainMode() const
Whether in must call again mode (or after others)
Definition: CbcCutGenerator.hpp:337
CbcCutGenerator::setAtSolution
void setAtSolution(bool value)
Set whether the cut generator should be called when a solution is found.
Definition: CbcCutGenerator.hpp:197
CbcCutGenerator::CbcCutGenerator
CbcCutGenerator(CbcModel *model, CglCutGenerator *generator, int howOften=1, const char *name=NULL, bool normal=true, bool atSolution=false, bool infeasible=false, int howOftenInsub=-100, int whatDepth=-1, int whatDepthInSub=-1, int switchOffIfLessThan=0)
Normal constructor.
CbcCutGenerator::setSwitchedOff
void setSwitchedOff(bool yesNo)
Set whether generator switched off for moment.
Definition: CbcCutGenerator.hpp:314
CbcCutGenerator::incrementNumberColumnCuts
void incrementNumberColumnCuts(int value=1)
Definition: CbcCutGenerator.hpp:272
CbcCutGenerator::switchOffIfLessThan
int switchOffIfLessThan() const
Definition: CbcCutGenerator.hpp:288
CbcCutGenerator::atSolution
bool atSolution() const
Get whether the cut generator should be called when a solution is found.
Definition: CbcCutGenerator.hpp:193
CbcCutGenerator::incrementNumberTimesEntered
void incrementNumberTimesEntered(int value=1)
Definition: CbcCutGenerator.hpp:242
CbcCutGenerator::setWhetherCallAtEnd
void setWhetherCallAtEnd(bool yesNo)
Set whether to call at end.
Definition: CbcCutGenerator.hpp:350
CbcCutGenerator::needsOptimalBasis
bool needsOptimalBasis() const
Say if optimal basis needed.
Definition: CbcCutGenerator.hpp:292
CbcCutGenerator::maximumTries
int maximumTries() const
Get maximum number of times to enter.
Definition: CbcCutGenerator.hpp:172
CbcCutGenerator::generator
CglCutGenerator * generator() const
Get the CglCutGenerator corresponding to this CbcCutGenerator.
Definition: CbcCutGenerator.hpp:232
CbcCutGenerator::globalCuts
bool globalCuts() const
Whether global cuts.
Definition: CbcCutGenerator.hpp:398
CbcCutGenerator::whetherToUse
bool whetherToUse() const
Whether to use if any cuts generated.
Definition: CbcCutGenerator.hpp:328
CbcCutGenerator::setSwitches
void setSwitches(int value)
Set switches (for copying from virgin state)
Definition: CbcCutGenerator.hpp:180
CbcCutGenerator::setNumberColumnCuts
void setNumberColumnCuts(int value)
Definition: CbcCutGenerator.hpp:269
CbcCutGenerator::switches
int switches() const
Get switches.
Definition: CbcCutGenerator.hpp:176
CbcCutGenerator::operator=
CbcCutGenerator & operator=(const CbcCutGenerator &rhs)
Assignment operator.
CbcCutGenerator::setNormal
void setNormal(bool value)
Set whether the cut generator should be called in the normal place.
Definition: CbcCutGenerator.hpp:188
CbcCutModifier.hpp
CbcCutGenerator::setNeedsRefresh
void setNeedsRefresh(bool yesNo)
Set whether needs refresh on copy.
Definition: CbcCutGenerator.hpp:359
CbcCutGenerator::refreshModel
void refreshModel(CbcModel *model)
Set the client model.
CbcCutGenerator::numberShortCutsAtRoot
int numberShortCutsAtRoot() const
Number of short cuts at root.
Definition: CbcCutGenerator.hpp:378
CbcCutGenerator::setNumberCutsInTotal
void setNumberCutsInTotal(int value)
Definition: CbcCutGenerator.hpp:249
CbcCutGenerator::timeInCutGenerator
double timeInCutGenerator() const
Return time taken in cut generator.
Definition: CbcCutGenerator.hpp:225
CbcCutGenerator::globalCutsAtRoot
bool globalCutsAtRoot() const
Whether global cuts at root.
Definition: CbcCutGenerator.hpp:389
CbcModel
Simple Branch and bound class.
Definition: CbcModel.hpp:101
CbcCutGenerator::howOften
int howOften() const
Get the cut generation interval.
Definition: CbcCutGenerator.hpp:131
CbcCutGenerator::incrementNumberCutsInTotal
void incrementNumberCutsInTotal(int value=1)
Definition: CbcCutGenerator.hpp:252
CbcCutGenerator::mustCallAgain
bool mustCallAgain() const
Whether generator MUST be called again if any cuts (i.e. ignore break from loop)
Definition: CbcCutGenerator.hpp:301
CbcCutGenerator::scaleBackStatistics
void scaleBackStatistics(int factor)
Scale back statistics by factor.
CbcCutGenerator::setMaximumTries
void setMaximumTries(int value)
Set maximum number of times to enter.
Definition: CbcCutGenerator.hpp:169
CbcCutGenerator::setWhetherInMustCallAgainMode
void setWhetherInMustCallAgainMode(bool yesNo)
Set whether in must call again mode (or after others)
Definition: CbcCutGenerator.hpp:341
CbcCutGenerator::numberCutsActive
int numberCutsActive() const
Total number of cuts active after (at end of n cut passes at each node)
Definition: CbcCutGenerator.hpp:276
CbcCutGenerator::addStatistics
void addStatistics(const CbcCutGenerator *other)
Add in statistics from other.
CbcCutGenerator::setSwitchOffIfLessThan
void setSwitchOffIfLessThan(int value)
Definition: CbcCutGenerator.hpp:285
CbcCutGenerator::whetherCallAtEnd
bool whetherCallAtEnd() const
Whether to call at end.
Definition: CbcCutGenerator.hpp:346
CbcCutGenerator::setInaccuracy
void setInaccuracy(int level)
Set level of cut inaccuracy (0 means exact e.g. cliques)
Definition: CbcCutGenerator.hpp:143
CbcCutGenerator::setNumberElementsInTotal
void setNumberElementsInTotal(int value)
Definition: CbcCutGenerator.hpp:259
CbcCutGenerator::CbcCutGenerator
CbcCutGenerator(const CbcCutGenerator &)
Copy constructor.
CbcCutGenerator::numberTimesEntered
int numberTimesEntered() const
Number times cut generator entered.
Definition: CbcCutGenerator.hpp:236
CbcCutGenerator::setNumberCutsAtRoot
void setNumberCutsAtRoot(int value)
Definition: CbcCutGenerator.hpp:367
CbcCutGenerator::setWhatDepthInSub
void setWhatDepthInSub(int value)
Set the cut generation depth in sub tree.
CbcCutGenerator::whatDepth
int whatDepth() const
Get the cut generation depth criterion.
Definition: CbcCutGenerator.hpp:161
CbcCutGenerator::generateCuts
bool generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface *solver, CbcNode *node)
Generate cuts for the client model.
CbcCutGenerator::setTiming
void setTiming(bool value)
Set whether the cut generator is being timed.
Definition: CbcCutGenerator.hpp:219
CbcCutGenerator::normal
bool normal() const
Get whether the cut generator should be called in the normal place.
Definition: CbcCutGenerator.hpp:184
CbcNode
Information required while the node is live.
Definition: CbcNode.hpp:49
CbcCutGenerator::switchedOff
bool switchedOff() const
Whether generator switched off for moment.
Definition: CbcCutGenerator.hpp:310
CbcCutGenerator::numberActiveCutsAtRoot
int numberActiveCutsAtRoot() const
Number of cuts active at root.
Definition: CbcCutGenerator.hpp:371
CbcCutGenerator::timing
bool timing() const
Get whether the cut generator is being timed.
Definition: CbcCutGenerator.hpp:215
CbcCutGenerator::ineffectualCuts
bool ineffectualCuts() const
Whether last round of cuts did little.
Definition: CbcCutGenerator.hpp:319
CbcCutGenerator::numberColumnCuts
int numberColumnCuts() const
Total number of column cuts.
Definition: CbcCutGenerator.hpp:266
CbcCutGenerator::howOftenInSub
int howOftenInSub() const
Get the cut generation interval.in sub tree.
Definition: CbcCutGenerator.hpp:135
CbcCutGenerator::setIneffectualCuts
void setIneffectualCuts(bool yesNo)
Set whether last round of cuts did little.
Definition: CbcCutGenerator.hpp:323
CbcCutGenerator::setModel
void setModel(CbcModel *model)
Set model.
Definition: CbcCutGenerator.hpp:385
CbcCutGenerator
Interface between Cbc and Cut Generation Library.
Definition: CbcCutGenerator.hpp:49
CbcCutGenerator::incrementTimeInCutGenerator
void incrementTimeInCutGenerator(double value)
Definition: CbcCutGenerator.hpp:228
CbcCutGenerator::incrementNumberCutsActive
void incrementNumberCutsActive(int value=1)
Definition: CbcCutGenerator.hpp:282
CbcCutGenerator::setNumberTimesEntered
void setNumberTimesEntered(int value)
Definition: CbcCutGenerator.hpp:239
CbcCutGenerator::whenInfeasible
bool whenInfeasible() const
Get whether the cut generator should be called when the subproblem is found to be infeasible.
Definition: CbcCutGenerator.hpp:204
CbcCutGenerator::whatDepthInSub
int whatDepthInSub() const
Get the cut generation depth criterion.in sub tree.
Definition: CbcCutGenerator.hpp:165
CbcCutGenerator::setNumberCutsActive
void setNumberCutsActive(int value)
Definition: CbcCutGenerator.hpp:279
CbcCutGenerator::~CbcCutGenerator
~CbcCutGenerator()
Destructor.
CbcCutGenerator::needsRefresh
bool needsRefresh() const
Whether needs refresh on copy.
Definition: CbcCutGenerator.hpp:355
CbcCutGenerator::numberElementsInTotal
int numberElementsInTotal() const
Total number of elements added.
Definition: CbcCutGenerator.hpp:256
CbcCutGenerator::setMustCallAgain
void setMustCallAgain(bool yesNo)
Set whether generator MUST be called again if any cuts (i.e. ignore break from loop)
Definition: CbcCutGenerator.hpp:305
CbcCutGenerator::setWhetherToUse
void setWhetherToUse(bool yesNo)
Set whether to use if any cuts generated.
Definition: CbcCutGenerator.hpp:332
CbcCutGenerator::generateTuning
void generateTuning(FILE *fp)
Create C++ lines to show how to tune.