Unified message handling for LP and MIP solvers (#9)
authorBalazs Dezso <deba@inf.elte.hu>
Wed, 08 Apr 2009 22:49:28 +0200
changeset 568745e182d0139
parent 565 37216ca5b9c6
child 569 5563527bcc8d
Unified message handling for LP and MIP solvers (#9)
lemon/cbc.cc
lemon/cbc.h
lemon/clp.cc
lemon/clp.h
lemon/cplex.cc
lemon/cplex.h
lemon/glpk.cc
lemon/glpk.h
lemon/lp_base.h
lemon/lp_skeleton.cc
lemon/lp_skeleton.h
lemon/soplex.cc
lemon/soplex.h
     1.1 --- a/lemon/cbc.cc	Tue Apr 07 14:50:20 2009 +0100
     1.2 +++ b/lemon/cbc.cc	Wed Apr 08 22:49:28 2009 +0200
     1.3 @@ -55,12 +55,15 @@
     1.4      _prob->setProblemName("LEMON");
     1.5      _osi_solver = 0;
     1.6      _cbc_model = 0;
     1.7 +    messageLevel(MESSAGE_NOTHING);
     1.8    }
     1.9  
    1.10    CbcMip::CbcMip(const CbcMip& other) {
    1.11      _prob = new CoinModel(*other._prob);
    1.12 +    _prob->setProblemName("LEMON");
    1.13      _osi_solver = 0;
    1.14      _cbc_model = 0;
    1.15 +    messageLevel(MESSAGE_NOTHING);
    1.16    }
    1.17  
    1.18    CbcMip::~CbcMip() {
    1.19 @@ -270,24 +273,8 @@
    1.20      }
    1.21      _cbc_model= new CbcModel(*_osi_solver);
    1.22  
    1.23 -    switch (_message_level) {
    1.24 -    case MESSAGE_NO_OUTPUT:
    1.25 -      _osi_solver->messageHandler()->setLogLevel(0);
    1.26 -      _cbc_model->setLogLevel(0);
    1.27 -      break;
    1.28 -    case MESSAGE_ERROR_MESSAGE:
    1.29 -      _osi_solver->messageHandler()->setLogLevel(1);
    1.30 -      _cbc_model->setLogLevel(1);
    1.31 -      break;
    1.32 -    case MESSAGE_NORMAL_OUTPUT:
    1.33 -      _osi_solver->messageHandler()->setLogLevel(2);
    1.34 -      _cbc_model->setLogLevel(2);
    1.35 -      break;
    1.36 -    case MESSAGE_FULL_OUTPUT:
    1.37 -      _osi_solver->messageHandler()->setLogLevel(3);
    1.38 -      _cbc_model->setLogLevel(3);
    1.39 -      break;
    1.40 -    }
    1.41 +    _osi_solver->messageHandler()->setLogLevel(_message_level);
    1.42 +    _cbc_model->setLogLevel(_message_level);
    1.43  
    1.44      _cbc_model->initialSolve();
    1.45      _cbc_model->solver()->setHintParam(OsiDoReducePrint, true, OsiHintTry);
    1.46 @@ -453,8 +440,24 @@
    1.47      cols.clear();
    1.48    }
    1.49  
    1.50 -  void CbcMip::messageLevel(MessageLevel m) {
    1.51 -    _message_level = m;
    1.52 +  void CbcMip::_messageLevel(MessageLevel level) {
    1.53 +    switch (level) {
    1.54 +    case MESSAGE_NOTHING:
    1.55 +      _message_level = 0;
    1.56 +      break;
    1.57 +    case MESSAGE_ERROR:
    1.58 +      _message_level = 1;
    1.59 +      break;
    1.60 +    case MESSAGE_WARNING:
    1.61 +      _message_level = 1;
    1.62 +      break;
    1.63 +    case MESSAGE_NORMAL:
    1.64 +      _message_level = 2;
    1.65 +      break;
    1.66 +    case MESSAGE_VERBOSE:
    1.67 +      _message_level = 3;
    1.68 +      break;
    1.69 +    }
    1.70    }
    1.71  
    1.72  } //END OF NAMESPACE LEMON
     2.1 --- a/lemon/cbc.h	Tue Apr 07 14:50:20 2009 +0100
     2.2 +++ b/lemon/cbc.h	Wed Apr 08 22:49:28 2009 +0200
     2.3 @@ -115,33 +115,12 @@
     2.4  
     2.5      virtual void _clear();
     2.6  
     2.7 -  public:
     2.8 +    virtual void _messageLevel(MessageLevel level);
     2.9 +    void _applyMessageLevel();
    2.10  
    2.11 -    ///Enum for \c messageLevel() parameter
    2.12 -    enum MessageLevel {
    2.13 -      /// no output (default value)
    2.14 -      MESSAGE_NO_OUTPUT = 0,
    2.15 -      /// error messages only
    2.16 -      MESSAGE_ERROR_MESSAGE = 1,
    2.17 -      /// normal output
    2.18 -      MESSAGE_NORMAL_OUTPUT = 2,
    2.19 -      /// full output (includes informational messages)
    2.20 -      MESSAGE_FULL_OUTPUT = 3
    2.21 -    };
    2.22 +    int _message_level;
    2.23  
    2.24 -  private:
    2.25 -
    2.26 -    MessageLevel _message_level;
    2.27 -
    2.28 -  public:
    2.29 -
    2.30 -    ///Set the verbosity of the messages
    2.31 -
    2.32 -    ///Set the verbosity of the messages
    2.33 -    ///
    2.34 -    ///\param m is the level of the messages output by the solver routines.
    2.35 -    void messageLevel(MessageLevel m);
    2.36 -
    2.37 +    
    2.38  
    2.39    };
    2.40  
     3.1 --- a/lemon/clp.cc	Tue Apr 07 14:50:20 2009 +0100
     3.2 +++ b/lemon/clp.cc	Wed Apr 08 22:49:28 2009 +0200
     3.3 @@ -24,7 +24,7 @@
     3.4    ClpLp::ClpLp() {
     3.5      _prob = new ClpSimplex();
     3.6      _init_temporals();
     3.7 -    messageLevel(MESSAGE_NO_OUTPUT);
     3.8 +    messageLevel(MESSAGE_NOTHING);
     3.9    }
    3.10  
    3.11    ClpLp::ClpLp(const ClpLp& other) {
    3.12 @@ -32,7 +32,7 @@
    3.13      rows = other.rows;
    3.14      cols = other.cols;
    3.15      _init_temporals();
    3.16 -    messageLevel(MESSAGE_NO_OUTPUT);
    3.17 +    messageLevel(MESSAGE_NOTHING);
    3.18    }
    3.19  
    3.20    ClpLp::~ClpLp() {
    3.21 @@ -430,8 +430,24 @@
    3.22      _clear_temporals();
    3.23    }
    3.24  
    3.25 -  void ClpLp::messageLevel(MessageLevel m) {
    3.26 -    _prob->setLogLevel(static_cast<int>(m));
    3.27 +  void ClpLp::_messageLevel(MessageLevel level) {
    3.28 +    switch (level) {
    3.29 +    case MESSAGE_NOTHING:
    3.30 +      _prob->setLogLevel(0);
    3.31 +      break;
    3.32 +    case MESSAGE_ERROR:
    3.33 +      _prob->setLogLevel(1);
    3.34 +      break;
    3.35 +    case MESSAGE_WARNING:
    3.36 +      _prob->setLogLevel(2);
    3.37 +      break;
    3.38 +    case MESSAGE_NORMAL:
    3.39 +      _prob->setLogLevel(3);
    3.40 +      break;
    3.41 +    case MESSAGE_VERBOSE:
    3.42 +      _prob->setLogLevel(4);
    3.43 +      break;
    3.44 +    }
    3.45    }
    3.46  
    3.47  } //END OF NAMESPACE LEMON
     4.1 --- a/lemon/clp.h	Tue Apr 07 14:50:20 2009 +0100
     4.2 +++ b/lemon/clp.h	Wed Apr 08 22:49:28 2009 +0200
     4.3 @@ -136,6 +136,8 @@
     4.4  
     4.5      virtual void _clear();
     4.6  
     4.7 +    virtual void _messageLevel(MessageLevel);
     4.8 +    
     4.9    public:
    4.10  
    4.11      ///Solves LP with primal simplex method.
    4.12 @@ -153,26 +155,6 @@
    4.13      ///Returns the variable identifier understood by CLP.
    4.14      int clpCol(Col c) const { return cols(id(c)); }
    4.15  
    4.16 -    ///Enum for \c messageLevel() parameter
    4.17 -    enum MessageLevel {
    4.18 -      /// no output (default value)
    4.19 -      MESSAGE_NO_OUTPUT = 0,
    4.20 -      /// print final solution
    4.21 -      MESSAGE_FINAL_SOLUTION = 1,
    4.22 -      /// print factorization
    4.23 -      MESSAGE_FACTORIZATION = 2,
    4.24 -      /// normal output
    4.25 -      MESSAGE_NORMAL_OUTPUT = 3,
    4.26 -      /// verbose output
    4.27 -      MESSAGE_VERBOSE_OUTPUT = 4
    4.28 -    };
    4.29 -    ///Set the verbosity of the messages
    4.30 -
    4.31 -    ///Set the verbosity of the messages
    4.32 -    ///
    4.33 -    ///\param m is the level of the messages output by the solver routines.
    4.34 -    void messageLevel(MessageLevel m);
    4.35 -
    4.36    };
    4.37  
    4.38  } //END OF NAMESPACE LEMON
     5.1 --- a/lemon/cplex.cc	Tue Apr 07 14:50:20 2009 +0100
     5.2 +++ b/lemon/cplex.cc	Wed Apr 08 22:49:28 2009 +0200
     5.3 @@ -72,12 +72,14 @@
     5.4    CplexBase::CplexBase() : LpBase() {
     5.5      int status;
     5.6      _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
     5.7 +    messageLevel(MESSAGE_NOTHING);
     5.8    }
     5.9  
    5.10    CplexBase::CplexBase(const CplexEnv& env)
    5.11      : LpBase(), _env(env) {
    5.12      int status;
    5.13      _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
    5.14 +    messageLevel(MESSAGE_NOTHING);
    5.15    }
    5.16  
    5.17    CplexBase::CplexBase(const CplexBase& cplex)
    5.18 @@ -86,6 +88,7 @@
    5.19      _prob = CPXcloneprob(cplexEnv(), cplex._prob, &status);
    5.20      rows = cplex.rows;
    5.21      cols = cplex.cols;
    5.22 +    messageLevel(MESSAGE_NOTHING);
    5.23    }
    5.24  
    5.25    CplexBase::~CplexBase() {
    5.26 @@ -438,6 +441,25 @@
    5.27      cols.clear();
    5.28    }
    5.29  
    5.30 +  void CplexBase::_messageLevel(MessageLevel level) {
    5.31 +    switch (level) {
    5.32 +    case MESSAGE_NOTHING:
    5.33 +      _message_enabled = false;
    5.34 +      break;
    5.35 +    case MESSAGE_ERROR:
    5.36 +    case MESSAGE_WARNING:
    5.37 +    case MESSAGE_NORMAL:
    5.38 +    case MESSAGE_VERBOSE:
    5.39 +      _message_enabled = true;
    5.40 +      break;
    5.41 +    }
    5.42 +  }
    5.43 +
    5.44 +  void CplexBase::_applyMessageLevel() {
    5.45 +    CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, 
    5.46 +                   _message_enabled ? CPX_ON : CPX_OFF);
    5.47 +  }
    5.48 +
    5.49    // CplexLp members
    5.50  
    5.51    CplexLp::CplexLp()
    5.52 @@ -507,21 +529,25 @@
    5.53  
    5.54    CplexLp::SolveExitStatus CplexLp::_solve() {
    5.55      _clear_temporals();
    5.56 +    _applyMessageLevel();
    5.57      return convertStatus(CPXlpopt(cplexEnv(), _prob));
    5.58    }
    5.59  
    5.60    CplexLp::SolveExitStatus CplexLp::solvePrimal() {
    5.61      _clear_temporals();
    5.62 +    _applyMessageLevel();
    5.63      return convertStatus(CPXprimopt(cplexEnv(), _prob));
    5.64    }
    5.65  
    5.66    CplexLp::SolveExitStatus CplexLp::solveDual() {
    5.67      _clear_temporals();
    5.68 +    _applyMessageLevel();
    5.69      return convertStatus(CPXdualopt(cplexEnv(), _prob));
    5.70    }
    5.71  
    5.72    CplexLp::SolveExitStatus CplexLp::solveBarrier() {
    5.73      _clear_temporals();
    5.74 +    _applyMessageLevel();
    5.75      return convertStatus(CPXbaropt(cplexEnv(), _prob));
    5.76    }
    5.77  
    5.78 @@ -600,7 +626,7 @@
    5.79      return _dual_ray[i];
    5.80    }
    5.81  
    5.82 -  //7.5-os cplex statusai (Vigyazat: a 9.0-asei masok!)
    5.83 +  // Cplex 7.0 status values
    5.84    // This table lists the statuses, returned by the CPXgetstat()
    5.85    // routine, for solutions to LP problems or mixed integer problems. If
    5.86    // no solution exists, the return value is zero.
    5.87 @@ -647,7 +673,7 @@
    5.88    // 20   CPX_PIVOT
    5.89    //       User pivot used
    5.90    //
    5.91 -  //     Ezeket hova tegyem:
    5.92 +  // Pending return values
    5.93    // ??case CPX_ABORT_DUAL_INFEAS
    5.94    // ??case CPX_ABORT_CROSSOVER
    5.95    // ??case CPX_INForUNBD
    5.96 @@ -718,7 +744,6 @@
    5.97  #else
    5.98      statusSwitch(cplexEnv(),stat);
    5.99      //CPXgetstat(cplexEnv(), _prob);
   5.100 -    //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
   5.101      switch (stat) {
   5.102      case 0:
   5.103        return UNDEFINED; //Undefined
   5.104 @@ -751,7 +776,7 @@
   5.105  #endif
   5.106    }
   5.107  
   5.108 -  //9.0-as cplex verzio statusai
   5.109 +  // Cplex 9.0 status values
   5.110    // CPX_STAT_ABORT_DUAL_OBJ_LIM
   5.111    // CPX_STAT_ABORT_IT_LIM
   5.112    // CPX_STAT_ABORT_OBJ_LIM
   5.113 @@ -864,6 +889,7 @@
   5.114  
   5.115    CplexMip::SolveExitStatus CplexMip::_solve() {
   5.116      int status;
   5.117 +    _applyMessageLevel();
   5.118      status = CPXmipopt (cplexEnv(), _prob);
   5.119      if (status==0)
   5.120        return SOLVED;
     6.1 --- a/lemon/cplex.h	Tue Apr 07 14:50:20 2009 +0100
     6.2 +++ b/lemon/cplex.h	Wed Apr 08 22:49:28 2009 +0200
     6.3 @@ -144,14 +144,29 @@
     6.4  
     6.5      virtual void _clear();
     6.6  
     6.7 +    virtual void _messageLevel(MessageLevel level);
     6.8 +    void _applyMessageLevel();
     6.9 +
    6.10 +    bool _message_enabled;
    6.11 +
    6.12    public:
    6.13  
    6.14      /// Returns the used \c CplexEnv instance
    6.15      const CplexEnv& env() const { return _env; }
    6.16 +
    6.17 +    /// \brief Returns the const cpxenv pointer
    6.18      ///
    6.19 +    /// \note The cpxenv might be destructed with the solver.
    6.20      const cpxenv* cplexEnv() const { return _env.cplexEnv(); }
    6.21  
    6.22 +    /// \brief Returns the const cpxenv pointer
    6.23 +    ///
    6.24 +    /// \note The cpxenv might be destructed with the solver.
    6.25 +    cpxenv* cplexEnv() { return _env.cplexEnv(); }
    6.26 +
    6.27 +    /// Returns the cplex problem object
    6.28      cpxlp* cplexLp() { return _prob; }
    6.29 +    /// Returns the cplex problem object
    6.30      const cpxlp* cplexLp() const { return _prob; }
    6.31  
    6.32    };
     7.1 --- a/lemon/glpk.cc	Tue Apr 07 14:50:20 2009 +0100
     7.2 +++ b/lemon/glpk.cc	Wed Apr 08 22:49:28 2009 +0200
     7.3 @@ -31,6 +31,7 @@
     7.4    GlpkBase::GlpkBase() : LpBase() {
     7.5      lp = glp_create_prob();
     7.6      glp_create_index(lp);
     7.7 +    messageLevel(MESSAGE_NOTHING);
     7.8    }
     7.9  
    7.10    GlpkBase::GlpkBase(const GlpkBase &other) : LpBase() {
    7.11 @@ -39,6 +40,7 @@
    7.12      glp_create_index(lp);
    7.13      rows = other.rows;
    7.14      cols = other.cols;
    7.15 +    messageLevel(MESSAGE_NOTHING);
    7.16    }
    7.17  
    7.18    GlpkBase::~GlpkBase() {
    7.19 @@ -526,19 +528,37 @@
    7.20      glp_free_env();
    7.21    }
    7.22  
    7.23 +  void GlpkBase::_messageLevel(MessageLevel level) {
    7.24 +    switch (level) {
    7.25 +    case MESSAGE_NOTHING:
    7.26 +      _message_level = GLP_MSG_OFF;
    7.27 +      break;
    7.28 +    case MESSAGE_ERROR:
    7.29 +      _message_level = GLP_MSG_ERR;
    7.30 +      break;
    7.31 +    case MESSAGE_WARNING:
    7.32 +      _message_level = GLP_MSG_ERR;
    7.33 +      break;
    7.34 +    case MESSAGE_NORMAL:
    7.35 +      _message_level = GLP_MSG_ON;
    7.36 +      break;
    7.37 +    case MESSAGE_VERBOSE:
    7.38 +      _message_level = GLP_MSG_ALL;
    7.39 +      break;
    7.40 +    }
    7.41 +  }
    7.42 +
    7.43    GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;
    7.44  
    7.45    // GlpkLp members
    7.46  
    7.47    GlpkLp::GlpkLp()
    7.48      : LpBase(), LpSolver(), GlpkBase() {
    7.49 -    messageLevel(MESSAGE_NO_OUTPUT);
    7.50      presolver(false);
    7.51    }
    7.52  
    7.53    GlpkLp::GlpkLp(const GlpkLp& other)
    7.54      : LpBase(other), LpSolver(other), GlpkBase(other) {
    7.55 -    messageLevel(MESSAGE_NO_OUTPUT);
    7.56      presolver(false);
    7.57    }
    7.58  
    7.59 @@ -562,20 +582,7 @@
    7.60      glp_smcp smcp;
    7.61      glp_init_smcp(&smcp);
    7.62  
    7.63 -    switch (_message_level) {
    7.64 -    case MESSAGE_NO_OUTPUT:
    7.65 -      smcp.msg_lev = GLP_MSG_OFF;
    7.66 -      break;
    7.67 -    case MESSAGE_ERROR_MESSAGE:
    7.68 -      smcp.msg_lev = GLP_MSG_ERR;
    7.69 -      break;
    7.70 -    case MESSAGE_NORMAL_OUTPUT:
    7.71 -      smcp.msg_lev = GLP_MSG_ON;
    7.72 -      break;
    7.73 -    case MESSAGE_FULL_OUTPUT:
    7.74 -      smcp.msg_lev = GLP_MSG_ALL;
    7.75 -      break;
    7.76 -    }
    7.77 +    smcp.msg_lev = _message_level;
    7.78      smcp.presolve = _presolve;
    7.79  
    7.80      // If the basis is not valid we get an error return value.
    7.81 @@ -604,20 +611,7 @@
    7.82      glp_smcp smcp;
    7.83      glp_init_smcp(&smcp);
    7.84  
    7.85 -    switch (_message_level) {
    7.86 -    case MESSAGE_NO_OUTPUT:
    7.87 -      smcp.msg_lev = GLP_MSG_OFF;
    7.88 -      break;
    7.89 -    case MESSAGE_ERROR_MESSAGE:
    7.90 -      smcp.msg_lev = GLP_MSG_ERR;
    7.91 -      break;
    7.92 -    case MESSAGE_NORMAL_OUTPUT:
    7.93 -      smcp.msg_lev = GLP_MSG_ON;
    7.94 -      break;
    7.95 -    case MESSAGE_FULL_OUTPUT:
    7.96 -      smcp.msg_lev = GLP_MSG_ALL;
    7.97 -      break;
    7.98 -    }
    7.99 +    smcp.msg_lev = _message_level;
   7.100      smcp.meth = GLP_DUAL;
   7.101      smcp.presolve = _presolve;
   7.102  
   7.103 @@ -858,20 +852,14 @@
   7.104      _presolve = presolve;
   7.105    }
   7.106  
   7.107 -  void GlpkLp::messageLevel(MessageLevel m) {
   7.108 -    _message_level = m;
   7.109 -  }
   7.110 -
   7.111    // GlpkMip members
   7.112  
   7.113    GlpkMip::GlpkMip()
   7.114      : LpBase(), MipSolver(), GlpkBase() {
   7.115 -    messageLevel(MESSAGE_NO_OUTPUT);
   7.116    }
   7.117  
   7.118    GlpkMip::GlpkMip(const GlpkMip& other)
   7.119      : LpBase(), MipSolver(), GlpkBase(other) {
   7.120 -    messageLevel(MESSAGE_NO_OUTPUT);
   7.121    }
   7.122  
   7.123    void GlpkMip::_setColType(int i, GlpkMip::ColTypes col_type) {
   7.124 @@ -900,20 +888,7 @@
   7.125      glp_smcp smcp;
   7.126      glp_init_smcp(&smcp);
   7.127  
   7.128 -    switch (_message_level) {
   7.129 -    case MESSAGE_NO_OUTPUT:
   7.130 -      smcp.msg_lev = GLP_MSG_OFF;
   7.131 -      break;
   7.132 -    case MESSAGE_ERROR_MESSAGE:
   7.133 -      smcp.msg_lev = GLP_MSG_ERR;
   7.134 -      break;
   7.135 -    case MESSAGE_NORMAL_OUTPUT:
   7.136 -      smcp.msg_lev = GLP_MSG_ON;
   7.137 -      break;
   7.138 -    case MESSAGE_FULL_OUTPUT:
   7.139 -      smcp.msg_lev = GLP_MSG_ALL;
   7.140 -      break;
   7.141 -    }
   7.142 +    smcp.msg_lev = _message_level;
   7.143      smcp.meth = GLP_DUAL;
   7.144  
   7.145      // If the basis is not valid we get an error return value.
   7.146 @@ -938,20 +913,7 @@
   7.147      glp_iocp iocp;
   7.148      glp_init_iocp(&iocp);
   7.149  
   7.150 -    switch (_message_level) {
   7.151 -    case MESSAGE_NO_OUTPUT:
   7.152 -      iocp.msg_lev = GLP_MSG_OFF;
   7.153 -      break;
   7.154 -    case MESSAGE_ERROR_MESSAGE:
   7.155 -      iocp.msg_lev = GLP_MSG_ERR;
   7.156 -      break;
   7.157 -    case MESSAGE_NORMAL_OUTPUT:
   7.158 -      iocp.msg_lev = GLP_MSG_ON;
   7.159 -      break;
   7.160 -    case MESSAGE_FULL_OUTPUT:
   7.161 -      iocp.msg_lev = GLP_MSG_ALL;
   7.162 -      break;
   7.163 -    }
   7.164 +    iocp.msg_lev = _message_level;
   7.165  
   7.166      if (glp_intopt(lp, &iocp) != 0) return UNSOLVED;
   7.167      return SOLVED;
   7.168 @@ -1002,8 +964,4 @@
   7.169  
   7.170    const char* GlpkMip::_solverName() const { return "GlpkMip"; }
   7.171  
   7.172 -  void GlpkMip::messageLevel(MessageLevel m) {
   7.173 -    _message_level = m;
   7.174 -  }
   7.175 -
   7.176  } //END OF NAMESPACE LEMON
     8.1 --- a/lemon/glpk.h	Tue Apr 07 14:50:20 2009 +0100
     8.2 +++ b/lemon/glpk.h	Wed Apr 08 22:49:28 2009 +0200
     8.3 @@ -100,6 +100,8 @@
     8.4  
     8.5      virtual void _clear();
     8.6  
     8.7 +    virtual void _messageLevel(MessageLevel level);
     8.8 +
     8.9    private:
    8.10  
    8.11      static void freeEnv();
    8.12 @@ -111,6 +113,10 @@
    8.13      };
    8.14      
    8.15      static FreeEnvHelper freeEnvHelper;
    8.16 +
    8.17 +  protected:
    8.18 +    
    8.19 +    int _message_level;
    8.20      
    8.21    public:
    8.22  
    8.23 @@ -191,30 +197,6 @@
    8.24      ///The presolver is off by default.
    8.25      void presolver(bool presolve);
    8.26  
    8.27 -    ///Enum for \c messageLevel() parameter
    8.28 -    enum MessageLevel {
    8.29 -      /// no output (default value)
    8.30 -      MESSAGE_NO_OUTPUT = 0,
    8.31 -      /// error messages only
    8.32 -      MESSAGE_ERROR_MESSAGE = 1,
    8.33 -      /// normal output
    8.34 -      MESSAGE_NORMAL_OUTPUT = 2,
    8.35 -      /// full output (includes informational messages)
    8.36 -      MESSAGE_FULL_OUTPUT = 3
    8.37 -    };
    8.38 -
    8.39 -  private:
    8.40 -
    8.41 -    MessageLevel _message_level;
    8.42 -
    8.43 -  public:
    8.44 -
    8.45 -    ///Set the verbosity of the messages
    8.46 -
    8.47 -    ///Set the verbosity of the messages
    8.48 -    ///
    8.49 -    ///\param m is the level of the messages output by the solver routines.
    8.50 -    void messageLevel(MessageLevel m);
    8.51    };
    8.52  
    8.53    /// \brief Interface for the GLPK MIP solver
    8.54 @@ -244,30 +226,6 @@
    8.55      virtual Value _getSol(int i) const;
    8.56      virtual Value _getSolValue() const;
    8.57  
    8.58 -    ///Enum for \c messageLevel() parameter
    8.59 -    enum MessageLevel {
    8.60 -      /// no output (default value)
    8.61 -      MESSAGE_NO_OUTPUT = 0,
    8.62 -      /// error messages only
    8.63 -      MESSAGE_ERROR_MESSAGE = 1,
    8.64 -      /// normal output
    8.65 -      MESSAGE_NORMAL_OUTPUT = 2,
    8.66 -      /// full output (includes informational messages)
    8.67 -      MESSAGE_FULL_OUTPUT = 3
    8.68 -    };
    8.69 -
    8.70 -  private:
    8.71 -
    8.72 -    MessageLevel _message_level;
    8.73 -
    8.74 -  public:
    8.75 -
    8.76 -    ///Set the verbosity of the messages
    8.77 -
    8.78 -    ///Set the verbosity of the messages
    8.79 -    ///
    8.80 -    ///\param m is the level of the messages output by the solver routines.
    8.81 -    void messageLevel(MessageLevel m);
    8.82    };
    8.83  
    8.84  
     9.1 --- a/lemon/lp_base.h	Tue Apr 07 14:50:20 2009 +0100
     9.2 +++ b/lemon/lp_base.h	Wed Apr 08 22:49:28 2009 +0200
     9.3 @@ -69,6 +69,21 @@
     9.4        MAX
     9.5      };
     9.6  
     9.7 +    ///Enum for \c messageLevel() parameter
     9.8 +    enum MessageLevel {
     9.9 +      /// no output (default value)
    9.10 +      MESSAGE_NOTHING,
    9.11 +      /// error messages only
    9.12 +      MESSAGE_ERROR,
    9.13 +      /// warnings
    9.14 +      MESSAGE_WARNING,
    9.15 +      /// normal output
    9.16 +      MESSAGE_NORMAL,
    9.17 +      /// verbose output
    9.18 +      MESSAGE_VERBOSE
    9.19 +    };
    9.20 +    
    9.21 +
    9.22      ///The floating point type used by the solver
    9.23      typedef double Value;
    9.24      ///The infinity constant
    9.25 @@ -973,6 +988,8 @@
    9.26  
    9.27      virtual const char* _solverName() const = 0;
    9.28  
    9.29 +    virtual void _messageLevel(MessageLevel level) = 0;
    9.30 +
    9.31      //Own protected stuff
    9.32  
    9.33      //Constant component of the objective function
    9.34 @@ -1527,6 +1544,9 @@
    9.35      ///Clears the problem
    9.36      void clear() { _clear(); }
    9.37  
    9.38 +    /// Sets the message level of the solver
    9.39 +    void messageLevel(MessageLevel level) { _messageLevel(level); }
    9.40 +
    9.41      ///@}
    9.42  
    9.43    };
    10.1 --- a/lemon/lp_skeleton.cc	Tue Apr 07 14:50:20 2009 +0100
    10.2 +++ b/lemon/lp_skeleton.cc	Wed Apr 08 22:49:28 2009 +0200
    10.3 @@ -84,6 +84,8 @@
    10.4      row_num = col_num = 0;
    10.5    }
    10.6  
    10.7 +  void SkeletonSolverBase::_messageLevel(MessageLevel) {}
    10.8 +
    10.9    LpSkeleton::SolveExitStatus LpSkeleton::_solve() { return SOLVED; }
   10.10  
   10.11    LpSkeleton::Value LpSkeleton::_getPrimal(int) const { return 0; }
    11.1 --- a/lemon/lp_skeleton.h	Tue Apr 07 14:50:20 2009 +0100
    11.2 +++ b/lemon/lp_skeleton.h	Wed Apr 08 22:49:28 2009 +0200
    11.3 @@ -140,6 +140,8 @@
    11.4      ///\e
    11.5      virtual void _clear();
    11.6  
    11.7 +    ///\e
    11.8 +    virtual void _messageLevel(MessageLevel);
    11.9    };
   11.10  
   11.11    /// \brief Skeleton class for an LP solver interface
    12.1 --- a/lemon/soplex.cc	Tue Apr 07 14:50:20 2009 +0100
    12.2 +++ b/lemon/soplex.cc	Wed Apr 08 22:49:28 2009 +0200
    12.3 @@ -20,6 +20,7 @@
    12.4  #include <lemon/soplex.h>
    12.5  
    12.6  #include <soplex.h>
    12.7 +#include <spxout.h>
    12.8  
    12.9  
   12.10  ///\file
   12.11 @@ -28,6 +29,7 @@
   12.12  
   12.13    SoplexLp::SoplexLp() {
   12.14      soplex = new soplex::SoPlex;
   12.15 +    messageLevel(MESSAGE_NOTHING);
   12.16    }
   12.17  
   12.18    SoplexLp::~SoplexLp() {
   12.19 @@ -47,6 +49,7 @@
   12.20      _row_names = lp._row_names;
   12.21      _row_names_ref = lp._row_names_ref;
   12.22  
   12.23 +    messageLevel(MESSAGE_NOTHING);
   12.24    }
   12.25  
   12.26    void SoplexLp::_clear_temporals() {
   12.27 @@ -271,6 +274,8 @@
   12.28    SoplexLp::SolveExitStatus SoplexLp::_solve() {
   12.29  
   12.30      _clear_temporals();
   12.31 +    
   12.32 +    _applyMessageLevel();
   12.33  
   12.34      soplex::SPxSolver::Status status = soplex->solve();
   12.35  
   12.36 @@ -419,5 +424,29 @@
   12.37      _clear_temporals();
   12.38    }
   12.39  
   12.40 +  void SoplexLp::_messageLevel(MessageLevel level) {
   12.41 +    switch (level) {
   12.42 +    case MESSAGE_NOTHING:
   12.43 +      _message_level = -1;
   12.44 +      break;
   12.45 +    case MESSAGE_ERROR:
   12.46 +      _message_level = soplex::SPxOut::ERROR;
   12.47 +      break;
   12.48 +    case MESSAGE_WARNING:
   12.49 +      _message_level = soplex::SPxOut::WARNING;
   12.50 +      break;
   12.51 +    case MESSAGE_NORMAL:
   12.52 +      _message_level = soplex::SPxOut::INFO2;
   12.53 +      break;
   12.54 +    case MESSAGE_VERBOSE:
   12.55 +      _message_level = soplex::SPxOut::DEBUG;
   12.56 +      break;
   12.57 +    }
   12.58 +  }
   12.59 +
   12.60 +  void SoplexLp::_applyMessageLevel() {
   12.61 +    soplex::Param::setVerbose(_message_level);
   12.62 +  }
   12.63 +
   12.64  } //namespace lemon
   12.65  
    13.1 --- a/lemon/soplex.h	Tue Apr 07 14:50:20 2009 +0100
    13.2 +++ b/lemon/soplex.h	Wed Apr 08 22:49:28 2009 +0200
    13.3 @@ -144,6 +144,11 @@
    13.4  
    13.5      virtual void _clear();
    13.6  
    13.7 +    void _messageLevel(MessageLevel m);
    13.8 +    void _applyMessageLevel();
    13.9 +
   13.10 +    int _message_level;
   13.11 +
   13.12    };
   13.13  
   13.14  } //END OF NAMESPACE LEMON