lemon/soplex.cc
changeset 783 ef88c0a30f85
parent 576 745e182d0139
child 877 141f9c0db4a3
     1.1 --- a/lemon/soplex.cc	Mon Jan 12 23:11:39 2009 +0100
     1.2 +++ b/lemon/soplex.cc	Thu Nov 05 15:48:01 2009 +0100
     1.3 @@ -19,7 +19,8 @@
     1.4  #include <iostream>
     1.5  #include <lemon/soplex.h>
     1.6  
     1.7 -#include <soplex/soplex.h>
     1.8 +#include <soplex.h>
     1.9 +#include <spxout.h>
    1.10  
    1.11  
    1.12  ///\file
    1.13 @@ -28,6 +29,7 @@
    1.14  
    1.15    SoplexLp::SoplexLp() {
    1.16      soplex = new soplex::SoPlex;
    1.17 +    messageLevel(MESSAGE_NOTHING);
    1.18    }
    1.19  
    1.20    SoplexLp::~SoplexLp() {
    1.21 @@ -47,6 +49,7 @@
    1.22      _row_names = lp._row_names;
    1.23      _row_names_ref = lp._row_names_ref;
    1.24  
    1.25 +    messageLevel(MESSAGE_NOTHING);
    1.26    }
    1.27  
    1.28    void SoplexLp::_clear_temporals() {
    1.29 @@ -54,12 +57,12 @@
    1.30      _dual_values.clear();
    1.31    }
    1.32  
    1.33 -  SoplexLp* SoplexLp::_newSolver() const {
    1.34 +  SoplexLp* SoplexLp::newSolver() const {
    1.35      SoplexLp* newlp = new SoplexLp();
    1.36      return newlp;
    1.37    }
    1.38  
    1.39 -  SoplexLp* SoplexLp::_cloneSolver() const {
    1.40 +  SoplexLp* SoplexLp::cloneSolver() const {
    1.41      SoplexLp* newlp = new SoplexLp(*this);
    1.42      return newlp;
    1.43    }
    1.44 @@ -88,6 +91,19 @@
    1.45      return soplex->nRows() - 1;
    1.46    }
    1.47  
    1.48 +  int SoplexLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
    1.49 +    soplex::DSVector v;
    1.50 +    for (ExprIterator it = b; it != e; ++it) {
    1.51 +      v.add(it->first, it->second);
    1.52 +    }
    1.53 +    soplex::LPRow r(l, v, u);
    1.54 +    soplex->addRow(r);
    1.55 +
    1.56 +    _row_names.push_back(std::string());
    1.57 +
    1.58 +    return soplex->nRows() - 1;
    1.59 +  }
    1.60 +
    1.61  
    1.62    void SoplexLp::_eraseCol(int i) {
    1.63      soplex->removeCol(i);
    1.64 @@ -271,6 +287,8 @@
    1.65    SoplexLp::SolveExitStatus SoplexLp::_solve() {
    1.66  
    1.67      _clear_temporals();
    1.68 +    
    1.69 +    _applyMessageLevel();
    1.70  
    1.71      soplex::SPxSolver::Status status = soplex->solve();
    1.72  
    1.73 @@ -419,5 +437,29 @@
    1.74      _clear_temporals();
    1.75    }
    1.76  
    1.77 +  void SoplexLp::_messageLevel(MessageLevel level) {
    1.78 +    switch (level) {
    1.79 +    case MESSAGE_NOTHING:
    1.80 +      _message_level = -1;
    1.81 +      break;
    1.82 +    case MESSAGE_ERROR:
    1.83 +      _message_level = soplex::SPxOut::ERROR;
    1.84 +      break;
    1.85 +    case MESSAGE_WARNING:
    1.86 +      _message_level = soplex::SPxOut::WARNING;
    1.87 +      break;
    1.88 +    case MESSAGE_NORMAL:
    1.89 +      _message_level = soplex::SPxOut::INFO2;
    1.90 +      break;
    1.91 +    case MESSAGE_VERBOSE:
    1.92 +      _message_level = soplex::SPxOut::DEBUG;
    1.93 +      break;
    1.94 +    }
    1.95 +  }
    1.96 +
    1.97 +  void SoplexLp::_applyMessageLevel() {
    1.98 +    soplex::Param::setVerbose(_message_level);
    1.99 +  }
   1.100 +
   1.101  } //namespace lemon
   1.102