CbcCutGenerator.hpp
Go to the documentation of this file.
1 /* $Id: CbcCutGenerator.hpp 1432 2010-02-07 19:33:53Z bjarni $ */
2 // Copyright (C) 2003, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef CbcCutGenerator_H
5 #define CbcCutGenerator_H
6 
7 #include "OsiSolverInterface.hpp"
8 #include "OsiCuts.hpp"
9 #include "CglCutGenerator.hpp"
10 #include "CbcCutModifier.hpp"
11 
12 class CbcModel;
13 class OsiRowCut;
14 class OsiRowCutDebugger;
15 
16 //#############################################################################
17 
47 class CbcCutGenerator {
48 
49 public:
50 
69  bool generateCuts( OsiCuts &cs, int fullScan, OsiSolverInterface * solver,
70  CbcNode * node);
72 
73 
76 
77  CbcCutGenerator ();
78 
80  CbcCutGenerator(CbcModel * model, CglCutGenerator * generator,
81  int howOften = 1, const char * name = NULL,
82  bool normal = true, bool atSolution = false,
83  bool infeasible = false, int howOftenInsub = -100,
84  int whatDepth = -1, int whatDepthInSub = -1, int switchOffIfLessThan = 0);
85 
88 
91 
95 
103  void refreshModel(CbcModel * model);
104 
106  inline const char * cutGeneratorName() const {
107  return generatorName_;
108  }
109 
111  void generateTuning( FILE * fp);
126  void setHowOften(int value) ;
127 
129  inline int howOften() const {
130  return whenCutGenerator_;
131  }
133  inline int howOftenInSub() const {
134  return whenCutGeneratorInSub_;
135  }
137  inline int inaccuracy() const {
138  return inaccuracy_;
139  }
141  inline void setInaccuracy(int level) {
142  inaccuracy_ = level;
143  }
144 
155  void setWhatDepth(int value) ;
157  void setWhatDepthInSub(int value) ;
159  inline int whatDepth() const {
160  return depthCutGenerator_;
161  }
163  inline int whatDepthInSub() const {
165  }
166 
168  inline bool normal() const {
169  return (switches_&1) != 0;
170  }
172  inline void setNormal(bool value) {
173  switches_ &= ~1;
174  switches_ |= value ? 1 : 0;
175  }
177  inline bool atSolution() const {
178  return (switches_&2) != 0;
179  }
181  inline void setAtSolution(bool value) {
182  switches_ &= ~2;
183  switches_ |= value ? 2 : 0;
184  }
188  inline bool whenInfeasible() const {
189  return (switches_&4) != 0;
190  }
194  inline void setWhenInfeasible(bool value) {
195  switches_ &= ~4;
196  switches_ |= value ? 4 : 0;
197  }
199  inline bool timing() const {
200  return (switches_&64) != 0;
201  }
203  inline void setTiming(bool value) {
204  switches_ &= ~64;
205  switches_ |= value ? 64 : 0;
206  timeInCutGenerator_ = 0.0;
207  }
209  inline double timeInCutGenerator() const {
210  return timeInCutGenerator_;
211  }
212  inline void incrementTimeInCutGenerator(double value) {
213  timeInCutGenerator_ += value;
214  }
216  inline CglCutGenerator * generator() const {
217  return generator_;
218  }
220  inline int numberTimesEntered() const {
221  return numberTimes_;
222  }
223  inline void setNumberTimesEntered(int value) {
224  numberTimes_ = value;
225  }
226  inline void incrementNumberTimesEntered(int value = 1) {
227  numberTimes_ += value;
228  }
230  inline int numberCutsInTotal() const {
231  return numberCuts_;
232  }
233  inline void setNumberCutsInTotal(int value) {
234  numberCuts_ = value;
235  }
236  inline void incrementNumberCutsInTotal(int value = 1) {
237  numberCuts_ += value;
238  }
240  inline int numberElementsInTotal() const {
241  return numberElements_;
242  }
243  inline void setNumberElementsInTotal(int value) {
244  numberElements_ = value;
245  }
246  inline void incrementNumberElementsInTotal(int value = 1) {
247  numberElements_ += value;
248  }
250  inline int numberColumnCuts() const {
251  return numberColumnCuts_;
252  }
253  inline void setNumberColumnCuts(int value) {
254  numberColumnCuts_ = value;
255  }
256  inline void incrementNumberColumnCuts(int value = 1) {
257  numberColumnCuts_ += value;
258  }
260  inline int numberCutsActive() const {
261  return numberCutsActive_;
262  }
263  inline void setNumberCutsActive(int value) {
264  numberCutsActive_ = value;
265  }
266  inline void incrementNumberCutsActive(int value = 1) {
267  numberCutsActive_ += value;
268  }
269  inline void setSwitchOffIfLessThan(int value) {
270  switchOffIfLessThan_ = value;
271  }
272  inline int switchOffIfLessThan() const {
273  return switchOffIfLessThan_;
274  }
276  inline bool needsOptimalBasis() const {
277  return (switches_&128) != 0;
278  }
280  inline void setNeedsOptimalBasis(bool yesNo) {
281  switches_ &= ~128;
282  switches_ |= yesNo ? 128 : 0;
283  }
285  inline bool mustCallAgain() const {
286  return (switches_&8) != 0;
287  }
289  inline void setMustCallAgain(bool yesNo) {
290  switches_ &= ~8;
291  switches_ |= yesNo ? 8 : 0;
292  }
294  inline bool switchedOff() const {
295  return (switches_&16) != 0;
296  }
298  inline void setSwitchedOff(bool yesNo) {
299  switches_ &= ~16;
300  switches_ |= yesNo ? 16 : 0;
301  }
303  inline bool ineffectualCuts() const {
304  return (switches_&512) != 0;
305  }
307  inline void setIneffectualCuts(bool yesNo) {
308  switches_ &= ~512;
309  switches_ |= yesNo ? 512 : 0;
310  }
312  inline bool whetherToUse() const {
313  return (switches_&1024) != 0;
314  }
316  inline void setWhetherToUse(bool yesNo) {
317  switches_ &= ~1024;
318  switches_ |= yesNo ? 1024 : 0;
319  }
321  inline int numberCutsAtRoot() const {
322  return numberCutsAtRoot_;
323  }
324  inline void setNumberCutsAtRoot(int value) {
325  numberCutsAtRoot_ = value;
326  }
328  inline int numberActiveCutsAtRoot() const {
330  }
331  inline void setNumberActiveCutsAtRoot(int value) {
332  numberActiveCutsAtRoot_ = value;
333  }
335  inline int numberShortCutsAtRoot() const {
336  return numberShortCutsAtRoot_;
337  }
339  inline void setModel(CbcModel * model) {
340  model_ = model;
341  }
343  inline bool globalCutsAtRoot() const {
344  return (switches_&32) != 0;
345  }
347  inline void setGlobalCutsAtRoot(bool yesNo) {
348  switches_ &= ~32;
349  switches_ |= yesNo ? 32 : 0;
350  }
352  inline bool globalCuts() const {
353  return (switches_&256) != 0;
354  }
356  inline void setGlobalCuts(bool yesNo) {
357  switches_ &= ~256;
358  switches_ |= yesNo ? 256 : 0;
359  }
361 
362 private:
365 
366 
367  OsiCuts savedCuts_;
369  double timeInCutGenerator_;
371  CbcModel *model_;
372 
373  // The CglCutGenerator object
374  CglCutGenerator * generator_;
375 
377  char * generatorName_;
378 
382  int whenCutGenerator_;
390 
394  int depthCutGenerator_;
395 
401 
403  int inaccuracy_;
405  int numberTimes_;
407  int numberCuts_;
409  int numberElements_;
411  int numberColumnCuts_;
413  int numberCutsActive_;
415  int numberCutsAtRoot_;
421  int switches_;
422 };
423 
424 // How often to do if mostly switched off (A)
425 # define SCANCUTS 1000
426 // How often to do if mostly switched off (probing B)
427 # define SCANCUTS_PROBING 1000
428 
429 #endif
430