Cbc  2.10.3
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 2467 2019-01-03 21:26:29Z unxusr $
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 2467 2019-01-03 21:26:29Z unxusr $
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:
75 
76  /*
77  In order for initialisation to work properly, the order of declaration of
78  the enum constants here must match the order of keyword declaration for
79  the PREPROCESS parameter in CbcGenParamUtils::addCbcGenParams
80  */
98  typedef enum { IPPOff = 0,
105  IPPStrategy
106  } IPPControl;
107 
108  /*
109  In order for initialisation to work properly, the order of declaration of
110  the enum constants here must match the order of keyword declaration for
111  the various cut and heuristic control parameters in
112  CbcGenParamUtils::addCbcGenParams
113  */
134  typedef enum { CGOff,
140  CGMarker
141  } CGControl;
142 
151  typedef enum { BPOff,
154  BPExt } BPControl;
155 
171  typedef enum { BACInvalid = -1,
172  BACFinish = 0,
173  BACStop = 1,
174  BACAbandon = 2,
176  BACUser = 5
177  } BACMajor;
178 
198  typedef enum { BACmInvalid = -1,
199  BACmFinish = 0,
207  BACmOther
208  } BACMinor;
209 
219  typedef enum { BACwInvalid = -1,
220  BACwNotStarted = 0,
224  BACwBAC
225  } BACWhere;
226 
228 
231 
234  CbcGenCtlBlk();
235 
238  ~CbcGenCtlBlk();
240 
256 
264  inline int getCutDepth()
265  {
266  return cutDepth_;
267  }
268 
274  inline void setCutDepth(int cutDepth)
275  {
276  cutDepth_ = cutDepth;
277  }
278 
279  /*1 \brief Get action state for use of integer preprocessing */
280 
281  inline IPPControl getIPPAction()
282  {
283  return (preProcess_);
284  }
285 
288  inline void setIPPAction(IPPControl action)
289  {
290  preProcess_ = action;
291  }
292 
295  CGControl getProbing(CglCutGenerator *&gen);
296 
299  inline void setProbingAction(CGControl action)
300  {
301  probing_.action_ = action;
302  }
303 
306  CGControl getClique(CglCutGenerator *&gen);
307 
310  inline void setCliqueAction(CGControl action)
311  {
312  clique_.action_ = action;
313  }
314 
317  CGControl getFlow(CglCutGenerator *&gen);
318 
321  inline void setFlowAction(CGControl action)
322  {
323  flow_.action_ = action;
324  }
325 
328  CGControl getGomory(CglCutGenerator *&gen);
329 
332  inline void setGomoryAction(CGControl action)
333  {
334  gomory_.action_ = action;
335  }
336 
339  CGControl getKnapsack(CglCutGenerator *&gen);
340 
343  inline void setKnapsackAction(CGControl action)
344  {
345  knapsack_.action_ = action;
346  }
347 
348  /* \brief Obtain a prototype for a lift-and-project cut generator.
349 
350  CGControl getLandP(CglCutGenerator *&gen) ;
351 
352  \brief Set action state for use of lift-and-project cut generator.
353 
354  inline void setLandPAction(CGControl action)
355  { landp_.action_ = action ; }
356  */
357 
362  CGControl getMir(CglCutGenerator *&gen);
363 
366  inline void setMirAction(CGControl action)
367  {
368  mir_.action_ = action;
369  }
370 
373  CGControl getRedSplit(CglCutGenerator *&gen);
374 
377  inline void setRedSplitAction(CGControl action)
378  {
379  redSplit_.action_ = action;
380  }
381 
384  CGControl getTwomir(CglCutGenerator *&gen);
385 
388  inline void setTwomirAction(CGControl action)
389  {
390  twomir_.action_ = action;
391  }
392 
400  CGControl getFPump(CbcHeuristic *&gen, CbcModel *model,
401  bool alwaysCreate = true);
402 
405  inline void setFPumpAction(CGControl action)
406  {
407  fpump_.action_ = action;
408  }
409 
417  CGControl getCombine(CbcHeuristic *&gen, CbcModel *model,
418  bool alwaysCreate = true);
419 
422  inline void setCombineAction(CGControl action)
423  {
424  combine_.action_ = action;
425  }
426 
434  CGControl getGreedyCover(CbcHeuristic *&gen, CbcModel *model,
435  bool alwaysCreate = true);
436 
439  inline void setGreedyCoverAction(CGControl action)
440  {
441  greedyCover_.action_ = action;
442  }
443 
451  CGControl getGreedyEquality(CbcHeuristic *&gen, CbcModel *model,
452  bool alwaysCreate = true);
453 
456  inline void setGreedyEqualityAction(CGControl action)
457  {
458  greedyEquality_.action_ = action;
459  }
460 
468  CGControl getRounding(CbcHeuristic *&gen, CbcModel *model,
469  bool alwaysCreate = true);
470 
473  inline void setRoundingAction(CGControl action)
474  {
475  rounding_.action_ = action;
476  }
477 
485  CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model,
486  bool alwaysCreate = true);
487 
490  inline void setTreeLocalAction(CGControl action)
491  {
492  localTree_.action_ = action;
493  }
494 
496 
501 
504  inline void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus,
505  BACWhere where, bool haveAnswer,
506  OsiSolverInterface *answerSolver)
507  {
508  bab_.majorStatus_ = majorStatus;
509  bab_.minorStatus_ = minorStatus;
510  bab_.where_ = where;
511  bab_.haveAnswer_ = haveAnswer;
512  bab_.answerSolver_ = answerSolver;
513  }
514 
520  void setBaBStatus(const CbcModel *model, BACWhere where,
521  bool haveAnswer = false,
522  OsiSolverInterface *answerSolver = 0);
523 
528  BACMajor translateMajor(int status);
529 
534  BACMinor translateMinor(int status);
535 
541  BACMinor translateMinor(const OsiSolverInterface *osi);
542 
545  void printBaBStatus();
546 
548 
551 
556  CoinMessageHandler &message(CbcGenMsgCode inID);
557 
563  void passInMessageHandler(CoinMessageHandler *handler);
564 
566  inline CoinMessageHandler *messageHandler() const
567  {
568  return msgHandler_;
569  }
570 
583  void setMessages(CoinMessages::Language lang = CoinMessages::us_en);
584 
586  inline void setLogLevel(int lvl)
587  {
588  logLvl_ = lvl;
589  if (msgHandler_)
590  msgHandler_->setLogLevel(lvl);
591  }
592 
594  inline int logLevel() const
595  {
596  return (logLvl_);
597  }
598 
603 
605 
610  std::string version_;
611 
614  std::string dfltDirectory_;
615 
618  std::string lastMpsIn_;
619 
622 
625  std::string lastSolnOut_;
626 
634 
640  std::string printMask_;
641 
644  CoinParamVec *paramVec_;
645 
649  int first_;
650  int last_;
651  } genParams_;
652 
656  int first_;
657  int last_;
658  } cbcParams_;
659 
665  int first_;
666  int last_;
667  } osiParams_;
668 
678  int verbose_;
679 
683 
686  std::vector< bool > setByUser_;
687 
695 
704  std::string debugCreate_;
705 
712  std::string debugFile_;
713 
720  int numCols_;
721  double *values_;
722  } debugSol_;
724 
725  /* \name Timing */
727 
730  double totalTime_;
731 
733 
736 
748 
755  OsiSolverInterface *dfltSolver_;
756 
760 
770  BACMinor minorStatus_;
771  BACWhere where_;
773  OsiSolverInterface *answerSolver_;
774  } bab_;
775 
777 
780 
790  bool action_;
791  double threshold_;
792  } djFix_;
793 
797  BPControl priorityAction_;
798 
800 
807 
819  } chooseStrong_;
821 
822 private:
827 
830  IPPControl preProcess_;
831 
838  int cutDepth_;
839 
841  struct probingCtl_struct {
842  CGControl action_;
843  CglProbing *proto_;
844  bool usingObjective_;
845  int maxPass_;
846  int maxPassRoot_;
847  int maxProbe_;
848  int maxProbeRoot_;
849  int maxLook_;
850  int maxLookRoot_;
851  int maxElements_;
852  int rowCuts_;
853  } probing_;
854 
856  struct cliqueCtl_struct {
857  CGControl action_;
858  CglClique *proto_;
859  bool starCliqueReport_;
860  bool rowCliqueReport_;
861  double minViolation_;
862  } clique_;
863 
865  struct flowCtl_struct {
866  CGControl action_;
867  CglFlowCover *proto_;
868  } flow_;
869 
871  struct gomoryCtl_struct {
872  CGControl action_;
873  CglGomory *proto_;
874  int limit_;
875  int limitAtRoot_;
876  } gomory_;
877 
878  /* \brief Control variable and prototype for lift-and-project cut
879  generator
880  struct landpCtl_struct
881  { CGControl action_ ;
882  CglLandP *proto_ ; } landp_ ;
883  */
884 
886  struct knapsackCtl_struct {
887  CGControl action_;
888  CglKnapsackCover *proto_;
889  } knapsack_;
890 
892  struct mirCtl_struct {
893  CGControl action_;
894  CglMixedIntegerRounding2 *proto_;
895  } mir_;
896 
898  struct oddHoleCtl_struct {
899  CGControl action_;
900  CglOddHole *proto_;
901  } oddHole_;
902 
906  struct redSplitCtl_struct {
907  CGControl action_;
908  CglRedSplit *proto_;
909  } redSplit_;
910 
912  struct twomirCtl_struct {
913  CGControl action_;
914  CglTwomir *proto_;
915  int maxElements_;
916  } twomir_;
917 
919  struct fpumpCtl_struct {
920  CGControl action_;
921  CbcHeuristicFPump *proto_;
922  int iters_;
923  } fpump_;
924 
926  struct combineCtl_struct {
927  CGControl action_;
928  CbcHeuristicLocal *proto_;
929  int trySwap_;
930  } combine_;
931 
933  struct greedyCoverCtl_struct {
934  CGControl action_;
935  CbcHeuristicGreedyCover *proto_;
936  } greedyCover_;
937 
939  struct greedyEqualityCtl_struct {
940  CGControl action_;
942  } greedyEquality_;
943 
945  struct roundingCtl_struct {
946  CGControl action_;
947  CbcRounding *proto_;
948  } rounding_;
949 
956  struct localTreeCtl_struct {
957  CGControl action_;
958  CbcTreeLocal *proto_;
959  double *soln_;
960  int range_;
961  int typeCuts_;
962  int maxDiverge_;
963  int timeLimit_;
964  int nodeLimit_;
965  bool refine_;
966  } localTree_;
967 
969 
975 
977  CoinMessageHandler *msgHandler_;
978 
985  bool ourMsgHandler_;
986 
988  CoinMessages::Language cur_lang_;
989 
991  CoinMessages *msgs_;
992 
994  int logLvl_;
995 
997 };
998 
999 #endif
1000 
1001 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
1002 */
void setProbingAction(CGControl action)
Set action state for use of probing cut generator.
LocalSearch class.
Start and end of CbcModel parameters in parameter vector.
void setGomoryAction(CGControl action)
Set action state for use of Gomory cut generator.
std::string lastSolnOut_
Last solution output file.
IPPControl getIPPAction()
int printMode_
Solution printing mode.
CGControl
Codes to control the use of cut generators and heuristics.
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.
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.
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.
Start and end of cbc-generic parameters in parameter vector.
double totalTime_
Total elapsed time for this run.
CoinMessageHandler * messageHandler() const
Return a pointer to the message handler.
CbcModel * model_
The reference CbcModel object.
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.
void setFlowAction(CGControl action)
Set action state for use of flow cover cut generator.
std::vector< bool > setByUser_
Record of parameters changed by user command.
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.
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.
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.
BPControl priorityAction_
Control the assignment of branching priorities to integer variables.
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.
void setTreeLocalAction(CGControl action)
Set action state for use of local tree.
BACMinor
Minor status codes.
OsiSolverInterface * answerSolver_
bool defaultSettings_
False if the user has made nontrivial modifications to the default control settings.
Feasibility Pump class.
int logLevel() const
Get log level.
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.
std::string debugFile_
Last debug input file.