Cbc  2.8.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 code is licensed under the terms of the Eclipse Public License (EPL).
6 
7  $Id: CbcGenCtlBlk.hpp 1902 2013-04-10 16:58:16Z stefan $
8 */
9 /*
10  This file is part of cbc-generic.
11 */
12 
13 #ifndef CbcGenCtlBlk_H
14 #define CbcGenCtlBlk_H
15 
16 /* \file CbcGenCtlBlk.hpp
17  \brief Declarations for parameters of the cbc-generic main program.
18 */
19 
20 #include "CoinParam.hpp"
21 #include "CoinMessageHandler.hpp"
22 
23 #include "CglCutGenerator.hpp"
24 #include "CglProbing.hpp"
25 #include "CglClique.hpp"
26 #include "CglFlowCover.hpp"
27 #include "CglGomory.hpp"
28 #include "CglKnapsackCover.hpp"
29 #include "CglMixedIntegerRounding2.hpp"
30 #include "CglOddHole.hpp"
31 #include "CglRedSplit.hpp"
32 #include "CglTwomir.hpp"
33 
34 #include "CbcModel.hpp"
35 
36 #include "CbcHeuristic.hpp"
37 #include "CbcHeuristicFPump.hpp"
38 #include "CbcHeuristicGreedy.hpp"
39 #include "CbcHeuristicLocal.hpp"
40 #include "CbcTreeLocal.hpp"
41 
42 #include "CbcGenMessages.hpp"
43 
44 /*
45  It turns out that doxygen is not good with anonymous structures. Hence the
46  `struct nameCtl_struct' style used for structured fields in CbcGenCtlBlk.
47 */
48 
49 /*
50  $Id: CbcGenCtlBlk.hpp 1902 2013-04-10 16:58:16Z stefan $
51 */
52 
53 #define CBC_GENERIC_VERSION "00.01.00"
54 
55 class CbcGenCtlBlk ;
56 namespace CbcGenParamUtils {
57 void addCbcGenParams(int &numParams, CoinParamVec &paramVec,
58  CbcGenCtlBlk *ctlBlk) ;
59 }
60 
61 /* \brief cbc-generic algorithm control class
62 
63  This class defines values and methods used to control the operation of the
64  cbc-generic main program.
65 */
66 
67 class CbcGenCtlBlk {
68 
69  friend void CbcGenParamUtils::addCbcGenParams(int &numParams,
70  CoinParamVec &paramVec, CbcGenCtlBlk *ctlBlk) ;
71 
72 public:
73 
76 
77  /*
78  In order for initialisation to work properly, the order of declaration of
79  the enum constants here must match the order of keyword declaration for
80  the PREPROCESS parameter in CbcGenParamUtils::addCbcGenParams
81  */
99  typedef enum { IPPOff = 0, IPPOn, IPPSave, IPPEqual,
101  } IPPControl ;
102 
103  /*
104  In order for initialisation to work properly, the order of declaration of
105  the enum constants here must match the order of keyword declaration for
106  the various cut and heuristic control parameters in
107  CbcGenParamUtils::addCbcGenParams
108  */
129  typedef enum { CGOff, CGOn, CGRoot, CGIfMove,
131  } CGControl ;
132 
141  typedef enum { BPOff, BPCost, BPOrder, BPExt } BPControl ;
142 
158  typedef enum { BACInvalid = -1, BACFinish = 0,
160  } BACMajor ;
161 
181  typedef enum { BACmInvalid = -1, BACmFinish = 0, BACmInfeas, BACmUbnd,
184  } BACMinor ;
185 
195  typedef enum { BACwInvalid = -1, BACwNotStarted = 0, BACwBareRoot,
197  } BACWhere ;
198 
200 
203 
206  CbcGenCtlBlk() ;
207 
210  ~CbcGenCtlBlk() ;
212 
228 
236  inline int getCutDepth() {
237  return cutDepth_ ;
238  }
239 
245  inline void setCutDepth(int cutDepth) {
246  cutDepth_ = cutDepth ;
247  }
248 
249  /*1 \brief Get action state for use of integer preprocessing */
250 
252  return (preProcess_) ;
253  }
254 
257  inline void setIPPAction(IPPControl action) {
258  preProcess_ = action ;
259  }
260 
263  CGControl getProbing(CglCutGenerator *&gen) ;
264 
267  inline void setProbingAction(CGControl action) {
268  probing_.action_ = action ;
269  }
270 
273  CGControl getClique(CglCutGenerator *&gen) ;
274 
277  inline void setCliqueAction(CGControl action) {
278  clique_.action_ = action ;
279  }
280 
283  CGControl getFlow(CglCutGenerator *&gen) ;
284 
287  inline void setFlowAction(CGControl action) {
288  flow_.action_ = action ;
289  }
290 
293  CGControl getGomory(CglCutGenerator *&gen) ;
294 
297  inline void setGomoryAction(CGControl action) {
298  gomory_.action_ = action ;
299  }
300 
303  CGControl getKnapsack(CglCutGenerator *&gen) ;
304 
307  inline void setKnapsackAction(CGControl action) {
308  knapsack_.action_ = action ;
309  }
310 
311  /* \brief Obtain a prototype for a lift-and-project cut generator.
312 
313  CGControl getLandP(CglCutGenerator *&gen) ;
314 
315  \brief Set action state for use of lift-and-project cut generator.
316 
317  inline void setLandPAction(CGControl action)
318  { landp_.action_ = action ; }
319  */
320 
325  CGControl getMir(CglCutGenerator *&gen) ;
326 
329  inline void setMirAction(CGControl action) {
330  mir_.action_ = action ;
331  }
332 
335  CGControl getRedSplit(CglCutGenerator *&gen) ;
336 
339  inline void setRedSplitAction(CGControl action) {
340  redSplit_.action_ = action ;
341  }
342 
345  CGControl getTwomir(CglCutGenerator *&gen) ;
346 
349  inline void setTwomirAction(CGControl action) {
350  twomir_.action_ = action ;
351  }
352 
353 
361  CGControl getFPump(CbcHeuristic *&gen, CbcModel *model,
362  bool alwaysCreate = true) ;
363 
366  inline void setFPumpAction(CGControl action) {
367  fpump_.action_ = action ;
368  }
369 
378  bool alwaysCreate = true) ;
379 
382  inline void setCombineAction(CGControl action) {
383  combine_.action_ = action ;
384  }
385 
394  bool alwaysCreate = true) ;
395 
398  inline void setGreedyCoverAction(CGControl action) {
399  greedyCover_.action_ = action ;
400  }
401 
410  bool alwaysCreate = true) ;
411 
414  inline void setGreedyEqualityAction(CGControl action) {
415  greedyEquality_.action_ = action ;
416  }
417 
426  bool alwaysCreate = true) ;
427 
430  inline void setRoundingAction(CGControl action) {
431  rounding_.action_ = action ;
432  }
433 
441  CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model,
442  bool alwaysCreate = true) ;
443 
446  inline void setTreeLocalAction(CGControl action) {
447  localTree_.action_ = action ;
448  }
449 
451 
456 
459  inline void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus,
460  BACWhere where, bool haveAnswer,
461  OsiSolverInterface *answerSolver) {
462  bab_.majorStatus_ = majorStatus ;
463  bab_.minorStatus_ = minorStatus ;
464  bab_.where_ = where ;
465  bab_.haveAnswer_ = haveAnswer ;
466  bab_.answerSolver_ = answerSolver ;
467  }
468 
474  void setBaBStatus(const CbcModel *model, BACWhere where,
475  bool haveAnswer = false,
476  OsiSolverInterface *answerSolver = 0) ;
477 
482  BACMajor translateMajor(int status) ;
483 
488  BACMinor translateMinor(int status) ;
489 
495  BACMinor translateMinor(const OsiSolverInterface *osi) ;
496 
499  void printBaBStatus() ;
500 
502 
505 
510  CoinMessageHandler &message(CbcGenMsgCode inID) ;
511 
517  void passInMessageHandler(CoinMessageHandler *handler) ;
518 
520  inline CoinMessageHandler *messageHandler() const {
521  return msgHandler_ ;
522  }
523 
536  void setMessages(CoinMessages::Language lang = CoinMessages::us_en) ;
537 
539  inline void setLogLevel(int lvl) {
540  logLvl_ = lvl ;
541  if (msgHandler_) msgHandler_->setLogLevel(lvl) ;
542  }
543 
545  inline int logLevel() const {
546  return (logLvl_) ;
547  }
548 
552  int printOpt_ ;
553 
555 
560  std::string version_ ;
561 
564  std::string dfltDirectory_ ;
565 
568  std::string lastMpsIn_ ;
569 
572 
575  std::string lastSolnOut_ ;
576 
584 
590  std::string printMask_ ;
591 
594  CoinParamVec *paramVec_ ;
595 
599  int first_ ;
600  int last_ ;
601  } genParams_ ;
602 
606  int first_ ;
607  int last_ ;
608  } cbcParams_ ;
609 
615  int first_ ;
616  int last_ ;
617  } osiParams_ ;
618 
628  int verbose_ ;
629 
633 
636  std::vector<bool> setByUser_ ;
637 
645 
654  std::string debugCreate_ ;
655 
662  std::string debugFile_ ;
663 
670  int numCols_ ;
671  double *values_ ;
672  } debugSol_ ;
674 
675  /* \name Timing */
677 
680  double totalTime_ ;
681 
683 
686 
698 
705  OsiSolverInterface *dfltSolver_ ;
706 
709  bool goodModel_ ;
710 
722  bool haveAnswer_ ;
723  OsiSolverInterface *answerSolver_ ;
724  } bab_ ;
725 
727 
730 
740  bool action_ ;
741  double threshold_ ;
742  } djFix_ ;
743 
748 
750 
757 
769  } chooseStrong_ ;
771 
772 private:
773 
778 
781  IPPControl preProcess_ ;
782 
789  int cutDepth_ ;
790 
792  struct probingCtl_struct {
793  CGControl action_ ;
794  CglProbing *proto_ ;
795  bool usingObjective_ ;
796  int maxPass_ ;
797  int maxPassRoot_ ;
798  int maxProbe_ ;
799  int maxProbeRoot_ ;
800  int maxLook_ ;
801  int maxLookRoot_ ;
802  int maxElements_ ;
803  int rowCuts_ ;
804  } probing_ ;
805 
807  struct cliqueCtl_struct {
808  CGControl action_ ;
809  CglClique *proto_ ;
810  bool starCliqueReport_ ;
811  bool rowCliqueReport_ ;
812  double minViolation_ ;
813  } clique_ ;
814 
816  struct flowCtl_struct {
817  CGControl action_ ;
818  CglFlowCover *proto_ ;
819  } flow_ ;
820 
822  struct gomoryCtl_struct {
823  CGControl action_ ;
824  CglGomory *proto_ ;
825  int limit_ ;
826  int limitAtRoot_ ;
827  } gomory_ ;
828 
829  /* \brief Control variable and prototype for lift-and-project cut
830  generator
831  struct landpCtl_struct
832  { CGControl action_ ;
833  CglLandP *proto_ ; } landp_ ;
834  */
835 
837  struct knapsackCtl_struct {
838  CGControl action_ ;
839  CglKnapsackCover *proto_ ;
840  } knapsack_ ;
841 
843  struct mirCtl_struct {
844  CGControl action_ ;
845  CglMixedIntegerRounding2 *proto_ ;
846  } mir_ ;
847 
849  struct oddHoleCtl_struct {
850  CGControl action_ ;
851  CglOddHole *proto_ ;
852  } oddHole_ ;
853 
857  struct redSplitCtl_struct {
858  CGControl action_ ;
859  CglRedSplit *proto_ ;
860  } redSplit_ ;
861 
863  struct twomirCtl_struct {
864  CGControl action_ ;
865  CglTwomir *proto_ ;
866  int maxElements_ ;
867  } twomir_ ;
868 
870  struct fpumpCtl_struct {
871  CGControl action_ ;
872  CbcHeuristicFPump *proto_ ;
873  int iters_ ;
874  } fpump_ ;
875 
877  struct combineCtl_struct {
878  CGControl action_ ;
879  CbcHeuristicLocal *proto_ ;
880  int trySwap_ ;
881  } combine_ ;
882 
884  struct greedyCoverCtl_struct {
885  CGControl action_ ;
886  CbcHeuristicGreedyCover *proto_ ;
887  } greedyCover_ ;
888 
890  struct greedyEqualityCtl_struct {
891  CGControl action_ ;
893  } greedyEquality_ ;
894 
896  struct roundingCtl_struct {
897  CGControl action_ ;
898  CbcRounding *proto_ ;
899  } rounding_ ;
900 
901 
908  struct localTreeCtl_struct {
909  CGControl action_ ;
910  CbcTreeLocal *proto_ ;
911  double *soln_ ;
912  int range_ ;
913  int typeCuts_ ;
914  int maxDiverge_ ;
915  int timeLimit_ ;
916  int nodeLimit_ ;
917  bool refine_ ;
918  } localTree_ ;
919 
921 
927 
929  CoinMessageHandler *msgHandler_ ;
930 
937  bool ourMsgHandler_ ;
938 
940  CoinMessages::Language cur_lang_ ;
941 
943  CoinMessages *msgs_ ;
944 
946  int logLvl_ ;
947 
949 
950 } ;
951 
952 
953 #endif
954 
int logLevel() const
Get log level.
void setProbingAction(CGControl action)
Set action state for use of probing cut generator.
LocalSearch class.
struct CbcGenCtlBlk::debugSolInfo_struct debugSol_
struct CbcGenCtlBlk::djFixCtl_struct djFix_
Start and end of CbcModel parameters in parameter vector.
BACMinor translateMinor(int status)
Translate CbcModel minor status to BACMinor.
void setGomoryAction(CGControl action)
Set action state for use of Gomory cut generator.
std::string lastSolnOut_
Last solution output file.
~CbcGenCtlBlk()
Destructor.
IPPControl getIPPAction()
int printMode_
Solution printing mode.
CGControl
Codes to control the use of cut generators and heuristics.
struct CbcGenCtlBlk::osiParamsInfo_struct osiParams_
std::string debugCreate_
Control debug file creation.
BACWhere
Codes to specify where branch-and-cut stopped.
void setCombineAction(CGControl action)
Set action state for use of local search/combine heuristic.
CoinMessageHandler & message(CbcGenMsgCode inID)
Print a message.
CGControl getTwomir(CglCutGenerator *&gen)
Obtain a prototype for a 2-MIR cut generator.
void setRedSplitAction(CGControl action)
Set action state for use of reduce and split cut generator.
void setFPumpAction(CGControl action)
Set action state for use of feasibility pump heuristic.
void setRoundingAction(CGControl action)
Set action state for use of simple rounding heuristic.
CGControl getFPump(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a feasibility pump heuristic.
void passInMessageHandler(CoinMessageHandler *handler)
Supply a new message handler.
State of branch-and-cut.
Array of primal variable values for debugging.
bool goodModel_
True if we have a valid model loaded, false otherwise.
void setGreedyCoverAction(CGControl action)
Set action state for use of greedy cover heuristic.
Control variables for a strong branching method.
void setCliqueAction(CGControl action)
Set action state for use of clique cut generator.
CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model, bool alwaysCreate=true)
Obtain a local search tree object.
Start and end of cbc-generic parameters in parameter vector.
struct CbcGenCtlBlk::cbcParamsInfo_struct cbcParams_
double totalTime_
Total elapsed time for this run.
struct CbcGenCtlBlk::genParamsInfo_struct genParams_
CbcModel * model_
The reference CbcModel object.
CGControl getMir(CglCutGenerator *&gen)
Obtain a prototype for a mixed integer rounding (MIR) cut generator.
struct CbcGenCtlBlk::babState_struct bab_
CGControl getCombine(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a local search/combine heuristic.
void setKnapsackAction(CGControl action)
Set action state for use of knapsack cut generator.
std::string dfltDirectory_
Default directory prefix.
BACMajor
Major status codes for branch-and-cut.
CGControl getProbing(CglCutGenerator *&gen)
Obtain a prototype for a probing cut generator.
void setFlowAction(CGControl action)
Set action state for use of flow cover cut generator.
void printBaBStatus()
Print the status block.
int printOpt_
When greater than 0, integer presolve gives more information and branch-and-cut provides statistics...
int verbose_
Verbosity level for help messages.
CbcGenMsgCode
Symbolic names for cbc-generic messages.
BPControl
Codes to specify the assignment of branching priorities.
void setLogLevel(int lvl)
Set log level.
Start and end of OsiSolverInterface parameters in parameter vector.
std::string printMask_
Print mask.
std::string version_
cbc-generic version
void setCutDepth(int cutDepth)
Set cut depth setting.
CGControl getFlow(CglCutGenerator *&gen)
Obtain a prototype for a flow cover cut generator.
Rounding class.
void setMirAction(CGControl action)
Set action state for use of MIR cut generator.
bool allowImportErrors_
Allow/disallow errors when importing a model.
CoinParamVec * paramVec_
The parameter vector.
CbcGenCtlBlk()
Default constructor.
This file contains the enum that defines symbolic names for for cbc-generic messages.
void setIPPAction(IPPControl action)
Set action state for use of integer preprocessing.
IPPControl
Codes to control integer preprocessing.
int getCutDepth()
Get cut depth setting.
Heuristic base class.
CGControl getRedSplit(CglCutGenerator *&gen)
Obtain a prototype for a reduce and split cut generator.
CGControl getRounding(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a simple rounding heuristic.
std::vector< bool > setByUser_
Record of parameters changed by user command.
void setMessages(CoinMessages::Language lang=CoinMessages::us_en)
Set up messages in the specified language.
BPControl priorityAction_
Control the assignment of branching priorities to integer variables.
CGControl getGreedyCover(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a greedy cover heuristic.
void addCbcGenParams(int &numParams, CoinParamVec &paramVec, CbcGenCtlBlk *ctlBlk)
void setTwomirAction(CGControl action)
Set action state for use of 2-MIR cut generator.
std::string lastMpsIn_
Last MPS input file.
CGControl getGreedyEquality(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a greedy equality heuristic.
void setTreeLocalAction(CGControl action)
Set action state for use of local tree.
struct CbcGenCtlBlk::chooseStrongCtl_struct chooseStrong_
BACMinor
Minor status codes.
CGControl getGomory(CglCutGenerator *&gen)
Obtain a prototype for a Gomory cut generator.
OsiSolverInterface * answerSolver_
bool defaultSettings_
False if the user has made nontrivial modifications to the default control settings.
Feasibility Pump class.
CGControl getClique(CglCutGenerator *&gen)
Obtain a prototype for a clique cut generator.
OsiSolverInterface * dfltSolver_
The current default LP solver.
void setGreedyEqualityAction(CGControl action)
Set action state for use of greedy equality heuristic.
Greedy heuristic classes.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
Control use of reduced cost fixing prior to B&C.
int paramsProcessed_
Number of parameters processed.
void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus, BACWhere where, bool haveAnswer, OsiSolverInterface *answerSolver)
Set the result of branch-and-cut search.
CoinMessageHandler * messageHandler() const
Return a pointer to the message handler.
std::string debugFile_
Last debug input file.
BACMajor translateMajor(int status)
Translate CbcModel major status to BACMajor.
CGControl getKnapsack(CglCutGenerator *&gen)
Obtain a prototype for a knapsack cover cut generator.