# CbcGenCtlBlk.hpp

Go to the documentation of this file.

    00001 /*
    00002   Copyright (C) 2007, Lou Hafer, International Business Machines Corporation
    00003   and others.  All Rights Reserved.
    00004
    00005   This code is licensed under the terms of the Eclipse Public License (EPL).
    00006
    00007   $Id$
    00008 */
    00009 /*
    00010   This file is part of cbc-generic.
    00011 */
    00012
    00013 #ifndef CbcGenCtlBlk_H
    00014 #define CbcGenCtlBlk_H
    00015
    00016 /* \file CbcGenCtlBlk.hpp
    00017    \brief Declarations for parameters of the cbc-generic main program.
    00018 */
    00019
    00020 #include "CoinParam.hpp"
    00021 #include "CoinMessageHandler.hpp"
    00022
    00023 #include "CglCutGenerator.hpp"
    00024 #include "CglProbing.hpp"
    00025 #include "CglClique.hpp"
    00026 #include "CglFlowCover.hpp"
    00027 #include "CglGomory.hpp"
    00028 #include "CglKnapsackCover.hpp"
    00029 #include "CglMixedIntegerRounding2.hpp"
    00030 #include "CglOddHole.hpp"
    00031 #include "CglRedSplit.hpp"
    00032 #include "CglTwomir.hpp"
    00033
    00034 #include "CbcModel.hpp"
    00035
    00036 #include "CbcHeuristic.hpp"
    00037 #include "CbcHeuristicFPump.hpp"
    00038 #include "CbcHeuristicGreedy.hpp"
    00039 #include "CbcHeuristicLocal.hpp"
    00040 #include "CbcTreeLocal.hpp"
    00041
    00042 #include "CbcGenMessages.hpp"
    00043
    00044 /*
    00045   It turns out that doxygen is not good with anonymous structures. Hence the
    00046   `struct nameCtl_struct' style used for structured fields in CbcGenCtlBlk.
    00047 */
    00048
    00049 /*
    00050   $Id: CbcGenCtlBlk.hpp 1173 2009-06-04 09:44:10Z forrest $
    00051 */
    00052
    00053 #define CBC_GENERIC_VERSION "00.01.00"
    00054
    00055 class CbcGenCtlBlk ;
    00056 namespace CbcGenParamUtils {
    00057 void addCbcGenParams(int &numParams, CoinParamVec &paramVec,
    00058                      CbcGenCtlBlk *ctlBlk) ;
    00059 }
    00060
    00061 /* \brief cbc-generic algorithm control class
    00062
    00063   This class defines values and methods used to control the operation of the
    00064   cbc-generic main program.
    00065 */
    00066
    00067 class CbcGenCtlBlk {
    00068
    00069     friend void CbcGenParamUtils::addCbcGenParams(int &numParams,
    00070             CoinParamVec &paramVec, CbcGenCtlBlk *ctlBlk) ;
    00071
    00072 public:
    00073
    00076
    00077     /*
    00078       In order for initialisation to work properly, the order of declaration of
    00079       the enum constants here must match the order of keyword declaration for
    00080       the PREPROCESS parameter in CbcGenParamUtils::addCbcGenParams
    00081     */
    00099     typedef enum { IPPOff = 0, IPPOn, IPPSave, IPPEqual,
    00100                    IPPSOS, IPPTrySOS, IPPEqualAll, IPPStrategy
    00101                  } IPPControl ;
    00102
    00103     /*
    00104       In order for initialisation to work properly, the order of declaration of
    00105       the enum constants here must match the order of keyword declaration for
    00106       the various cut and heuristic control parameters in
    00107       CbcGenParamUtils::addCbcGenParams
    00108     */
    00129     typedef enum { CGOff, CGOn, CGRoot, CGIfMove,
    00130                    CGForceOn, CGForceBut, CGMarker
    00131                  } CGControl ;
    00132
    00141     typedef enum { BPOff, BPCost, BPOrder, BPExt } BPControl ;
    00142
    00158     typedef enum { BACInvalid = -1, BACFinish = 0,
    00159                    BACStop = 1, BACAbandon = 2, BACNotRun, BACUser = 5
    00160                  } BACMajor ;
    00161
    00181     typedef enum { BACmInvalid = -1, BACmFinish = 0, BACmInfeas, BACmUbnd,
    00182                    BACmGap, BACmNodeLimit, BACmTimeLimit, BACmSolnLimit,
    00183                    BACmUser, BACmOther
    00184                  } BACMinor ;
    00185
    00195     typedef enum { BACwInvalid = -1, BACwNotStarted = 0, BACwBareRoot,
    00196                    BACwIPP, BACwIPPRelax, BACwBAC
    00197                  } BACWhere ;
    00198
    00200
    00203
    00206     CbcGenCtlBlk() ;
    00207
    00210     ~CbcGenCtlBlk() ;
    00212
    00228
    00236     inline int getCutDepth() {
    00237         return cutDepth_ ;
    00238     }
    00239
    00245     inline void setCutDepth(int cutDepth) {
    00246         cutDepth_ = cutDepth ;
    00247     }
    00248
    00249     /*1 \brief Get action state for use of integer preprocessing */
    00250
    00251     inline IPPControl getIPPAction() {
    00252         return (preProcess_) ;
    00253     }
    00254
    00257     inline void setIPPAction(IPPControl action) {
    00258         preProcess_ = action ;
    00259     }
    00260
    00263     CGControl getProbing(CglCutGenerator *&gen) ;
    00264
    00267     inline void setProbingAction(CGControl action) {
    00268         probing_.action_ = action ;
    00269     }
    00270
    00273     CGControl getClique(CglCutGenerator *&gen) ;
    00274
    00277     inline void setCliqueAction(CGControl action) {
    00278         clique_.action_ = action ;
    00279     }
    00280
    00283     CGControl getFlow(CglCutGenerator *&gen) ;
    00284
    00287     inline void setFlowAction(CGControl action) {
    00288         flow_.action_ = action ;
    00289     }
    00290
    00293     CGControl getGomory(CglCutGenerator *&gen) ;
    00294
    00297     inline void setGomoryAction(CGControl action) {
    00298         gomory_.action_ = action ;
    00299     }
    00300
    00303     CGControl getKnapsack(CglCutGenerator *&gen) ;
    00304
    00307     inline void setKnapsackAction(CGControl action) {
    00308         knapsack_.action_ = action ;
    00309     }
    00310
    00311     /*  \brief Obtain a prototype for a lift-and-project cut generator.
    00312
    00313       CGControl getLandP(CglCutGenerator *&gen) ;
    00314
    00315        \brief Set action state for use of lift-and-project cut generator.
    00316
    00317       inline void setLandPAction(CGControl action)
    00318       { landp_.action_ = action ; }
    00319     */
    00320
    00325     CGControl getMir(CglCutGenerator *&gen) ;
    00326
    00329     inline void setMirAction(CGControl action) {
    00330         mir_.action_ = action ;
    00331     }
    00332
    00335     CGControl getRedSplit(CglCutGenerator *&gen) ;
    00336
    00339     inline void setRedSplitAction(CGControl action) {
    00340         redSplit_.action_ = action ;
    00341     }
    00342
    00345     CGControl getTwomir(CglCutGenerator *&gen) ;
    00346
    00349     inline void setTwomirAction(CGControl action) {
    00350         twomir_.action_ = action ;
    00351     }
    00352
    00353
    00361     CGControl getFPump(CbcHeuristic *&gen, CbcModel *model,
    00362                        bool alwaysCreate = true) ;
    00363
    00366     inline void setFPumpAction(CGControl action) {
    00367         fpump_.action_ = action ;
    00368     }
    00369
    00377     CGControl getCombine(CbcHeuristic *&gen, CbcModel *model,
    00378                          bool alwaysCreate = true) ;
    00379
    00382     inline void setCombineAction(CGControl action) {
    00383         combine_.action_ = action ;
    00384     }
    00385
    00393     CGControl getGreedyCover(CbcHeuristic *&gen, CbcModel *model,
    00394                              bool alwaysCreate = true) ;
    00395
    00398     inline void setGreedyCoverAction(CGControl action) {
    00399         greedyCover_.action_ = action ;
    00400     }
    00401
    00409     CGControl getGreedyEquality(CbcHeuristic *&gen, CbcModel *model,
    00410                                 bool alwaysCreate = true) ;
    00411
    00414     inline void setGreedyEqualityAction(CGControl action) {
    00415         greedyEquality_.action_ = action ;
    00416     }
    00417
    00425     CGControl getRounding(CbcHeuristic *&gen, CbcModel *model,
    00426                           bool alwaysCreate = true) ;
    00427
    00430     inline void setRoundingAction(CGControl action) {
    00431         rounding_.action_ = action ;
    00432     }
    00433
    00441     CGControl getTreeLocal(CbcTreeLocal *&localTree, CbcModel *model,
    00442                            bool alwaysCreate = true) ;
    00443
    00446     inline void setTreeLocalAction(CGControl action) {
    00447         localTree_.action_ = action ;
    00448     }
    00449
    00451
    00456
    00459     inline void setBaBStatus(BACMajor majorStatus, BACMinor minorStatus,
    00460                              BACWhere where, bool haveAnswer,
    00461                              OsiSolverInterface *answerSolver) {
    00462         bab_.majorStatus_ = majorStatus ;
    00463         bab_.minorStatus_ = minorStatus ;
    00464         bab_.where_ = where ;
    00465         bab_.haveAnswer_ = haveAnswer ;
    00466         bab_.answerSolver_ = answerSolver ;
    00467     }
    00468
    00474     void setBaBStatus(const CbcModel *model, BACWhere where,
    00475                       bool haveAnswer = false,
    00476                       OsiSolverInterface *answerSolver = 0) ;
    00477
    00482     BACMajor translateMajor(int status) ;
    00483
    00488     BACMinor translateMinor(int status) ;
    00489
    00495     BACMinor translateMinor(const OsiSolverInterface *osi) ;
    00496
    00499     void printBaBStatus() ;
    00500
    00502
    00505
    00510     CoinMessageHandler &message(CbcGenMsgCode inID) ;
    00511
    00517     void passInMessageHandler(CoinMessageHandler *handler) ;
    00518
    00520     inline CoinMessageHandler *messageHandler() const {
    00521         return msgHandler_ ;
    00522     }
    00523
    00536     void setMessages(CoinMessages::Language lang = CoinMessages::us_en) ;
    00537
    00539     inline void setLogLevel(int lvl) {
    00540         logLvl_ = lvl ;
    00541         if (msgHandler_) msgHandler_->setLogLevel(lvl) ;
    00542     }
    00543
    00545     inline int logLevel() const {
    00546         return (logLvl_) ;
    00547     }
    00548
    00552     int printOpt_ ;
    00553
    00555
    00560     std::string version_ ;
    00561
    00564     std::string dfltDirectory_ ;
    00565
    00568     std::string lastMpsIn_ ;
    00569
    00571     bool allowImportErrors_ ;
    00572
    00575     std::string lastSolnOut_ ;
    00576
    00583     int printMode_ ;
    00584
    00590     std::string printMask_ ;
    00591
    00594     CoinParamVec *paramVec_ ;
    00595
    00598     struct genParamsInfo_struct {
    00599         int first_ ;
    00600         int last_ ;
    00601     } genParams_ ;
    00602
    00605     struct cbcParamsInfo_struct {
    00606         int first_ ;
    00607         int last_ ;
    00608     } cbcParams_ ;
    00609
    00614     struct osiParamsInfo_struct {
    00615         int first_ ;
    00616         int last_ ;
    00617     } osiParams_ ;
    00618
    00628     int verbose_ ;
    00629
    00632     int paramsProcessed_ ;
    00633
    00636     std::vector<bool> setByUser_ ;
    00637
    00644     bool defaultSettings_ ;
    00645
    00654     std::string debugCreate_ ;
    00655
    00662     std::string debugFile_ ;
    00663
    00669     struct debugSolInfo_struct {
    00670         int numCols_ ;
    00671         double *values_ ;
    00672     } debugSol_ ;
    00674
    00675     /* \name Timing */
    00677
    00680     double totalTime_ ;
    00681
    00683
    00686
    00697     CbcModel *model_ ;
    00698
    00705     OsiSolverInterface *dfltSolver_ ;
    00706
    00709     bool goodModel_ ;
    00710
    00718     struct babState_struct {
    00719         BACMajor majorStatus_ ;
    00720         BACMinor minorStatus_ ;
    00721         BACWhere where_ ;
    00722         bool haveAnswer_ ;
    00723         OsiSolverInterface *answerSolver_ ;
    00724     } bab_ ;
    00725
    00727
    00730
    00739     struct djFixCtl_struct {
    00740         bool action_ ;
    00741         double threshold_ ;
    00742     } djFix_ ;
    00743
    00747     BPControl priorityAction_ ;
    00748
    00750
    00757
    00765     struct chooseStrongCtl_struct {
    00766         int numBeforeTrust_ ;
    00767         int numStrong_ ;
    00768         int shadowPriceMode_ ;
    00769     } chooseStrong_ ;
    00771
    00772 private:
    00773
    00778
    00781     IPPControl preProcess_ ;
    00782
    00789     int cutDepth_ ;
    00790
    00792     struct probingCtl_struct {
    00793         CGControl action_ ;
    00794         CglProbing *proto_ ;
    00795         bool usingObjective_ ;
    00796         int maxPass_ ;
    00797         int maxPassRoot_ ;
    00798         int maxProbe_ ;
    00799         int maxProbeRoot_ ;
    00800         int maxLook_ ;
    00801         int maxLookRoot_ ;
    00802         int maxElements_ ;
    00803         int rowCuts_ ;
    00804     } probing_ ;
    00805
    00807     struct cliqueCtl_struct {
    00808         CGControl action_ ;
    00809         CglClique *proto_ ;
    00810         bool starCliqueReport_ ;
    00811         bool rowCliqueReport_ ;
    00812         double minViolation_ ;
    00813     } clique_ ;
    00814
    00816     struct flowCtl_struct {
    00817         CGControl action_ ;
    00818         CglFlowCover *proto_ ;
    00819     } flow_ ;
    00820
    00822     struct gomoryCtl_struct {
    00823         CGControl action_ ;
    00824         CglGomory *proto_ ;
    00825         int limit_ ;
    00826         int limitAtRoot_ ;
    00827     } gomory_ ;
    00828
    00829     /*   \brief Control variable and prototype for lift-and-project cut
    00830              generator
    00831        struct landpCtl_struct
    00832        { CGControl action_ ;
    00833          CglLandP *proto_ ; } landp_ ;
    00834     */
    00835
    00837     struct knapsackCtl_struct {
    00838         CGControl action_ ;
    00839         CglKnapsackCover *proto_ ;
    00840     } knapsack_ ;
    00841
    00843     struct mirCtl_struct {
    00844         CGControl action_ ;
    00845         CglMixedIntegerRounding2 *proto_ ;
    00846     } mir_ ;
    00847
    00849     struct oddHoleCtl_struct {
    00850         CGControl action_ ;
    00851         CglOddHole *proto_ ;
    00852     } oddHole_ ;
    00853
    00857     struct redSplitCtl_struct {
    00858         CGControl action_ ;
    00859         CglRedSplit *proto_ ;
    00860     } redSplit_ ;
    00861
    00863     struct twomirCtl_struct {
    00864         CGControl action_ ;
    00865         CglTwomir *proto_ ;
    00866         int maxElements_ ;
    00867     } twomir_ ;
    00868
    00870     struct fpumpCtl_struct {
    00871         CGControl action_ ;
    00872         CbcHeuristicFPump *proto_ ;
    00873         int iters_ ;
    00874     } fpump_ ;
    00875
    00877     struct combineCtl_struct {
    00878         CGControl action_ ;
    00879         CbcHeuristicLocal *proto_ ;
    00880         int trySwap_ ;
    00881     } combine_ ;
    00882
    00884     struct greedyCoverCtl_struct {
    00885         CGControl action_ ;
    00886         CbcHeuristicGreedyCover *proto_ ;
    00887     } greedyCover_ ;
    00888
    00890     struct greedyEqualityCtl_struct {
    00891         CGControl action_ ;
    00892         CbcHeuristicGreedyEquality *proto_ ;
    00893     } greedyEquality_ ;
    00894
    00896     struct roundingCtl_struct {
    00897         CGControl action_ ;
    00898         CbcRounding *proto_ ;
    00899     } rounding_ ;
    00900
    00901
    00908     struct localTreeCtl_struct {
    00909         CGControl action_ ;
    00910         CbcTreeLocal *proto_ ;
    00911         double *soln_ ;
    00912         int range_ ;
    00913         int typeCuts_ ;
    00914         int maxDiverge_ ;
    00915         int timeLimit_ ;
    00916         int nodeLimit_ ;
    00917         bool refine_ ;
    00918     } localTree_ ;
    00919
    00921
    00927
    00929     CoinMessageHandler *msgHandler_ ;
    00930
    00937     bool ourMsgHandler_ ;
    00938
    00940     CoinMessages::Language cur_lang_ ;
    00941
    00943     CoinMessages *msgs_ ;
    00944
    00946     int logLvl_ ;
    00947
    00949
    00950 } ;
    00951
    00952
    00953 #endif
    00954

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines