lemon/cplex.cc
changeset 576 745e182d0139
parent 551 9d0d7e20f76d
child 746 e4554cd6b2bf
child 955 8d281761dea4
     1.1 --- a/lemon/cplex.cc	Tue Apr 07 14:50:20 2009 +0100
     1.2 +++ b/lemon/cplex.cc	Wed Apr 08 22:49:28 2009 +0200
     1.3 @@ -72,12 +72,14 @@
     1.4    CplexBase::CplexBase() : LpBase() {
     1.5      int status;
     1.6      _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
     1.7 +    messageLevel(MESSAGE_NOTHING);
     1.8    }
     1.9  
    1.10    CplexBase::CplexBase(const CplexEnv& env)
    1.11      : LpBase(), _env(env) {
    1.12      int status;
    1.13      _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
    1.14 +    messageLevel(MESSAGE_NOTHING);
    1.15    }
    1.16  
    1.17    CplexBase::CplexBase(const CplexBase& cplex)
    1.18 @@ -86,6 +88,7 @@
    1.19      _prob = CPXcloneprob(cplexEnv(), cplex._prob, &status);
    1.20      rows = cplex.rows;
    1.21      cols = cplex.cols;
    1.22 +    messageLevel(MESSAGE_NOTHING);
    1.23    }
    1.24  
    1.25    CplexBase::~CplexBase() {
    1.26 @@ -438,6 +441,25 @@
    1.27      cols.clear();
    1.28    }
    1.29  
    1.30 +  void CplexBase::_messageLevel(MessageLevel level) {
    1.31 +    switch (level) {
    1.32 +    case MESSAGE_NOTHING:
    1.33 +      _message_enabled = false;
    1.34 +      break;
    1.35 +    case MESSAGE_ERROR:
    1.36 +    case MESSAGE_WARNING:
    1.37 +    case MESSAGE_NORMAL:
    1.38 +    case MESSAGE_VERBOSE:
    1.39 +      _message_enabled = true;
    1.40 +      break;
    1.41 +    }
    1.42 +  }
    1.43 +
    1.44 +  void CplexBase::_applyMessageLevel() {
    1.45 +    CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, 
    1.46 +                   _message_enabled ? CPX_ON : CPX_OFF);
    1.47 +  }
    1.48 +
    1.49    // CplexLp members
    1.50  
    1.51    CplexLp::CplexLp()
    1.52 @@ -507,21 +529,25 @@
    1.53  
    1.54    CplexLp::SolveExitStatus CplexLp::_solve() {
    1.55      _clear_temporals();
    1.56 +    _applyMessageLevel();
    1.57      return convertStatus(CPXlpopt(cplexEnv(), _prob));
    1.58    }
    1.59  
    1.60    CplexLp::SolveExitStatus CplexLp::solvePrimal() {
    1.61      _clear_temporals();
    1.62 +    _applyMessageLevel();
    1.63      return convertStatus(CPXprimopt(cplexEnv(), _prob));
    1.64    }
    1.65  
    1.66    CplexLp::SolveExitStatus CplexLp::solveDual() {
    1.67      _clear_temporals();
    1.68 +    _applyMessageLevel();
    1.69      return convertStatus(CPXdualopt(cplexEnv(), _prob));
    1.70    }
    1.71  
    1.72    CplexLp::SolveExitStatus CplexLp::solveBarrier() {
    1.73      _clear_temporals();
    1.74 +    _applyMessageLevel();
    1.75      return convertStatus(CPXbaropt(cplexEnv(), _prob));
    1.76    }
    1.77  
    1.78 @@ -600,7 +626,7 @@
    1.79      return _dual_ray[i];
    1.80    }
    1.81  
    1.82 -  //7.5-os cplex statusai (Vigyazat: a 9.0-asei masok!)
    1.83 +  // Cplex 7.0 status values
    1.84    // This table lists the statuses, returned by the CPXgetstat()
    1.85    // routine, for solutions to LP problems or mixed integer problems. If
    1.86    // no solution exists, the return value is zero.
    1.87 @@ -647,7 +673,7 @@
    1.88    // 20   CPX_PIVOT
    1.89    //       User pivot used
    1.90    //
    1.91 -  //     Ezeket hova tegyem:
    1.92 +  // Pending return values
    1.93    // ??case CPX_ABORT_DUAL_INFEAS
    1.94    // ??case CPX_ABORT_CROSSOVER
    1.95    // ??case CPX_INForUNBD
    1.96 @@ -718,7 +744,6 @@
    1.97  #else
    1.98      statusSwitch(cplexEnv(),stat);
    1.99      //CPXgetstat(cplexEnv(), _prob);
   1.100 -    //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL);
   1.101      switch (stat) {
   1.102      case 0:
   1.103        return UNDEFINED; //Undefined
   1.104 @@ -751,7 +776,7 @@
   1.105  #endif
   1.106    }
   1.107  
   1.108 -  //9.0-as cplex verzio statusai
   1.109 +  // Cplex 9.0 status values
   1.110    // CPX_STAT_ABORT_DUAL_OBJ_LIM
   1.111    // CPX_STAT_ABORT_IT_LIM
   1.112    // CPX_STAT_ABORT_OBJ_LIM
   1.113 @@ -864,6 +889,7 @@
   1.114  
   1.115    CplexMip::SolveExitStatus CplexMip::_solve() {
   1.116      int status;
   1.117 +    _applyMessageLevel();
   1.118      status = CPXmipopt (cplexEnv(), _prob);
   1.119      if (status==0)
   1.120        return SOLVED;