COIN-OR::LEMON - Graph Library

Changeset 576:745e182d0139 in lemon-main for lemon/cplex.cc


Ignore:
Timestamp:
04/08/09 22:49:28 (15 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/cplex.cc

    r551 r576  
    7373    int status;
    7474    _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
     75    messageLevel(MESSAGE_NOTHING);
    7576  }
    7677
     
    7980    int status;
    8081    _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
     82    messageLevel(MESSAGE_NOTHING);
    8183  }
    8284
     
    8789    rows = cplex.rows;
    8890    cols = cplex.cols;
     91    messageLevel(MESSAGE_NOTHING);
    8992  }
    9093
     
    437440    rows.clear();
    438441    cols.clear();
     442  }
     443
     444  void CplexBase::_messageLevel(MessageLevel level) {
     445    switch (level) {
     446    case MESSAGE_NOTHING:
     447      _message_enabled = false;
     448      break;
     449    case MESSAGE_ERROR:
     450    case MESSAGE_WARNING:
     451    case MESSAGE_NORMAL:
     452    case MESSAGE_VERBOSE:
     453      _message_enabled = true;
     454      break;
     455    }
     456  }
     457
     458  void CplexBase::_applyMessageLevel() {
     459    CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND,
     460                   _message_enabled ? CPX_ON : CPX_OFF);
    439461  }
    440462
     
    508530  CplexLp::SolveExitStatus CplexLp::_solve() {
    509531    _clear_temporals();
     532    _applyMessageLevel();
    510533    return convertStatus(CPXlpopt(cplexEnv(), _prob));
    511534  }
     
    513536  CplexLp::SolveExitStatus CplexLp::solvePrimal() {
    514537    _clear_temporals();
     538    _applyMessageLevel();
    515539    return convertStatus(CPXprimopt(cplexEnv(), _prob));
    516540  }
     
    518542  CplexLp::SolveExitStatus CplexLp::solveDual() {
    519543    _clear_temporals();
     544    _applyMessageLevel();
    520545    return convertStatus(CPXdualopt(cplexEnv(), _prob));
    521546  }
     
    523548  CplexLp::SolveExitStatus CplexLp::solveBarrier() {
    524549    _clear_temporals();
     550    _applyMessageLevel();
    525551    return convertStatus(CPXbaropt(cplexEnv(), _prob));
    526552  }
     
    601627  }
    602628
    603   //7.5-os cplex statusai (Vigyazat: a 9.0-asei masok!)
     629  // Cplex 7.0 status values
    604630  // This table lists the statuses, returned by the CPXgetstat()
    605631  // routine, for solutions to LP problems or mixed integer problems. If
     
    648674  //       User pivot used
    649675  //
    650   //     Ezeket hova tegyem:
     676  // Pending return values
    651677  // ??case CPX_ABORT_DUAL_INFEAS
    652678  // ??case CPX_ABORT_CROSSOVER
     
    719745    statusSwitch(cplexEnv(),stat);
    720746    //CPXgetstat(cplexEnv(), _prob);
    721     //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
    722747    switch (stat) {
    723748    case 0:
     
    752777  }
    753778
    754   //9.0-as cplex verzio statusai
     779  // Cplex 9.0 status values
    755780  // CPX_STAT_ABORT_DUAL_OBJ_LIM
    756781  // CPX_STAT_ABORT_IT_LIM
     
    865890  CplexMip::SolveExitStatus CplexMip::_solve() {
    866891    int status;
     892    _applyMessageLevel();
    867893    status = CPXmipopt (cplexEnv(), _prob);
    868894    if (status==0)
Note: See TracChangeset for help on using the changeset viewer.