00001
00002
00003
00004
00005
00006
00007
00008 #ifndef CbcGenCtlBlk_H
00009 #define CbcGenCtlBlk_H
00010
00011
00012
00013
00014
00015 #include "CoinParam.hpp"
00016 #include "CoinMessageHandler.hpp"
00017
00018 #include "CglCutGenerator.hpp"
00019 #include "CglProbing.hpp"
00020 #include "CglClique.hpp"
00021 #include "CglFlowCover.hpp"
00022 #include "CglGomory.hpp"
00023 #include "CglKnapsackCover.hpp"
00024 #include "CglMixedIntegerRounding2.hpp"
00025 #include "CglOddHole.hpp"
00026 #include "CglRedSplit.hpp"
00027 #include "CglTwomir.hpp"
00028
00029 #include "CbcModel.hpp"
00030
00031 #include "CbcHeuristic.hpp"
00032 #include "CbcHeuristicFPump.hpp"
00033 #include "CbcHeuristicGreedy.hpp"
00034 #include "CbcHeuristicLocal.hpp"
00035 #include "CbcTreeLocal.hpp"
00036
00037 #include "CbcGenMessages.hpp"
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #define CBC_GENERIC_VERSION "00.01.00"
00049
00050 class CbcGenCtlBlk ;
00051 namespace CbcGenParamUtils {
00052 void addCbcGenParams(int &numParams, CoinParamVec ¶mVec,
00053 CbcGenCtlBlk *ctlBlk) ;
00054 }
00055
00056
00057
00058
00059
00060
00061
00062 class CbcGenCtlBlk {
00063
00064 friend void CbcGenParamUtils::addCbcGenParams(int &numParams,
00065 CoinParamVec ¶mVec, CbcGenCtlBlk *ctlBlk) ;
00066
00067 public:
00068
00071
00072
00073
00074
00075
00076
00094 typedef enum { IPPOff = 0, IPPOn, IPPSave, IPPEqual,
00095 IPPSOS, IPPTrySOS, IPPEqualAll, IPPStrategy
00096 } IPPControl ;
00097
00098
00099
00100
00101
00102
00103
00124 typedef enum { CGOff, CGOn, CGRoot, CGIfMove,
00125 CGForceOn, CGForceBut, CGMarker
00126 } CGControl ;
00127
00136 typedef enum { BPOff, BPCost, BPOrder, BPExt } BPControl ;
00137
00153 typedef enum { BACInvalid = -1, BACFinish = 0,
00154 BACStop = 1, BACAbandon = 2, BACNotRun, BACUser = 5
00155 } BACMajor ;
00156
00176 typedef enum { BACmInvalid = -1, BACmFinish = 0, BACmInfeas, BACmUbnd,
00177 BACmGap, BACmNodeLimit, BACmTimeLimit, BACmSolnLimit,
00178 BACmUser, BACmOther
00179 } BACMinor ;
00180
00190 typedef enum { BACwInvalid = -1, BACwNotStarted = 0, BACwBareRoot,
00191 BACwIPP, BACwIPPRelax, BACwBAC
00192 } BACWhere ;
00193
00195
00198
00201 CbcGenCtlBlk() ;
00202
00205 ~CbcGenCtlBlk() ;
00207
00223
00231 inline int getCutDepth() {
00232 return cutDepth_ ;
00233 }
00234
00240 inline void setCutDepth(int cutDepth) {
00241 cutDepth_ = cutDepth ;
00242 }
00243
00244
00245
00246 inline IPPControl getIPPAction() {
00247 return (preProcess_) ;
00248 }
00249
00252 inline void setIPPAction(IPPControl action) {
00253 preProcess_ = action ;
00254 }
00255
00258 CGControl getProbing(CglCutGenerator *&gen) ;
00259
00262 inline void setProbingAction(CGControl action) {
00263 probing_.action_ = action ;
00264 }
00265
00268 CGControl getClique(CglCutGenerator *&gen) ;
00269
00272 inline void setCliqueAction(CGControl action) {
00273 clique_.action_ = action ;
00274 }
00275
00278 CGControl getFlow(CglCutGenerator *&gen) ;
00279
00282 inline void setFlowAction(CGControl action) {
00283 flow_.action_ = action ;
00284 }
00285
00288 CGControl getGomory(CglCutGenerator *&gen) ;
00289
00292 inline void setGomoryAction(CGControl action) {
00293 gomory_.action_ = action ;
00294 }
00295
00298 CGControl getKnapsack(CglCutGenerator *&gen) ;
00299
00302 inline void setKnapsackAction(CGControl action) {
00303 knapsack_.action_ = action ;
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00320 CGControl getMir(CglCutGenerator *&gen) ;
00321
00324 inline void setMirAction(CGControl action) {
00325 mir_.action_ = action ;
00326 }
00327
00330 CGControl getRedSplit(CglCutGenerator *&gen) ;
00331
00334 inline void setRedSplitAction(CGControl action) {
00335 redSplit_.action_ = action ;
00336 }
00337
00340 CGControl getTwomir(CglCutGenerator *&gen) ;
00341
00344 inline void setTwomirAction(CGControl action) {
00345 twomir_.action_ = action ;
00346 }
00347
00348
00356 CGControl getFPump(CbcHeuristic *&gen, CbcModel *model,
00357 bool alwaysCreate = true) ;
00358
00361 inline void setFPumpAction(CGControl action) {
00362 fpump_.action_ = action ;
00363 }
00364
00372 CGControl getCombine(CbcHeuristic *&gen, CbcModel *model,
00373 bool alwaysCreate = true) ;
00374
00377 inline void setCombineAction(CGControl action) {
00378 combine_.action_ = action ;
00379 }
00380
00388 CGControl getGreedyCover(CbcHeuristic *&gen, CbcModel *model,
00389 bool alwaysCreate = true) ;
00390
00393 inline void setGreedyCoverAction(CGControl action) {
00394 greedyCover_.action_ = action ;
00395 }
00396
00404 CGControl getGreedyEquality(CbcHeuristic *&gen, CbcModel *model,
00405 bool alwaysCreate = true) ;
00406
00409 inline void setGreedyEqualityAction(CGControl action) {
00410 greedyEquality_.action_ = action ;
00411 }
00412
00420 CGControl getRounding(CbcHeuristic *&gen, CbcModel *model,
00421 bool alwaysCreate = true) ;
00422
00425 inline void setRoundingAction(CGControl action) {
00426 rounding_.action_ = action ;
00427 }
00428
00436 CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model,
00437 bool alwaysCreate = true) ;
00438
00441 inline void setTreeLocalAction(CGControl action) {
00442 localTree_.action_ = action ;
00443 }
00444
00446
00451
00454 inline void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus,
00455 BACWhere where, bool haveAnswer,
00456 OsiSolverInterface *answerSolver) {
00457 bab_.majorStatus_ = majorStatus ;
00458 bab_.minorStatus_ = minorStatus ;
00459 bab_.where_ = where ;
00460 bab_.haveAnswer_ = haveAnswer ;
00461 bab_.answerSolver_ = answerSolver ;
00462 }
00463
00469 void setBaBStatus(const CbcModel *model, BACWhere where,
00470 bool haveAnswer = false,
00471 OsiSolverInterface *answerSolver = 0) ;
00472
00477 BACMajor translateMajor(int status) ;
00478
00483 BACMinor translateMinor(int status) ;
00484
00490 BACMinor translateMinor(const OsiSolverInterface *osi) ;
00491
00494 void printBaBStatus() ;
00495
00497
00500
00505 CoinMessageHandler &message(CbcGenMsgCode inID) ;
00506
00512 void passInMessageHandler(CoinMessageHandler *handler) ;
00513
00515 inline CoinMessageHandler *messageHandler() const {
00516 return msgHandler_ ;
00517 }
00518
00531 void setMessages(CoinMessages::Language lang = CoinMessages::us_en) ;
00532
00534 inline void setLogLevel(int lvl) {
00535 logLvl_ = lvl ;
00536 if (msgHandler_) msgHandler_->setLogLevel(lvl) ;
00537 }
00538
00540 inline int logLevel() const {
00541 return (logLvl_) ;
00542 }
00543
00547 int printOpt_ ;
00548
00550
00555 std::string version_ ;
00556
00559 std::string dfltDirectory_ ;
00560
00563 std::string lastMpsIn_ ;
00564
00566 bool allowImportErrors_ ;
00567
00570 std::string lastSolnOut_ ;
00571
00578 int printMode_ ;
00579
00585 std::string printMask_ ;
00586
00589 CoinParamVec *paramVec_ ;
00590
00593 struct genParamsInfo_struct {
00594 int first_ ;
00595 int last_ ;
00596 } genParams_ ;
00597
00600 struct cbcParamsInfo_struct {
00601 int first_ ;
00602 int last_ ;
00603 } cbcParams_ ;
00604
00609 struct osiParamsInfo_struct {
00610 int first_ ;
00611 int last_ ;
00612 } osiParams_ ;
00613
00623 int verbose_ ;
00624
00627 int paramsProcessed_ ;
00628
00631 std::vector<bool> setByUser_ ;
00632
00639 bool defaultSettings_ ;
00640
00649 std::string debugCreate_ ;
00650
00657 std::string debugFile_ ;
00658
00664 struct debugSolInfo_struct {
00665 int numCols_ ;
00666 double *values_ ;
00667 } debugSol_ ;
00669
00670
00672
00675 double totalTime_ ;
00676
00678
00681
00692 CbcModel *model_ ;
00693
00700 OsiSolverInterface *dfltSolver_ ;
00701
00704 bool goodModel_ ;
00705
00713 struct babState_struct {
00714 BACMajor majorStatus_ ;
00715 BACMinor minorStatus_ ;
00716 BACWhere where_ ;
00717 bool haveAnswer_ ;
00718 OsiSolverInterface *answerSolver_ ;
00719 } bab_ ;
00720
00722
00725
00734 struct djFixCtl_struct {
00735 bool action_ ;
00736 double threshold_ ;
00737 } djFix_ ;
00738
00742 BPControl priorityAction_ ;
00743
00745
00752
00760 struct chooseStrongCtl_struct {
00761 int numBeforeTrust_ ;
00762 int numStrong_ ;
00763 int shadowPriceMode_ ;
00764 } chooseStrong_ ;
00766
00767 private:
00768
00773
00776 IPPControl preProcess_ ;
00777
00784 int cutDepth_ ;
00785
00787 struct probingCtl_struct {
00788 CGControl action_ ;
00789 CglProbing *proto_ ;
00790 bool usingObjective_ ;
00791 int maxPass_ ;
00792 int maxPassRoot_ ;
00793 int maxProbe_ ;
00794 int maxProbeRoot_ ;
00795 int maxLook_ ;
00796 int maxLookRoot_ ;
00797 int maxElements_ ;
00798 int rowCuts_ ;
00799 } probing_ ;
00800
00802 struct cliqueCtl_struct {
00803 CGControl action_ ;
00804 CglClique *proto_ ;
00805 bool starCliqueReport_ ;
00806 bool rowCliqueReport_ ;
00807 double minViolation_ ;
00808 } clique_ ;
00809
00811 struct flowCtl_struct {
00812 CGControl action_ ;
00813 CglFlowCover *proto_ ;
00814 } flow_ ;
00815
00817 struct gomoryCtl_struct {
00818 CGControl action_ ;
00819 CglGomory *proto_ ;
00820 int limit_ ;
00821 int limitAtRoot_ ;
00822 } gomory_ ;
00823
00824
00825
00826
00827
00828
00829
00830
00832 struct knapsackCtl_struct {
00833 CGControl action_ ;
00834 CglKnapsackCover *proto_ ;
00835 } knapsack_ ;
00836
00838 struct mirCtl_struct {
00839 CGControl action_ ;
00840 CglMixedIntegerRounding2 *proto_ ;
00841 } mir_ ;
00842
00844 struct oddHoleCtl_struct {
00845 CGControl action_ ;
00846 CglOddHole *proto_ ;
00847 } oddHole_ ;
00848
00852 struct redSplitCtl_struct {
00853 CGControl action_ ;
00854 CglRedSplit *proto_ ;
00855 } redSplit_ ;
00856
00858 struct twomirCtl_struct {
00859 CGControl action_ ;
00860 CglTwomir *proto_ ;
00861 int maxElements_ ;
00862 } twomir_ ;
00863
00865 struct fpumpCtl_struct {
00866 CGControl action_ ;
00867 CbcHeuristicFPump *proto_ ;
00868 int iters_ ;
00869 } fpump_ ;
00870
00872 struct combineCtl_struct {
00873 CGControl action_ ;
00874 CbcHeuristicLocal *proto_ ;
00875 int trySwap_ ;
00876 } combine_ ;
00877
00879 struct greedyCoverCtl_struct {
00880 CGControl action_ ;
00881 CbcHeuristicGreedyCover *proto_ ;
00882 } greedyCover_ ;
00883
00885 struct greedyEqualityCtl_struct {
00886 CGControl action_ ;
00887 CbcHeuristicGreedyEquality *proto_ ;
00888 } greedyEquality_ ;
00889
00891 struct roundingCtl_struct {
00892 CGControl action_ ;
00893 CbcRounding *proto_ ;
00894 } rounding_ ;
00895
00896
00903 struct localTreeCtl_struct {
00904 CGControl action_ ;
00905 CbcTreeLocal *proto_ ;
00906 double *soln_ ;
00907 int range_ ;
00908 int typeCuts_ ;
00909 int maxDiverge_ ;
00910 int timeLimit_ ;
00911 int nodeLimit_ ;
00912 bool refine_ ;
00913 } localTree_ ;
00914
00916
00922
00924 CoinMessageHandler *msgHandler_ ;
00925
00932 bool ourMsgHandler_ ;
00933
00935 CoinMessages::Language cur_lang_ ;
00936
00938 CoinMessages *msgs_ ;
00939
00941 int logLvl_ ;
00942
00944
00945 } ;
00946
00947
00948 #endif
00949