lemon/glpk.cc
changeset 568 745e182d0139
parent 558 e7017ec2d5cd
child 785 8d281761dea4
     1.1 --- a/lemon/glpk.cc	Tue Apr 07 14:50:20 2009 +0100
     1.2 +++ b/lemon/glpk.cc	Wed Apr 08 22:49:28 2009 +0200
     1.3 @@ -31,6 +31,7 @@
     1.4    GlpkBase::GlpkBase() : LpBase() {
     1.5      lp = glp_create_prob();
     1.6      glp_create_index(lp);
     1.7 +    messageLevel(MESSAGE_NOTHING);
     1.8    }
     1.9  
    1.10    GlpkBase::GlpkBase(const GlpkBase &other) : LpBase() {
    1.11 @@ -39,6 +40,7 @@
    1.12      glp_create_index(lp);
    1.13      rows = other.rows;
    1.14      cols = other.cols;
    1.15 +    messageLevel(MESSAGE_NOTHING);
    1.16    }
    1.17  
    1.18    GlpkBase::~GlpkBase() {
    1.19 @@ -526,19 +528,37 @@
    1.20      glp_free_env();
    1.21    }
    1.22  
    1.23 +  void GlpkBase::_messageLevel(MessageLevel level) {
    1.24 +    switch (level) {
    1.25 +    case MESSAGE_NOTHING:
    1.26 +      _message_level = GLP_MSG_OFF;
    1.27 +      break;
    1.28 +    case MESSAGE_ERROR:
    1.29 +      _message_level = GLP_MSG_ERR;
    1.30 +      break;
    1.31 +    case MESSAGE_WARNING:
    1.32 +      _message_level = GLP_MSG_ERR;
    1.33 +      break;
    1.34 +    case MESSAGE_NORMAL:
    1.35 +      _message_level = GLP_MSG_ON;
    1.36 +      break;
    1.37 +    case MESSAGE_VERBOSE:
    1.38 +      _message_level = GLP_MSG_ALL;
    1.39 +      break;
    1.40 +    }
    1.41 +  }
    1.42 +
    1.43    GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;
    1.44  
    1.45    // GlpkLp members
    1.46  
    1.47    GlpkLp::GlpkLp()
    1.48      : LpBase(), LpSolver(), GlpkBase() {
    1.49 -    messageLevel(MESSAGE_NO_OUTPUT);
    1.50      presolver(false);
    1.51    }
    1.52  
    1.53    GlpkLp::GlpkLp(const GlpkLp& other)
    1.54      : LpBase(other), LpSolver(other), GlpkBase(other) {
    1.55 -    messageLevel(MESSAGE_NO_OUTPUT);
    1.56      presolver(false);
    1.57    }
    1.58  
    1.59 @@ -562,20 +582,7 @@
    1.60      glp_smcp smcp;
    1.61      glp_init_smcp(&smcp);
    1.62  
    1.63 -    switch (_message_level) {
    1.64 -    case MESSAGE_NO_OUTPUT:
    1.65 -      smcp.msg_lev = GLP_MSG_OFF;
    1.66 -      break;
    1.67 -    case MESSAGE_ERROR_MESSAGE:
    1.68 -      smcp.msg_lev = GLP_MSG_ERR;
    1.69 -      break;
    1.70 -    case MESSAGE_NORMAL_OUTPUT:
    1.71 -      smcp.msg_lev = GLP_MSG_ON;
    1.72 -      break;
    1.73 -    case MESSAGE_FULL_OUTPUT:
    1.74 -      smcp.msg_lev = GLP_MSG_ALL;
    1.75 -      break;
    1.76 -    }
    1.77 +    smcp.msg_lev = _message_level;
    1.78      smcp.presolve = _presolve;
    1.79  
    1.80      // If the basis is not valid we get an error return value.
    1.81 @@ -604,20 +611,7 @@
    1.82      glp_smcp smcp;
    1.83      glp_init_smcp(&smcp);
    1.84  
    1.85 -    switch (_message_level) {
    1.86 -    case MESSAGE_NO_OUTPUT:
    1.87 -      smcp.msg_lev = GLP_MSG_OFF;
    1.88 -      break;
    1.89 -    case MESSAGE_ERROR_MESSAGE:
    1.90 -      smcp.msg_lev = GLP_MSG_ERR;
    1.91 -      break;
    1.92 -    case MESSAGE_NORMAL_OUTPUT:
    1.93 -      smcp.msg_lev = GLP_MSG_ON;
    1.94 -      break;
    1.95 -    case MESSAGE_FULL_OUTPUT:
    1.96 -      smcp.msg_lev = GLP_MSG_ALL;
    1.97 -      break;
    1.98 -    }
    1.99 +    smcp.msg_lev = _message_level;
   1.100      smcp.meth = GLP_DUAL;
   1.101      smcp.presolve = _presolve;
   1.102  
   1.103 @@ -858,20 +852,14 @@
   1.104      _presolve = presolve;
   1.105    }
   1.106  
   1.107 -  void GlpkLp::messageLevel(MessageLevel m) {
   1.108 -    _message_level = m;
   1.109 -  }
   1.110 -
   1.111    // GlpkMip members
   1.112  
   1.113    GlpkMip::GlpkMip()
   1.114      : LpBase(), MipSolver(), GlpkBase() {
   1.115 -    messageLevel(MESSAGE_NO_OUTPUT);
   1.116    }
   1.117  
   1.118    GlpkMip::GlpkMip(const GlpkMip& other)
   1.119      : LpBase(), MipSolver(), GlpkBase(other) {
   1.120 -    messageLevel(MESSAGE_NO_OUTPUT);
   1.121    }
   1.122  
   1.123    void GlpkMip::_setColType(int i, GlpkMip::ColTypes col_type) {
   1.124 @@ -900,20 +888,7 @@
   1.125      glp_smcp smcp;
   1.126      glp_init_smcp(&smcp);
   1.127  
   1.128 -    switch (_message_level) {
   1.129 -    case MESSAGE_NO_OUTPUT:
   1.130 -      smcp.msg_lev = GLP_MSG_OFF;
   1.131 -      break;
   1.132 -    case MESSAGE_ERROR_MESSAGE:
   1.133 -      smcp.msg_lev = GLP_MSG_ERR;
   1.134 -      break;
   1.135 -    case MESSAGE_NORMAL_OUTPUT:
   1.136 -      smcp.msg_lev = GLP_MSG_ON;
   1.137 -      break;
   1.138 -    case MESSAGE_FULL_OUTPUT:
   1.139 -      smcp.msg_lev = GLP_MSG_ALL;
   1.140 -      break;
   1.141 -    }
   1.142 +    smcp.msg_lev = _message_level;
   1.143      smcp.meth = GLP_DUAL;
   1.144  
   1.145      // If the basis is not valid we get an error return value.
   1.146 @@ -938,20 +913,7 @@
   1.147      glp_iocp iocp;
   1.148      glp_init_iocp(&iocp);
   1.149  
   1.150 -    switch (_message_level) {
   1.151 -    case MESSAGE_NO_OUTPUT:
   1.152 -      iocp.msg_lev = GLP_MSG_OFF;
   1.153 -      break;
   1.154 -    case MESSAGE_ERROR_MESSAGE:
   1.155 -      iocp.msg_lev = GLP_MSG_ERR;
   1.156 -      break;
   1.157 -    case MESSAGE_NORMAL_OUTPUT:
   1.158 -      iocp.msg_lev = GLP_MSG_ON;
   1.159 -      break;
   1.160 -    case MESSAGE_FULL_OUTPUT:
   1.161 -      iocp.msg_lev = GLP_MSG_ALL;
   1.162 -      break;
   1.163 -    }
   1.164 +    iocp.msg_lev = _message_level;
   1.165  
   1.166      if (glp_intopt(lp, &iocp) != 0) return UNSOLVED;
   1.167      return SOLVED;
   1.168 @@ -1002,8 +964,4 @@
   1.169  
   1.170    const char* GlpkMip::_solverName() const { return "GlpkMip"; }
   1.171  
   1.172 -  void GlpkMip::messageLevel(MessageLevel m) {
   1.173 -    _message_level = m;
   1.174 -  }
   1.175 -
   1.176  } //END OF NAMESPACE LEMON