Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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 {
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 {
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 
422 
423  // The CglCutGenerator object
425 
428 
440 
445 
451 
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 
void setSwitches(int value)
Set switches (for copying from virgin state)
void setNumberColumnCuts(int value)
int switchOffIfLessThan() const
void setWhatDepth(int value)
Set the cut generation depth.
int numberCutsAtRoot() const
Number of cuts generated at root.
bool switchedOff() const
Whether generator switched off for moment.
void setNormal(bool value)
Set whether the cut generator should be called in the normal place.
void setWhetherToUse(bool yesNo)
Set whether to use if any cuts generated.
int depthCutGenerator_
Depth at which to call the CglCutGenerator::generateCuts routine (If >0 then overrides when and is ca...
void setIneffectualCuts(bool yesNo)
Set whether last round of cuts did little.
void setNumberCutsInTotal(int value)
bool globalCutsAtRoot() const
Whether global cuts at root.
int maximumTries() const
Get maximum number of times to enter.
const char * cutGeneratorName() const
return name of generator
int depthCutGeneratorInSub_
Depth at which to call the CglCutGenerator::generateCuts routine (If >0 then overrides when and is ca...
bool needsRefresh() const
Whether needs refresh on copy.
void incrementNumberCutsInTotal(int value=1)
int inaccuracy_
Level of cut inaccuracy (0 means exact e.g. cliques)
bool whetherCallAtEnd() const
Whether to call at end.
CbcModel * model_
The client model.
int numberCuts_
Total number of cuts added.
int switches() const
Get switches.
void setWhenInfeasible(bool value)
Set whether the cut generator should be called when the subproblem is found to be infeasible...
int whatDepth() const
Get the cut generation depth criterion.
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
CbcCutGenerator & operator=(const CbcCutGenerator &rhs)
Assignment operator.
bool atSolution() const
Get whether the cut generator should be called when a solution is found.
int numberElementsInTotal() const
Total number of elements added.
void setGlobalCuts(bool yesNo)
Set whether global cuts.
void setNumberCutsAtRoot(int value)
double timeInCutGenerator_
Time in cut generator.
int numberCutsAtRoot_
Number of cuts generated at root.
Abstract Base Class for describing an interface to a solver.
bool generateCuts(OsiCuts &cs, int fullScan, OsiSolverInterface *solver, CbcNode *node)
Generate cuts for the client model.
int numberActiveCutsAtRoot() const
Number of cuts active at root.
void setTiming(bool value)
Set whether the cut generator is being timed.
int numberColumnCuts_
Total number of column cuts added.
int numberTimes_
Number times cut generator entered.
int numberCutsActive() const
Total number of cuts active after (at end of n cut passes at each node)
void setNeedsOptimalBasis(bool yesNo)
Set if optimal basis needed.
bool globalCuts() const
Whether global cuts.
bool whenInfeasible() const
Get whether the cut generator should be called when the subproblem is found to be infeasible...
void setWhetherInMustCallAgainMode(bool yesNo)
Set whether in must call again mode (or after others)
void setNumberShortCutsAtRoot(int value)
void setAtSolution(bool value)
Set whether the cut generator should be called when a solution is found.
Cut Generator Base Class.
int switchOffIfLessThan_
If first pass at root produces fewer than this cuts then switch off.
double timeInCutGenerator() const
Return time taken in cut generator.
void setSwitchedOff(bool yesNo)
Set whether generator switched off for moment.
void incrementNumberColumnCuts(int value=1)
void refreshModel(CbcModel *model)
Set the client model.
bool whetherInMustCallAgainMode() const
Whether in must call again mode (or after others)
void setNumberTimesEntered(int value)
int numberTimesEntered() const
Number times cut generator entered.
char * generatorName_
Name of generator.
int inaccuracy() const
Get level of cut inaccuracy (0 means exact e.g. cliques)
int numberCutsActive_
Total number of cuts active after (at end of n cut passes at each node)
int whenCutGenerator_
Number of nodes between calls to the CglCutGenerator::generateCuts routine.
Information required while the node is live.
Definition: CbcNode.hpp:49
void setNumberCutsActive(int value)
int numberColumnCuts() const
Total number of column cuts.
int numberCutsInTotal() const
Total number of cuts added.
void setWhetherCallAtEnd(bool yesNo)
Set whether to call at end.
CglCutGenerator * generator_
~CbcCutGenerator()
Destructor.
Row Cut Class.
Definition: OsiRowCut.hpp:29
bool timing() const
Get whether the cut generator is being timed.
int numberActiveCutsAtRoot_
Number of cuts active at root.
bool ineffectualCuts() const
Whether last round of cuts did little.
int whatDepthInSub() const
Get the cut generation depth criterion.in sub tree.
void generateTuning(FILE *fp)
Create C++ lines to show how to tune.
void scaleBackStatistics(int factor)
Scale back statistics by factor.
void setMaximumTries(int value)
Set maximum number of times to enter.
void setModel(CbcModel *model)
Set model.
void setGlobalCutsAtRoot(bool yesNo)
Set whether global cuts at root.
void setNeedsRefresh(bool yesNo)
Set whether needs refresh on copy.
void incrementNumberCutsActive(int value=1)
int switches_
Switches - see gets and sets.
void setInaccuracy(int level)
Set level of cut inaccuracy (0 means exact e.g. cliques)
CglCutGenerator * generator() const
Get the CglCutGenerator corresponding to this CbcCutGenerator.
void setNumberElementsInTotal(int value)
bool whetherToUse() const
Whether to use if any cuts generated.
bool normal() const
Get whether the cut generator should be called in the normal place.
void setWhatDepthInSub(int value)
Set the cut generation depth in sub tree.
CbcCutGenerator()
Default constructor.
void setNumberActiveCutsAtRoot(int value)
bool mustCallAgain() const
Whether generator MUST be called again if any cuts (i.e. ignore break from loop)
int numberShortCutsAtRoot() const
Number of short cuts at root.
Validate cuts against a known solution.
void setMustCallAgain(bool yesNo)
Set whether generator MUST be called again if any cuts (i.e. ignore break from loop) ...
bool needsOptimalBasis() const
Say if optimal basis needed.
OsiCuts savedCuts_
Saved cuts.
int numberShortCutsAtRoot_
Number of short cuts at root.
int howOftenInSub() const
Get the cut generation interval.in sub tree.
Interface between Cbc and Cut Generation Library.
void addStatistics(const CbcCutGenerator *other)
Add in statistics from other.
void setSwitchOffIfLessThan(int value)
int whenCutGeneratorInSub_
Number of nodes between calls to the CglCutGenerator::generateCuts routine in sub tree...
Simple Branch and bound class.
Definition: CbcModel.hpp:101
void setHowOften(int value)
Set the cut generation interval.
int howOften() const
Get the cut generation interval.
void incrementTimeInCutGenerator(double value)
void incrementNumberElementsInTotal(int value=1)
int maximumTries_
Maximum number of times to enter.
void incrementNumberTimesEntered(int value=1)
int numberElements_
Total number of elements added.