COIN-OR::LEMON - Graph Library

Changeset 576:745e182d0139 in lemon-1.2 for lemon/glpk.cc


Ignore:
Timestamp:
04/08/09 22:49:28 (11 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

Unified message handling for LP and MIP solvers (#9)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/glpk.cc

    r566 r576  
    3232    lp = glp_create_prob();
    3333    glp_create_index(lp);
     34    messageLevel(MESSAGE_NOTHING);
    3435  }
    3536
     
    4041    rows = other.rows;
    4142    cols = other.cols;
     43    messageLevel(MESSAGE_NOTHING);
    4244  }
    4345
     
    527529  }
    528530
     531  void GlpkBase::_messageLevel(MessageLevel level) {
     532    switch (level) {
     533    case MESSAGE_NOTHING:
     534      _message_level = GLP_MSG_OFF;
     535      break;
     536    case MESSAGE_ERROR:
     537      _message_level = GLP_MSG_ERR;
     538      break;
     539    case MESSAGE_WARNING:
     540      _message_level = GLP_MSG_ERR;
     541      break;
     542    case MESSAGE_NORMAL:
     543      _message_level = GLP_MSG_ON;
     544      break;
     545    case MESSAGE_VERBOSE:
     546      _message_level = GLP_MSG_ALL;
     547      break;
     548    }
     549  }
     550
    529551  GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;
    530552
     
    533555  GlpkLp::GlpkLp()
    534556    : LpBase(), LpSolver(), GlpkBase() {
    535     messageLevel(MESSAGE_NO_OUTPUT);
    536557    presolver(false);
    537558  }
     
    539560  GlpkLp::GlpkLp(const GlpkLp& other)
    540561    : LpBase(other), LpSolver(other), GlpkBase(other) {
    541     messageLevel(MESSAGE_NO_OUTPUT);
    542562    presolver(false);
    543563  }
     
    563583    glp_init_smcp(&smcp);
    564584
    565     switch (_message_level) {
    566     case MESSAGE_NO_OUTPUT:
    567       smcp.msg_lev = GLP_MSG_OFF;
    568       break;
    569     case MESSAGE_ERROR_MESSAGE:
    570       smcp.msg_lev = GLP_MSG_ERR;
    571       break;
    572     case MESSAGE_NORMAL_OUTPUT:
    573       smcp.msg_lev = GLP_MSG_ON;
    574       break;
    575     case MESSAGE_FULL_OUTPUT:
    576       smcp.msg_lev = GLP_MSG_ALL;
    577       break;
    578     }
     585    smcp.msg_lev = _message_level;
    579586    smcp.presolve = _presolve;
    580587
     
    605612    glp_init_smcp(&smcp);
    606613
    607     switch (_message_level) {
    608     case MESSAGE_NO_OUTPUT:
    609       smcp.msg_lev = GLP_MSG_OFF;
    610       break;
    611     case MESSAGE_ERROR_MESSAGE:
    612       smcp.msg_lev = GLP_MSG_ERR;
    613       break;
    614     case MESSAGE_NORMAL_OUTPUT:
    615       smcp.msg_lev = GLP_MSG_ON;
    616       break;
    617     case MESSAGE_FULL_OUTPUT:
    618       smcp.msg_lev = GLP_MSG_ALL;
    619       break;
    620     }
     614    smcp.msg_lev = _message_level;
    621615    smcp.meth = GLP_DUAL;
    622616    smcp.presolve = _presolve;
     
    859853  }
    860854
    861   void GlpkLp::messageLevel(MessageLevel m) {
    862     _message_level = m;
    863   }
    864 
    865855  // GlpkMip members
    866856
    867857  GlpkMip::GlpkMip()
    868858    : LpBase(), MipSolver(), GlpkBase() {
    869     messageLevel(MESSAGE_NO_OUTPUT);
    870859  }
    871860
    872861  GlpkMip::GlpkMip(const GlpkMip& other)
    873862    : LpBase(), MipSolver(), GlpkBase(other) {
    874     messageLevel(MESSAGE_NO_OUTPUT);
    875863  }
    876864
     
    901889    glp_init_smcp(&smcp);
    902890
    903     switch (_message_level) {
    904     case MESSAGE_NO_OUTPUT:
    905       smcp.msg_lev = GLP_MSG_OFF;
    906       break;
    907     case MESSAGE_ERROR_MESSAGE:
    908       smcp.msg_lev = GLP_MSG_ERR;
    909       break;
    910     case MESSAGE_NORMAL_OUTPUT:
    911       smcp.msg_lev = GLP_MSG_ON;
    912       break;
    913     case MESSAGE_FULL_OUTPUT:
    914       smcp.msg_lev = GLP_MSG_ALL;
    915       break;
    916     }
     891    smcp.msg_lev = _message_level;
    917892    smcp.meth = GLP_DUAL;
    918893
     
    939914    glp_init_iocp(&iocp);
    940915
    941     switch (_message_level) {
    942     case MESSAGE_NO_OUTPUT:
    943       iocp.msg_lev = GLP_MSG_OFF;
    944       break;
    945     case MESSAGE_ERROR_MESSAGE:
    946       iocp.msg_lev = GLP_MSG_ERR;
    947       break;
    948     case MESSAGE_NORMAL_OUTPUT:
    949       iocp.msg_lev = GLP_MSG_ON;
    950       break;
    951     case MESSAGE_FULL_OUTPUT:
    952       iocp.msg_lev = GLP_MSG_ALL;
    953       break;
    954     }
     916    iocp.msg_lev = _message_level;
    955917
    956918    if (glp_intopt(lp, &iocp) != 0) return UNSOLVED;
     
    1003965  const char* GlpkMip::_solverName() const { return "GlpkMip"; }
    1004966
    1005   void GlpkMip::messageLevel(MessageLevel m) {
    1006     _message_level = m;
    1007   }
    1008 
    1009967} //END OF NAMESPACE LEMON
Note: See TracChangeset for help on using the changeset viewer.