Ignore:
Timestamp:
May 14, 2007 8:37:33 PM (12 years ago)
Author:
lou
Message:

Cbc-generic: Add message handler, separate libCbc and cbc-generic main log
level parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Cbc/src/CbcGenCtlBlk.hpp

    r591 r608  
    1414
    1515#include "CoinParam.hpp"
     16#include "CoinMessageHandler.hpp"
    1617
    1718#include "CglCutGenerator.hpp"
     
    3334#include "CbcHeuristicLocal.hpp"
    3435#include "CbcTreeLocal.hpp"
     36
     37#include "CbcGenMessages.hpp"
     38
     39/*
     40  It turns out that doxygen is not good with anonymous structures. Hence the
     41  `struct nameCtl_struct' style used for structured fields in CbcGenCtlBlk.
     42*/
     43
     44/*
     45  $Id$
     46*/
    3547
    3648#define CBC_GENERIC_VERSION "00.01.00"
     
    409421//@}
    410422
    411 /*! \brief Convenience routines for status codes. */
     423/*! \name Status Functions
     424    \brief Convenience routines for status codes.
     425*/
    412426//@{
    413427
     
    432446                    OsiSolverInterface *answerSolver = 0) ;
    433447
    434   /*! \brief Translate CbcModel major status to BACMajor
    435  
    436     See the BACMajor enum for details.
     448  /*! \brief Translate CbcModel major status to #BACMajor
     449 
     450    See the #BACMajor enum for details.
    437451  */
    438452  BACMajor translateMajor(int status) ;
    439453
    440   /*!\brief Translate CbcModel minor status to BACMinor
    441 
    442     See the BACMinor enum for details.
     454  /*!\brief Translate CbcModel minor status to #BACMinor
     455
     456    See the #BACMinor enum for details.
    443457  */
    444458  BACMinor translateMinor(int status) ;
    445459
    446   /*!\brief Translate OsiSolverInterface status to BACMinor
    447 
    448     See the BACMinor enum for details. Optimal, infeasible, and unbounded
     460  /*!\brief Translate OsiSolverInterface status to #BACMinor
     461
     462    See the #BACMinor enum for details. Optimal, infeasible, and unbounded
    449463    get their own codes; everything else maps to BACmOther.
    450464  */
     
    457471//@}
    458472
    459 /*! \name Parameter parsing, input/output, and such like. */
     473/*! \name Messages and statistics */
     474//@{
     475
     476  /*! \brief Print a message
     477
     478    Uses the current message handler and messages.
     479  */
     480  CoinMessageHandler &message(CbcGenMsgCode inID) ;
     481
     482  /*! \brief Supply a new message handler.
     483
     484    Replaces the current message handler. The current handler is destroyed
     485    if ourMsgHandler_ is true, and the call will set ourMsgHandler_ = true.
     486  */
     487  void passInMessageHandler(CoinMessageHandler *handler) ;
     488
     489  /*! \brief Return a pointer to the message handler */
     490  inline CoinMessageHandler *messageHandler() const { return msgHandler_ ; } ;
     491
     492  /*! \brief Set up messages in the specified language.
     493
     494    Building a set of messages in a given language implies rebuilding the
     495    whole set of messages, for reasons explained in the body of the code.
     496    Hence there's no separate setLanguage routine. Use this routine for the
     497    initial setup of messages and any subsequent change in language. Note
     498    that the constructor gives you a message handler by default, but \e not
     499    messages. You need to call setMessages explicitly.
     500
     501    The default value specified here for lang effectively sets the default
     502    language.
     503  */
     504  void setMessages(CoinMessages::Language lang = CoinMessages::us_en) ;
     505
     506  /*! \brief Set log level */
     507  inline void setLogLevel(int lvl)
     508  { logLvl_ = lvl ;
     509    if (msgHandler_) msgHandler_->setLogLevel(lvl) ; } ;
     510
     511  /*! \brief Get log level */
     512  inline int logLevel() const { return (logLvl_) ; } ;
     513
     514  /*! \brief When greater than 0, integer presolve gives more information and
     515             branch-and-cut provides statistics.
     516  */
     517  int printOpt_ ;
     518
     519//@}
     520
     521/*! \name Parameter parsing and input/output. */
    460522//@{
    461523  /*! \brief cbc-generic version */
     
    499561  /*! \brief Start and end of cbc-generic parameters in parameter vector */
    500562
    501   struct { int first_ ;
    502            int last_ ; } genParams_ ;
     563  struct genParamsInfo_struct
     564  { int first_ ;
     565    int last_ ; } genParams_ ;
    503566
    504567  /*! \brief Start and end of CbcModel parameters in parameter vector */
    505568
    506   struct { int first_ ;
    507            int last_ ; } cbcParams_ ;
     569  struct cbcParamsInfo_struct
     570  { int first_ ;
     571    int last_ ; } cbcParams_ ;
    508572
    509573  /*! \brief Start and end of OsiSolverInterface  parameters in parameter
     
    511575  */
    512576
    513   struct { int first_ ;
    514            int last_ ; } osiParams_ ;
     577  struct osiParamsInfo_struct
     578  { int first_ ;
     579    int last_ ; } osiParams_ ;
    515580
    516581  /*! \brief Verbosity level for help messages.
     
    529594  int paramsProcessed_ ;
    530595
    531   /*! \brief Record of parameters changed by the user command */
     596  /*! \brief Record of parameters changed by user command */
    532597
    533598  std::vector<bool> setByUser_ ;
     
    564629  */
    565630
    566   struct { int numCols_ ;
    567            double *values_ ; } debugSol_ ;
    568 
    569   /*! \brief When greater than 0, presolve gives more information and
    570              branch-and-cut provides statistics.
    571   */
    572 
    573   int printOpt_ ;
    574 
     631  struct debugSolInfo_struct
     632  { int numCols_ ;
     633    double *values_ ; } debugSol_ ;
    575634//@}
    576635
     
    618677  */
    619678
    620   struct { BACMajor majorStatus_ ;
    621            BACMinor minorStatus_ ;
    622            BACWhere where_ ;
    623            bool haveAnswer_ ;
    624            OsiSolverInterface *answerSolver_ ; } bab_ ;
     679  struct babState_struct
     680  { BACMajor majorStatus_ ;
     681    BACMinor minorStatus_ ;
     682    BACWhere where_ ;
     683    bool haveAnswer_ ;
     684    OsiSolverInterface *answerSolver_ ; } bab_ ;
    625685
    626686//@}
     
    637697  */
    638698
    639   struct { bool action_ ;
    640            double threshold_ ; } djFix_ ;
     699  struct djFixCtl_struct
     700  { bool action_ ;
     701    double threshold_ ; } djFix_ ;
    641702
    642703  /*! \brief Control the assignment of branching priorities to integer
     
    661722    evaluated with strong branching (numStrong_) are parameters of CbcModel.
    662723  */
    663   struct { int numBeforeTrust_ ;
    664            int numStrong_ ;
    665            int shadowPriceMode_ ; } chooseStrong_ ;
     724  struct chooseStrongCtl_struct
     725  { int numBeforeTrust_ ;
     726    int numStrong_ ;
     727    int shadowPriceMode_ ; } chooseStrong_ ;
    666728//@}
    667729
     
    686748
    687749  /*! \brief Control variable and prototype for probing cut generator */
    688   struct { CGControl action_ ;
    689            CglProbing *proto_ ;
    690            bool usingObjective_ ;
    691            int maxPass_ ;
    692            int maxPassRoot_ ;
    693            int maxProbe_ ;
    694            int maxProbeRoot_ ;
    695            int maxLook_ ;
    696            int maxLookRoot_ ;
    697            int maxElements_ ;
    698            int rowCuts_ ; } probing_ ;
     750  struct probingCtl_struct
     751  { CGControl action_ ;
     752    CglProbing *proto_ ;
     753    bool usingObjective_ ;
     754    int maxPass_ ;
     755    int maxPassRoot_ ;
     756    int maxProbe_ ;
     757    int maxProbeRoot_ ;
     758    int maxLook_ ;
     759    int maxLookRoot_ ;
     760    int maxElements_ ;
     761    int rowCuts_ ; } probing_ ;
    699762
    700763  /*! \brief Control variable and prototype for clique cut generator */
    701   struct { CGControl action_ ;
    702            CglClique *proto_ ;
    703            bool starCliqueReport_ ;
    704            bool rowCliqueReport_ ;
    705            double minViolation_ ; } clique_ ;
     764  struct cliqueCtl_struct
     765  { CGControl action_ ;
     766    CglClique *proto_ ;
     767    bool starCliqueReport_ ;
     768    bool rowCliqueReport_ ;
     769    double minViolation_ ; } clique_ ;
    706770
    707771  /*! \brief Control variable and prototype for flow cover cut generator */
    708   struct { CGControl action_ ;
    709            CglFlowCover *proto_ ; } flow_ ;
     772  struct flowCtl_struct
     773  { CGControl action_ ;
     774    CglFlowCover *proto_ ; } flow_ ;
    710775
    711776  /*! \brief Control variable and prototype for Gomory cut generator */
    712   struct { CGControl action_ ;
    713            CglGomory *proto_ ;
    714            int limit_ ;
    715            int limitAtRoot_ ; } gomory_ ;
     777  struct gomoryCtl_struct
     778  { CGControl action_ ;
     779    CglGomory *proto_ ;
     780    int limit_ ;
     781    int limitAtRoot_ ; } gomory_ ;
    716782
    717783/*   \brief Control variable and prototype for lift-and-project cut
    718784             generator
    719    struct { CGControl action_ ;
    720            CglLandP *proto_ ; } landp_ ;
     785   struct landpCtl_struct
     786   { CGControl action_ ;
     787     CglLandP *proto_ ; } landp_ ;
    721788*/
    722789
    723790  /*! \brief Control variable and prototype for knapsack cover cut generator */
    724   struct { CGControl action_ ;
    725            CglKnapsackCover *proto_ ; } knapsack_ ;
     791  struct knapsackCtl_struct
     792  { CGControl action_ ;
     793    CglKnapsackCover *proto_ ; } knapsack_ ;
    726794
    727795  /*! \brief Control variable and prototype for MIR cut generator */
    728   struct { CGControl action_ ;
    729            CglMixedIntegerRounding2 *proto_ ; } mir_ ;
     796  struct mirCtl_struct
     797  { CGControl action_ ;
     798    CglMixedIntegerRounding2 *proto_ ; } mir_ ;
    730799
    731800  /*! \brief Control variable and prototype for odd hole cut generator */
    732   struct { CGControl action_ ;
    733            CglOddHole *proto_ ; } oddHole_ ;
     801  struct oddHoleCtl_struct
     802  { CGControl action_ ;
     803    CglOddHole *proto_ ; } oddHole_ ;
    734804
    735805  /*! \brief Control variable and prototype for reduce-and-split
    736806             cut generator
    737807  */
    738   struct { CGControl action_ ;
    739            CglRedSplit *proto_ ; } redSplit_ ;
     808  struct redSplitCtl_struct
     809  { CGControl action_ ;
     810    CglRedSplit *proto_ ; } redSplit_ ;
    740811
    741812  /*! \brief Control variable and prototype for Two-MIR cut generator */
    742   struct { CGControl action_ ;
    743            CglTwomir *proto_ ;
    744            int maxElements_ ; } twomir_ ;
     813  struct twomirCtl_struct
     814  { CGControl action_ ;
     815    CglTwomir *proto_ ;
     816    int maxElements_ ; } twomir_ ;
    745817
    746818  /*! \brief Control variable and prototype for feasibility pump heuristic */
    747   struct { CGControl action_ ;
    748            CbcHeuristicFPump *proto_ ;
    749            int iters_ ; } fpump_ ;
     819  struct fpumpCtl_struct
     820  { CGControl action_ ;
     821    CbcHeuristicFPump *proto_ ;
     822    int iters_ ; } fpump_ ;
    750823
    751824  /*! \brief Control variable and prototype for combine heuristic */
    752   struct { CGControl action_ ;
    753            CbcHeuristicLocal *proto_ ;
    754            int trySwap_ ; } combine_ ;
     825  struct combineCtl_struct
     826  { CGControl action_ ;
     827    CbcHeuristicLocal *proto_ ;
     828    int trySwap_ ; } combine_ ;
    755829
    756830  /*! \brief Control variable and prototype for greedy cover heuristic */
    757   struct { CGControl action_ ;
    758            CbcHeuristicGreedyCover *proto_ ; } greedyCover_ ;
     831  struct greedyCoverCtl_struct
     832  { CGControl action_ ;
     833    CbcHeuristicGreedyCover *proto_ ; } greedyCover_ ;
    759834
    760835  /*! \brief Control variable and prototype for greedy equality heuristic */
    761   struct { CGControl action_ ;
    762            CbcHeuristicGreedyEquality *proto_ ; } greedyEquality_ ;
     836  struct greedyEqualityCtl_struct
     837  { CGControl action_ ;
     838    CbcHeuristicGreedyEquality *proto_ ; } greedyEquality_ ;
    763839
    764840  /*! \brief Control variable and prototype for simple rounding heuristic */
    765   struct { CGControl action_ ;
    766            CbcRounding *proto_ ; } rounding_ ;
     841  struct roundingCtl_struct
     842  { CGControl action_ ;
     843    CbcRounding *proto_ ; } rounding_ ;
    767844
    768845
     
    773850    hide the details. Consult CbcTreeLocal.hpp for details.
    774851  */
    775   struct { CGControl action_ ;
    776            CbcTreeLocal *proto_ ;
    777            double *soln_ ;
    778            int range_ ;
    779            int typeCuts_ ;
    780            int maxDiverge_ ;
    781            int timeLimit_ ;
    782            int nodeLimit_ ;
    783            bool refine_ ; } localTree_ ;
     852  struct localTreeCtl_struct
     853  { CGControl action_ ;
     854    CbcTreeLocal *proto_ ;
     855    double *soln_ ;
     856    int range_ ;
     857    int typeCuts_ ;
     858    int maxDiverge_ ;
     859    int timeLimit_ ;
     860    int nodeLimit_ ;
     861    bool refine_ ; } localTree_ ;
     862
     863//@}
     864
     865/*! \name Messages and statistics (private)
     866    \brief Data and objects related to messages and statistics that should be
     867           protected from direct manipulation.
     868*/
     869//@{
     870
     871  /*! \brief Message handler. */
     872  CoinMessageHandler *msgHandler_ ;
     873
     874  /*! \brief Ownership of message handler.
     875
     876    If true, the control block owns the message handler and it will be destroyed
     877    with the control block. If false, the client is responsible for the message
     878    handler.
     879  */
     880  bool ourMsgHandler_ ;
     881
     882  /*! \brief The current language */
     883  CoinMessages::Language cur_lang_ ;
     884
     885  /*! \brief The current set of messages. */
     886  CoinMessages *msgs_ ;
     887
     888  /*! \brief The current log level */
     889  int logLvl_ ;
    784890
    785891//@}
Note: See TracChangeset for help on using the changeset viewer.