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 
CbcHeuristicFPump * proto_
struct CbcGenCtlBlk::chooseStrongCtl_struct chooseStrong_
std::string lastSolnOut_
Last solution output file.
struct CbcGenCtlBlk::babState_struct bab_
The reference CbcModel object.
CGControl getGreedyEquality(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a greedy equality heuristic.
struct CbcGenCtlBlk::greedyCoverCtl_struct greedyCover_
Control integer preprocessing.
CGControl getClique(CglCutGenerator *&gen)
Obtain a prototype for a clique cut generator.
struct CbcGenCtlBlk::osiParamsInfo_struct osiParams_
cbc-generic version
struct CbcGenCtlBlk::combineCtl_struct combine_
Control integer preprocessing.
CGControl getFlow(CglCutGenerator *&gen)
Obtain a prototype for a flow cover cut generator.
Control variable and prototype for feasibility pump heuristic.
LocalSearch class.
void setLogLevel(int lvl)
Set log level.
int paramsProcessed_
Number of parameters processed.
void printBaBStatus()
Print the status block.
std::string debugCreate_
Control debug file creation.
std::string version_
cbc-generic version
CoinMessageHandler & message(CbcGenMsgCode inID)
Print a message.
CoinMessageHandler * msgHandler_
Message handler.
Control variable and prototype for flow cover cut generator.
struct CbcGenCtlBlk::knapsackCtl_struct knapsack_
Control integer preprocessing.
IPPControl getIPPAction()
Get cut depth setting.
Rounding class.
void setMirAction(CGControl action)
Set action state for use of MIR cut generator.
CGControl getTwomir(CglCutGenerator *&gen)
Obtain a prototype for a 2-MIR cut generator.
bool ourMsgHandler_
Ownership of message handler.
BACMajor translateMajor(int status)
Translate CbcModel major status to BACMajor.
void setProbingAction(CGControl action)
Set action state for use of probing cut generator.
BACMinor
Minor status codes.
OsiSolverInterface * dfltSolver_
The current default LP solver.
CGControl getKnapsack(CglCutGenerator *&gen)
Obtain a prototype for a knapsack cover cut generator.
Control variables for local tree.
IPPControl
Codes to control integer preprocessing.
int logLvl_
The current log level.
Start and end of cbc-generic parameters in parameter vector.
Control variable and prototype for simple rounding heuristic.
IPPControl preProcess_
Control integer preprocessing.
Control variable and prototype for probing cut generator.
Control variable and prototype for Gomory cut generator.
Control variable and prototype for clique cut generator.
void setFPumpAction(CGControl action)
Set action state for use of feasibility pump heuristic.
CoinParamVec * paramVec_
The parameter vector.
std::string lastMpsIn_
Last MPS input file.
Feasibility Pump class.
struct CbcGenCtlBlk::probingCtl_struct probing_
Control integer preprocessing.
void setRedSplitAction(CGControl action)
Set action state for use of reduce and split cut generator.
CbcHeuristicGreedyCover * proto_
Control variable and prototype for reduce-and-split cut generator.
void setGreedyEqualityAction(CGControl action)
Set action state for use of greedy equality heuristic.
void setTreeLocalAction(CGControl action)
Set action state for use of local tree.
struct CbcGenCtlBlk::redSplitCtl_struct redSplit_
Control integer preprocessing.
Control use of reduced cost fixing prior to B&C.
void addCbcGenParams(int &numParams, CoinParamVec &paramVec, CbcGenCtlBlk *ctlBlk)
CGControl getCombine(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a local search/combine heuristic.
int cutDepth_
Control cut generator activity.
void setRoundingAction(CGControl action)
Set action state for use of simple rounding heuristic.
Array of primal variable values for debugging.
struct CbcGenCtlBlk::localTreeCtl_struct localTree_
Control integer preprocessing.
BPControl priorityAction_
Control the assignment of branching priorities to integer variables.
CoinMessageHandler * messageHandler() const
Return a pointer to the message handler.
void setTwomirAction(CGControl action)
Set action state for use of 2-MIR cut generator.
CGControl getRounding(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a simple rounding heuristic.
CbcModel * model_
The reference CbcModel object.
void passInMessageHandler(CoinMessageHandler *handler)
Supply a new message handler.
void setCliqueAction(CGControl action)
Set action state for use of clique cut generator.
struct CbcGenCtlBlk::debugSolInfo_struct debugSol_
cbc-generic version
CGControl getGreedyCover(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a greedy cover heuristic.
void setGreedyCoverAction(CGControl action)
Set action state for use of greedy cover heuristic.
int printOpt_
When greater than 0, integer presolve gives more information and branch-and-cut provides statistics...
int verbose_
Verbosity level for help messages.
Start and end of OsiSolverInterface parameters in parameter vector.
CglMixedIntegerRounding2 * proto_
struct CbcGenCtlBlk::greedyEqualityCtl_struct greedyEquality_
Control integer preprocessing.
Control variable and prototype for greedy equality heuristic.
void setIPPAction(IPPControl action)
Set action state for use of integer preprocessing.
CGControl getFPump(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a feasibility pump heuristic.
struct CbcGenCtlBlk::djFixCtl_struct djFix_
Control the assignment of branching priorities to integer variables.
struct CbcGenCtlBlk::cliqueCtl_struct clique_
Control integer preprocessing.
Greedy heuristic classes.
struct CbcGenCtlBlk::gomoryCtl_struct gomory_
Control integer preprocessing.
struct CbcGenCtlBlk::roundingCtl_struct rounding_
Control integer preprocessing.
int logLevel() const
Get log level.
CGControl getGomory(CglCutGenerator *&gen)
Obtain a prototype for a Gomory cut generator.
std::string printMask_
Print mask.
CbcGenMsgCode
Symbolic names for cbc-generic messages.
Control variable and prototype for Two-MIR cut generator.
void setFlowAction(CGControl action)
Set action state for use of flow cover cut generator.
struct CbcGenCtlBlk::fpumpCtl_struct fpump_
Control integer preprocessing.
bool defaultSettings_
False if the user has made nontrivial modifications to the default control settings.
void setKnapsackAction(CGControl action)
Set action state for use of knapsack cut generator.
OsiSolverInterface * answerSolver_
std::vector< bool > setByUser_
Record of parameters changed by user command.
struct CbcGenCtlBlk::mirCtl_struct mir_
Control integer preprocessing.
struct CbcGenCtlBlk::oddHoleCtl_struct oddHole_
Control integer preprocessing.
void setMessages(CoinMessages::Language lang=CoinMessages::us_en)
Set up messages in the specified language.
void setGomoryAction(CGControl action)
Set action state for use of Gomory cut generator.
BACMinor translateMinor(int status)
Translate CbcModel minor status to BACMinor.
Heuristic base class.
CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model, bool alwaysCreate=true)
Obtain a local search tree object.
CGControl
Codes to control the use of cut generators and heuristics.
double totalTime_
Total elapsed time for this run.
std::string dfltDirectory_
Default directory prefix.
struct CbcGenCtlBlk::twomirCtl_struct twomir_
Control integer preprocessing.
Start and end of CbcModel parameters in parameter vector.
BACWhere
Codes to specify where branch-and-cut stopped.
CbcGenCtlBlk()
Default constructor.
BACMajor
Major status codes for branch-and-cut.
std::string debugFile_
Last debug input file.
struct CbcGenCtlBlk::flowCtl_struct flow_
Control integer preprocessing.
Control variable and prototype for knapsack cover cut generator.
~CbcGenCtlBlk()
Destructor.
Control variables for a strong branching method.
int printMode_
Solution printing mode.
Control variable and prototype for MIR cut generator.
CoinMessages * msgs_
The current set of messages.
void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus, BACWhere where, bool haveAnswer, OsiSolverInterface *answerSolver)
Set the result of branch-and-cut search.
State of branch-and-cut.
Control variable and prototype for odd hole cut generator.
bool allowImportErrors_
Allow/disallow errors when importing a model.
int getCutDepth()
Get cut depth setting.
struct CbcGenCtlBlk::genParamsInfo_struct genParams_
cbc-generic version
CoinMessages::Language cur_lang_
The current language.
CbcHeuristicGreedyEquality * proto_
struct CbcGenCtlBlk::cbcParamsInfo_struct cbcParams_
cbc-generic version
Control variable and prototype for greedy cover heuristic.
BPControl
Codes to specify the assignment of branching priorities.
bool goodModel_
True if we have a valid model loaded, false otherwise.
Control variable and prototype for combine heuristic.
CGControl getProbing(CglCutGenerator *&gen)
Obtain a prototype for a probing cut generator.
CGControl getRedSplit(CglCutGenerator *&gen)
Obtain a prototype for a reduce and split cut generator.
Simple Branch and bound class.
Definition: CbcModel.hpp:98
void setCutDepth(int cutDepth)
Set cut depth setting.
CGControl getMir(CglCutGenerator *&gen)
Obtain a prototype for a mixed integer rounding (MIR) cut generator.
void setCombineAction(CGControl action)
Set action state for use of local search/combine heuristic.