CbcGenCtlBlk.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007, Lou Hafer, International Business Machines Corporation
3  and others. All Rights Reserved.
4 
5  This file is part of cbc-generic.
6 */
7 
8 #ifndef CbcGenCtlBlk_H
9 #define CbcGenCtlBlk_H
10 
11 /* \file CbcGenCtlBlk.hpp
12  \brief Declarations for parameters of the cbc-generic main program.
13 */
14 
15 #include "CoinParam.hpp"
16 #include "CoinMessageHandler.hpp"
17 
18 #include "CglCutGenerator.hpp"
19 #include "CglProbing.hpp"
20 #include "CglClique.hpp"
21 #include "CglFlowCover.hpp"
22 #include "CglGomory.hpp"
23 #include "CglKnapsackCover.hpp"
24 #include "CglMixedIntegerRounding2.hpp"
25 #include "CglOddHole.hpp"
26 #include "CglRedSplit.hpp"
27 #include "CglTwomir.hpp"
28 
29 #include "CbcModel.hpp"
30 
31 #include "CbcHeuristic.hpp"
32 #include "CbcHeuristicFPump.hpp"
33 #include "CbcHeuristicGreedy.hpp"
34 #include "CbcHeuristicLocal.hpp"
35 #include "CbcTreeLocal.hpp"
36 
37 #include "CbcGenMessages.hpp"
38 
39 /*
40  It turns out that doxygen is not good with anonymous structures. Hence the
41  `struct nameCtl_struct' style used for structured fields in CbcGenCtlBlk.
42 */
43 
44 /*
45  $Id: CbcGenCtlBlk.hpp 1173 2009-06-04 09:44:10Z forrest $
46 */
47 
48 #define CBC_GENERIC_VERSION "00.01.00"
49 
50 class CbcGenCtlBlk ;
51 namespace CbcGenParamUtils {
52 void addCbcGenParams(int &numParams, CoinParamVec &paramVec,
53  CbcGenCtlBlk *ctlBlk) ;
54 }
55 
56 /* \brief cbc-generic algorithm control class
57 
58  This class defines values and methods used to control the operation of the
59  cbc-generic main program.
60 */
61 
62 class CbcGenCtlBlk {
63 
64  friend void CbcGenParamUtils::addCbcGenParams(int &numParams,
65  CoinParamVec &paramVec, CbcGenCtlBlk *ctlBlk) ;
66 
67 public:
68 
71 
72  /*
73  In order for initialisation to work properly, the order of declaration of
74  the enum constants here must match the order of keyword declaration for
75  the PREPROCESS parameter in CbcGenParamUtils::addCbcGenParams
76  */
94  typedef enum { IPPOff = 0, IPPOn, IPPSave, IPPEqual,
96  } IPPControl ;
97 
98  /*
99  In order for initialisation to work properly, the order of declaration of
100  the enum constants here must match the order of keyword declaration for
101  the various cut and heuristic control parameters in
102  CbcGenParamUtils::addCbcGenParams
103  */
124  typedef enum { CGOff, CGOn, CGRoot, CGIfMove,
126  } CGControl ;
127 
136  typedef enum { BPOff, BPCost, BPOrder, BPExt } BPControl ;
137 
153  typedef enum { BACInvalid = -1, BACFinish = 0,
155  } BACMajor ;
156 
176  typedef enum { BACmInvalid = -1, BACmFinish = 0, BACmInfeas, BACmUbnd,
179  } BACMinor ;
180 
190  typedef enum { BACwInvalid = -1, BACwNotStarted = 0, BACwBareRoot,
192  } BACWhere ;
193 
195 
198 
201  CbcGenCtlBlk() ;
202 
205  ~CbcGenCtlBlk() ;
207 
223 
231  inline int getCutDepth() {
232  return cutDepth_ ;
233  }
234 
240  inline void setCutDepth(int cutDepth) {
241  cutDepth_ = cutDepth ;
242  }
243 
244  /*1 \brief Get action state for use of integer preprocessing */
245 
247  return (preProcess_) ;
248  }
249 
252  inline void setIPPAction(IPPControl action) {
253  preProcess_ = action ;
254  }
255 
258  CGControl getProbing(CglCutGenerator *&gen) ;
259 
262  inline void setProbingAction(CGControl action) {
263  probing_.action_ = action ;
264  }
265 
268  CGControl getClique(CglCutGenerator *&gen) ;
269 
272  inline void setCliqueAction(CGControl action) {
273  clique_.action_ = action ;
274  }
275 
278  CGControl getFlow(CglCutGenerator *&gen) ;
279 
282  inline void setFlowAction(CGControl action) {
283  flow_.action_ = action ;
284  }
285 
288  CGControl getGomory(CglCutGenerator *&gen) ;
289 
292  inline void setGomoryAction(CGControl action) {
293  gomory_.action_ = action ;
294  }
295 
298  CGControl getKnapsack(CglCutGenerator *&gen) ;
299 
302  inline void setKnapsackAction(CGControl action) {
303  knapsack_.action_ = action ;
304  }
305 
306  /* \brief Obtain a prototype for a lift-and-project cut generator.
307 
308  CGControl getLandP(CglCutGenerator *&gen) ;
309 
310  \brief Set action state for use of lift-and-project cut generator.
311 
312  inline void setLandPAction(CGControl action)
313  { landp_.action_ = action ; }
314  */
315 
320  CGControl getMir(CglCutGenerator *&gen) ;
321 
324  inline void setMirAction(CGControl action) {
325  mir_.action_ = action ;
326  }
327 
330  CGControl getRedSplit(CglCutGenerator *&gen) ;
331 
334  inline void setRedSplitAction(CGControl action) {
335  redSplit_.action_ = action ;
336  }
337 
340  CGControl getTwomir(CglCutGenerator *&gen) ;
341 
344  inline void setTwomirAction(CGControl action) {
345  twomir_.action_ = action ;
346  }
347 
348 
356  CGControl getFPump(CbcHeuristic *&gen, CbcModel *model,
357  bool alwaysCreate = true) ;
358 
361  inline void setFPumpAction(CGControl action) {
362  fpump_.action_ = action ;
363  }
364 
373  bool alwaysCreate = true) ;
374 
377  inline void setCombineAction(CGControl action) {
378  combine_.action_ = action ;
379  }
380 
389  bool alwaysCreate = true) ;
390 
393  inline void setGreedyCoverAction(CGControl action) {
394  greedyCover_.action_ = action ;
395  }
396 
405  bool alwaysCreate = true) ;
406 
409  inline void setGreedyEqualityAction(CGControl action) {
410  greedyEquality_.action_ = action ;
411  }
412 
421  bool alwaysCreate = true) ;
422 
425  inline void setRoundingAction(CGControl action) {
426  rounding_.action_ = action ;
427  }
428 
436  CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model,
437  bool alwaysCreate = true) ;
438 
441  inline void setTreeLocalAction(CGControl action) {
442  localTree_.action_ = action ;
443  }
444 
446 
451 
454  inline void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus,
455  BACWhere where, bool haveAnswer,
456  OsiSolverInterface *answerSolver) {
457  bab_.majorStatus_ = majorStatus ;
458  bab_.minorStatus_ = minorStatus ;
459  bab_.where_ = where ;
460  bab_.haveAnswer_ = haveAnswer ;
461  bab_.answerSolver_ = answerSolver ;
462  }
463 
469  void setBaBStatus(const CbcModel *model, BACWhere where,
470  bool haveAnswer = false,
471  OsiSolverInterface *answerSolver = 0) ;
472 
477  BACMajor translateMajor(int status) ;
478 
483  BACMinor translateMinor(int status) ;
484 
490  BACMinor translateMinor(const OsiSolverInterface *osi) ;
491 
494  void printBaBStatus() ;
495 
497 
500 
505  CoinMessageHandler &message(CbcGenMsgCode inID) ;
506 
512  void passInMessageHandler(CoinMessageHandler *handler) ;
513 
515  inline CoinMessageHandler *messageHandler() const {
516  return msgHandler_ ;
517  }
518 
531  void setMessages(CoinMessages::Language lang = CoinMessages::us_en) ;
532 
534  inline void setLogLevel(int lvl) {
535  logLvl_ = lvl ;
536  if (msgHandler_) msgHandler_->setLogLevel(lvl) ;
537  }
538 
540  inline int logLevel() const {
541  return (logLvl_) ;
542  }
543 
547  int printOpt_ ;
548 
550 
555  std::string version_ ;
556 
559  std::string dfltDirectory_ ;
560 
563  std::string lastMpsIn_ ;
564 
567 
570  std::string lastSolnOut_ ;
571 
579 
585  std::string printMask_ ;
586 
589  CoinParamVec *paramVec_ ;
590 
594  int first_ ;
595  int last_ ;
596  } genParams_ ;
597 
601  int first_ ;
602  int last_ ;
603  } cbcParams_ ;
604 
610  int first_ ;
611  int last_ ;
612  } osiParams_ ;
613 
623  int verbose_ ;
624 
628 
631  std::vector<bool> setByUser_ ;
632 
640 
649  std::string debugCreate_ ;
650 
657  std::string debugFile_ ;
658 
665  int numCols_ ;
666  double *values_ ;
667  } debugSol_ ;
669 
670  /* \name Timing */
672 
675  double totalTime_ ;
676 
678 
681 
693 
700  OsiSolverInterface *dfltSolver_ ;
701 
704  bool goodModel_ ;
705 
717  bool haveAnswer_ ;
718  OsiSolverInterface *answerSolver_ ;
719  } bab_ ;
720 
722 
725 
735  bool action_ ;
736  double threshold_ ;
737  } djFix_ ;
738 
743 
745 
752 
764  } chooseStrong_ ;
766 
767 private:
768 
773 
777 
784  int cutDepth_ ;
785 
789  CglProbing *proto_ ;
791  int maxPass_ ;
793  int maxProbe_ ;
795  int maxLook_ ;
798  int rowCuts_ ;
799  } probing_ ;
800 
804  CglClique *proto_ ;
807  double minViolation_ ;
808  } clique_ ;
809 
811  struct flowCtl_struct {
813  CglFlowCover *proto_ ;
814  } flow_ ;
815 
819  CglGomory *proto_ ;
820  int limit_ ;
822  } gomory_ ;
823 
824  /* \brief Control variable and prototype for lift-and-project cut
825  generator
826  struct landpCtl_struct
827  { CGControl action_ ;
828  CglLandP *proto_ ; } landp_ ;
829  */
830 
834  CglKnapsackCover *proto_ ;
835  } knapsack_ ;
836 
838  struct mirCtl_struct {
840  CglMixedIntegerRounding2 *proto_ ;
841  } mir_ ;
842 
846  CglOddHole *proto_ ;
847  } oddHole_ ;
848 
854  CglRedSplit *proto_ ;
855  } redSplit_ ;
856 
860  CglTwomir *proto_ ;
862  } twomir_ ;
863 
868  int iters_ ;
869  } fpump_ ;
870 
875  int trySwap_ ;
876  } combine_ ;
877 
882  } greedyCover_ ;
883 
888  } greedyEquality_ ;
889 
894  } rounding_ ;
895 
896 
906  double *soln_ ;
907  int range_ ;
908  int typeCuts_ ;
912  bool refine_ ;
913  } localTree_ ;
914 
916 
922 
924  CoinMessageHandler *msgHandler_ ;
925 
933 
935  CoinMessages::Language cur_lang_ ;
936 
938  CoinMessages *msgs_ ;
939 
941  int logLvl_ ;
942 
944 
945 } ;
946 
947 
948 #endif
949