Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 1899 2013-04-09 18:12:08Z 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"
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 1899 2013-04-09 18:12:08Z 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 
264 
267  inline void setProbingAction(CGControl action) {
268  probing_.action_ = action ;
269  }
270 
274 
277  inline void setCliqueAction(CGControl action) {
278  clique_.action_ = action ;
279  }
280 
284 
287  inline void setFlowAction(CGControl action) {
288  flow_.action_ = action ;
289  }
290 
294 
297  inline void setGomoryAction(CGControl action) {
298  gomory_.action_ = action ;
299  }
300 
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 
326 
329  inline void setMirAction(CGControl action) {
330  mir_.action_ = action ;
331  }
332 
336 
339  inline void setRedSplitAction(CGControl action) {
340  redSplit_.action_ = action ;
341  }
342 
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 
496 
499  void printBaBStatus() ;
500 
502 
505 
511 
518 
521  return msgHandler_ ;
522  }
523 
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 
706 
709  bool goodModel_ ;
710 
722  bool haveAnswer_ ;
724  } bab_ ;
725 
727 
730 
740  bool action_ ;
741  double threshold_ ;
742  } djFix_ ;
743 
748 
750 
757 
769  } chooseStrong_ ;
771 
772 private:
773 
778 
782 
789  int cutDepth_ ;
790 
796  int maxPass_ ;
798  int maxProbe_ ;
800  int maxLook_ ;
803  int rowCuts_ ;
804  } probing_ ;
805 
812  double minViolation_ ;
813  } clique_ ;
814 
816  struct flowCtl_struct {
819  } flow_ ;
820 
825  int limit_ ;
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 
840  } knapsack_ ;
841 
843  struct mirCtl_struct {
846  } mir_ ;
847 
852  } oddHole_ ;
853 
860  } redSplit_ ;
861 
867  } twomir_ ;
868 
873  int iters_ ;
874  } fpump_ ;
875 
880  int trySwap_ ;
881  } combine_ ;
882 
887  } greedyCover_ ;
888 
893  } greedyEquality_ ;
894 
899  } rounding_ ;
900 
901 
911  double *soln_ ;
912  int range_ ;
913  int typeCuts_ ;
917  bool refine_ ;
918  } localTree_ ;
919 
921 
927 
930 
938 
941 
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::oddHoleCtl_struct oddHole_
struct CbcGenCtlBlk::debugSolInfo_struct debugSol_
struct CbcGenCtlBlk::djFixCtl_struct djFix_
Start and end of CbcModel parameters in parameter vector.
struct CbcGenCtlBlk::gomoryCtl_struct gomory_
struct CbcGenCtlBlk::localTreeCtl_struct localTree_
BACMinor translateMinor(int status)
Translate CbcModel minor status to BACMinor.
void setGomoryAction(CGControl action)
Set action state for use of Gomory cut generator.
Control variable and prototype for Two-MIR cut generator.
struct CbcGenCtlBlk::greedyEqualityCtl_struct greedyEquality_
Declaration of a class for command line parameters.
bool ourMsgHandler_
Ownership of message handler.
Control variable and prototype for MIR cut generator.
std::string lastSolnOut_
Last solution output file.
IPPControl preProcess_
Control integer preprocessing.
struct CbcGenCtlBlk::flowCtl_struct flow_
Control variable and prototype for odd hole cut generator.
struct CbcGenCtlBlk::probingCtl_struct probing_
~CbcGenCtlBlk()
Destructor.
IPPControl getIPPAction()
int printMode_
Solution printing mode.
struct CbcGenCtlBlk::knapsackCtl_struct knapsack_
CGControl
Codes to control the use of cut generators and heuristics.
Control variable and prototype for probing cut generator.
CoinMessages * msgs_
The current set of messages.
struct CbcGenCtlBlk::osiParamsInfo_struct osiParams_
std::string debugCreate_
Control debug file creation.
BACWhere
Codes to specify where branch-and-cut stopped.
struct CbcGenCtlBlk::roundingCtl_struct rounding_
void setCombineAction(CGControl action)
Set action state for use of local search/combine heuristic.
Control variable and prototype for 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.
Control variable and prototype for clique cut generator.
void passInMessageHandler(CoinMessageHandler *handler)
Supply a new message handler.
Base class for message handling.
struct CbcGenCtlBlk::redSplitCtl_struct redSplit_
struct CbcGenCtlBlk::twomirCtl_struct twomir_
State of branch-and-cut.
Array of primal variable values for debugging.
bool goodModel_
True if we have a valid model loaded, false otherwise.
Control variable and prototype for flow cover cut generator.
void setGreedyCoverAction(CGControl action)
Set action state for use of greedy cover heuristic.
Control variables for a strong branching method.
Gomory Reduce-and-Split Cut Generator Class; See method generateCuts().
Definition: CglRedSplit.hpp:26
Abstract Base Class for describing an interface to a solver.
CbcHeuristicFPump * proto_
void setCliqueAction(CGControl action)
Set action state for use of clique cut generator.
Gomory Cut Generator Class.
Definition: CglGomory.hpp:14
struct CbcGenCtlBlk::fpumpCtl_struct fpump_
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::greedyCoverCtl_struct greedyCover_
struct CbcGenCtlBlk::cbcParamsInfo_struct cbcParams_
double totalTime_
Total elapsed time for this run.
struct CbcGenCtlBlk::genParamsInfo_struct genParams_
CbcModel * model_
The reference CbcModel object.
This is a first attempt at a message handler.
struct CbcGenCtlBlk::combineCtl_struct combine_
Cut Generator Base Class.
CGControl getMir(CglCutGenerator *&gen)
Obtain a prototype for a mixed integer rounding (MIR) cut generator.
struct CbcGenCtlBlk::babState_struct bab_
Control variable and prototype for feasibility pump heuristic.
CGControl getCombine(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a local search/combine heuristic.
Lifed Simple Generalized Flow Cover Cut Generator Class.
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.
struct CbcGenCtlBlk::mirCtl_struct mir_
void setFlowAction(CGControl action)
Set action state for use of flow cover cut generator.
struct CbcGenCtlBlk::cliqueCtl_struct clique_
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.
CglMixedIntegerRounding2 * proto_
CbcGenMsgCode
Symbolic names for cbc-generic messages.
BPControl
Codes to specify the assignment of branching priorities.
void setLogLevel(int lvl)
Set log level.
CoinMessageHandler * msgHandler_
Message handler.
Control variable and prototype for greedy equality heuristic.
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.
int logLvl_
The current log level.
bool allowImportErrors_
Allow/disallow errors when importing a model.
CoinParamVec * paramVec_
The parameter vector.
CbcGenCtlBlk()
Default constructor.
CbcHeuristicGreedyEquality * proto_
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.
Control variable and prototype for simple rounding heuristic.
IPPControl
Codes to control integer preprocessing.
int getCutDepth()
Get cut depth setting.
CbcHeuristicGreedyCover * proto_
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.
Language
Supported languages.
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.
Control variable and prototype for knapsack cover cut generator.
Twostep MIR Cut Generator Class.
Definition: CglTwomir.hpp:91
CGControl getGreedyCover(CbcHeuristic *&gen, CbcModel *model, bool alwaysCreate=true)
Obtain a greedy cover heuristic.
void addCbcGenParams(int &numParams, CoinParamVec &paramVec, CbcGenCtlBlk *ctlBlk)
Control variables for local tree.
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.
Control variable and prototype for reduce-and-split cut generator.
struct CbcGenCtlBlk::chooseStrongCtl_struct chooseStrong_
BACMinor
Minor status codes.
Odd Hole Cut Generator Class.
Definition: CglOddHole.hpp:14
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.
int cutDepth_
Control cut generator activity.
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.
Control variable and prototype for greedy cover heuristic.
Greedy heuristic classes.
Knapsack Cover Cut Generator Class.
Simple Branch and bound class.
Definition: CbcModel.hpp:101
Control use of reduced cost fixing prior to B&amp;C.
CoinMessages::Language cur_lang_
The current language.
Control variable and prototype for Gomory cut generator.
int paramsProcessed_
Number of parameters processed.
Probing Cut Generator Class.
Definition: CglProbing.hpp:25
Class to hold and manipulate an array of massaged messages.
void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus, BACWhere where, bool haveAnswer, OsiSolverInterface *answerSolver)
Set the result of branch-and-cut search.
void setLogLevel(int value)
Set current log (detail) level.
CoinMessageHandler * messageHandler() const
Return a pointer to the message handler.
Mixed Integer Rounding Cut Generator Class.
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.