lemon/soplex.cc
changeset 462 9b082b3fb33f
parent 461 08d495d48089
child 539 547e966b3b29
     1.1 --- a/lemon/soplex.cc	Mon Jan 12 12:26:01 2009 +0000
     1.2 +++ b/lemon/soplex.cc	Mon Jan 12 12:26:02 2009 +0000
     1.3 @@ -26,15 +26,15 @@
     1.4  ///\brief Implementation of the LEMON-SOPLEX lp solver interface.
     1.5  namespace lemon {
     1.6  
     1.7 -  LpSoplex::LpSoplex() {
     1.8 +  SoplexLp::SoplexLp() {
     1.9      soplex = new soplex::SoPlex;
    1.10    }
    1.11  
    1.12 -  LpSoplex::~LpSoplex() {
    1.13 +  SoplexLp::~SoplexLp() {
    1.14      delete soplex;
    1.15    }
    1.16  
    1.17 -  LpSoplex::LpSoplex(const LpSoplex& lp) {
    1.18 +  SoplexLp::SoplexLp(const SoplexLp& lp) {
    1.19      rows = lp.rows;
    1.20      cols = lp.cols;
    1.21  
    1.22 @@ -49,24 +49,24 @@
    1.23  
    1.24    }
    1.25  
    1.26 -  void LpSoplex::_clear_temporals() {
    1.27 +  void SoplexLp::_clear_temporals() {
    1.28      _primal_values.clear();
    1.29      _dual_values.clear();
    1.30    }
    1.31  
    1.32 -  LpSoplex* LpSoplex::_newSolver() const {
    1.33 -    LpSoplex* newlp = new LpSoplex();
    1.34 +  SoplexLp* SoplexLp::_newSolver() const {
    1.35 +    SoplexLp* newlp = new SoplexLp();
    1.36      return newlp;
    1.37    }
    1.38  
    1.39 -  LpSoplex* LpSoplex::_cloneSolver() const {
    1.40 -    LpSoplex* newlp = new LpSoplex(*this);
    1.41 +  SoplexLp* SoplexLp::_cloneSolver() const {
    1.42 +    SoplexLp* newlp = new SoplexLp(*this);
    1.43      return newlp;
    1.44    }
    1.45  
    1.46 -  const char* LpSoplex::_solverName() const { return "LpSoplex"; }
    1.47 +  const char* SoplexLp::_solverName() const { return "SoplexLp"; }
    1.48  
    1.49 -  int LpSoplex::_addCol() {
    1.50 +  int SoplexLp::_addCol() {
    1.51      soplex::LPCol c;
    1.52      c.setLower(-soplex::infinity);
    1.53      c.setUpper(soplex::infinity);
    1.54 @@ -77,7 +77,7 @@
    1.55      return soplex->nCols() - 1;
    1.56    }
    1.57  
    1.58 -  int LpSoplex::_addRow() {
    1.59 +  int SoplexLp::_addRow() {
    1.60      soplex::LPRow r;
    1.61      r.setLhs(-soplex::infinity);
    1.62      r.setRhs(soplex::infinity);
    1.63 @@ -89,7 +89,7 @@
    1.64    }
    1.65  
    1.66  
    1.67 -  void LpSoplex::_eraseCol(int i) {
    1.68 +  void SoplexLp::_eraseCol(int i) {
    1.69      soplex->removeCol(i);
    1.70      _col_names_ref.erase(_col_names[i]);
    1.71      _col_names[i] = _col_names.back();
    1.72 @@ -97,7 +97,7 @@
    1.73      _col_names.pop_back();
    1.74    }
    1.75  
    1.76 -  void LpSoplex::_eraseRow(int i) {
    1.77 +  void SoplexLp::_eraseRow(int i) {
    1.78      soplex->removeRow(i);
    1.79      _row_names_ref.erase(_row_names[i]);
    1.80      _row_names[i] = _row_names.back();
    1.81 @@ -105,20 +105,20 @@
    1.82      _row_names.pop_back();
    1.83    }
    1.84  
    1.85 -  void LpSoplex::_eraseColId(int i) {
    1.86 +  void SoplexLp::_eraseColId(int i) {
    1.87      cols.eraseIndex(i);
    1.88      cols.relocateIndex(i, cols.maxIndex());
    1.89    }
    1.90 -  void LpSoplex::_eraseRowId(int i) {
    1.91 +  void SoplexLp::_eraseRowId(int i) {
    1.92      rows.eraseIndex(i);
    1.93      rows.relocateIndex(i, rows.maxIndex());
    1.94    }
    1.95  
    1.96 -  void LpSoplex::_getColName(int c, std::string &name) const {
    1.97 +  void SoplexLp::_getColName(int c, std::string &name) const {
    1.98      name = _col_names[c];
    1.99    }
   1.100  
   1.101 -  void LpSoplex::_setColName(int c, const std::string &name) {
   1.102 +  void SoplexLp::_setColName(int c, const std::string &name) {
   1.103      _col_names_ref.erase(_col_names[c]);
   1.104      _col_names[c] = name;
   1.105      if (!name.empty()) {
   1.106 @@ -126,7 +126,7 @@
   1.107      }
   1.108    }
   1.109  
   1.110 -  int LpSoplex::_colByName(const std::string& name) const {
   1.111 +  int SoplexLp::_colByName(const std::string& name) const {
   1.112      std::map<std::string, int>::const_iterator it =
   1.113        _col_names_ref.find(name);
   1.114      if (it != _col_names_ref.end()) {
   1.115 @@ -136,11 +136,11 @@
   1.116      }
   1.117    }
   1.118  
   1.119 -  void LpSoplex::_getRowName(int r, std::string &name) const {
   1.120 +  void SoplexLp::_getRowName(int r, std::string &name) const {
   1.121      name = _row_names[r];
   1.122    }
   1.123  
   1.124 -  void LpSoplex::_setRowName(int r, const std::string &name) {
   1.125 +  void SoplexLp::_setRowName(int r, const std::string &name) {
   1.126      _row_names_ref.erase(_row_names[r]);
   1.127      _row_names[r] = name;
   1.128      if (!name.empty()) {
   1.129 @@ -148,7 +148,7 @@
   1.130      }
   1.131    }
   1.132  
   1.133 -  int LpSoplex::_rowByName(const std::string& name) const {
   1.134 +  int SoplexLp::_rowByName(const std::string& name) const {
   1.135      std::map<std::string, int>::const_iterator it =
   1.136        _row_names_ref.find(name);
   1.137      if (it != _row_names_ref.end()) {
   1.138 @@ -159,7 +159,7 @@
   1.139    }
   1.140  
   1.141  
   1.142 -  void LpSoplex::_setRowCoeffs(int i, ExprIterator b, ExprIterator e) {
   1.143 +  void SoplexLp::_setRowCoeffs(int i, ExprIterator b, ExprIterator e) {
   1.144      for (int j = 0; j < soplex->nCols(); ++j) {
   1.145        soplex->changeElement(i, j, 0.0);
   1.146      }
   1.147 @@ -168,7 +168,7 @@
   1.148      }
   1.149    }
   1.150  
   1.151 -  void LpSoplex::_getRowCoeffs(int i, InsertIterator b) const {
   1.152 +  void SoplexLp::_getRowCoeffs(int i, InsertIterator b) const {
   1.153      const soplex::SVector& vec = soplex->rowVector(i);
   1.154      for (int k = 0; k < vec.size(); ++k) {
   1.155        *b = std::make_pair(vec.index(k), vec.value(k));
   1.156 @@ -176,7 +176,7 @@
   1.157      }
   1.158    }
   1.159  
   1.160 -  void LpSoplex::_setColCoeffs(int j, ExprIterator b, ExprIterator e) {
   1.161 +  void SoplexLp::_setColCoeffs(int j, ExprIterator b, ExprIterator e) {
   1.162      for (int i = 0; i < soplex->nRows(); ++i) {
   1.163        soplex->changeElement(i, j, 0.0);
   1.164      }
   1.165 @@ -185,7 +185,7 @@
   1.166      }
   1.167    }
   1.168  
   1.169 -  void LpSoplex::_getColCoeffs(int i, InsertIterator b) const {
   1.170 +  void SoplexLp::_getColCoeffs(int i, InsertIterator b) const {
   1.171      const soplex::SVector& vec = soplex->colVector(i);
   1.172      for (int k = 0; k < vec.size(); ++k) {
   1.173        *b = std::make_pair(vec.index(k), vec.value(k));
   1.174 @@ -193,55 +193,55 @@
   1.175      }
   1.176    }
   1.177  
   1.178 -  void LpSoplex::_setCoeff(int i, int j, Value value) {
   1.179 +  void SoplexLp::_setCoeff(int i, int j, Value value) {
   1.180      soplex->changeElement(i, j, value);
   1.181    }
   1.182  
   1.183 -  LpSoplex::Value LpSoplex::_getCoeff(int i, int j) const {
   1.184 +  SoplexLp::Value SoplexLp::_getCoeff(int i, int j) const {
   1.185      return soplex->rowVector(i)[j];
   1.186    }
   1.187  
   1.188 -  void LpSoplex::_setColLowerBound(int i, Value value) {
   1.189 +  void SoplexLp::_setColLowerBound(int i, Value value) {
   1.190      LEMON_ASSERT(value != INF, "Invalid bound");
   1.191      soplex->changeLower(i, value != -INF ? value : -soplex::infinity);
   1.192    }
   1.193  
   1.194 -  LpSoplex::Value LpSoplex::_getColLowerBound(int i) const {
   1.195 +  SoplexLp::Value SoplexLp::_getColLowerBound(int i) const {
   1.196      double value = soplex->lower(i);
   1.197      return value != -soplex::infinity ? value : -INF;
   1.198    }
   1.199  
   1.200 -  void LpSoplex::_setColUpperBound(int i, Value value) {
   1.201 +  void SoplexLp::_setColUpperBound(int i, Value value) {
   1.202      LEMON_ASSERT(value != -INF, "Invalid bound");
   1.203      soplex->changeUpper(i, value != INF ? value : soplex::infinity);
   1.204    }
   1.205  
   1.206 -  LpSoplex::Value LpSoplex::_getColUpperBound(int i) const {
   1.207 +  SoplexLp::Value SoplexLp::_getColUpperBound(int i) const {
   1.208      double value = soplex->upper(i);
   1.209      return value != soplex::infinity ? value : INF;
   1.210    }
   1.211  
   1.212 -  void LpSoplex::_setRowLowerBound(int i, Value lb) {
   1.213 +  void SoplexLp::_setRowLowerBound(int i, Value lb) {
   1.214      LEMON_ASSERT(lb != INF, "Invalid bound");
   1.215      soplex->changeRange(i, lb != -INF ? lb : -soplex::infinity, soplex->rhs(i));
   1.216    }
   1.217  
   1.218 -  LpSoplex::Value LpSoplex::_getRowLowerBound(int i) const {
   1.219 +  SoplexLp::Value SoplexLp::_getRowLowerBound(int i) const {
   1.220      double res = soplex->lhs(i);
   1.221      return res == -soplex::infinity ? -INF : res;
   1.222    }
   1.223  
   1.224 -  void LpSoplex::_setRowUpperBound(int i, Value ub) {
   1.225 +  void SoplexLp::_setRowUpperBound(int i, Value ub) {
   1.226      LEMON_ASSERT(ub != -INF, "Invalid bound");
   1.227      soplex->changeRange(i, soplex->lhs(i), ub != INF ? ub : soplex::infinity);
   1.228    }
   1.229  
   1.230 -  LpSoplex::Value LpSoplex::_getRowUpperBound(int i) const {
   1.231 +  SoplexLp::Value SoplexLp::_getRowUpperBound(int i) const {
   1.232      double res = soplex->rhs(i);
   1.233      return res == soplex::infinity ? INF : res;
   1.234    }
   1.235  
   1.236 -  void LpSoplex::_setObjCoeffs(ExprIterator b, ExprIterator e) {
   1.237 +  void SoplexLp::_setObjCoeffs(ExprIterator b, ExprIterator e) {
   1.238      for (int j = 0; j < soplex->nCols(); ++j) {
   1.239        soplex->changeObj(j, 0.0);
   1.240      }
   1.241 @@ -250,7 +250,7 @@
   1.242      }
   1.243    }
   1.244  
   1.245 -  void LpSoplex::_getObjCoeffs(InsertIterator b) const {
   1.246 +  void SoplexLp::_getObjCoeffs(InsertIterator b) const {
   1.247      for (int j = 0; j < soplex->nCols(); ++j) {
   1.248        Value coef = soplex->obj(j);
   1.249        if (coef != 0.0) {
   1.250 @@ -260,15 +260,15 @@
   1.251      }
   1.252    }
   1.253  
   1.254 -  void LpSoplex::_setObjCoeff(int i, Value obj_coef) {
   1.255 +  void SoplexLp::_setObjCoeff(int i, Value obj_coef) {
   1.256      soplex->changeObj(i, obj_coef);
   1.257    }
   1.258  
   1.259 -  LpSoplex::Value LpSoplex::_getObjCoeff(int i) const {
   1.260 +  SoplexLp::Value SoplexLp::_getObjCoeff(int i) const {
   1.261      return soplex->obj(i);
   1.262    }
   1.263  
   1.264 -  LpSoplex::SolveExitStatus LpSoplex::_solve() {
   1.265 +  SoplexLp::SolveExitStatus SoplexLp::_solve() {
   1.266  
   1.267      _clear_temporals();
   1.268  
   1.269 @@ -284,7 +284,7 @@
   1.270      }
   1.271    }
   1.272  
   1.273 -  LpSoplex::Value LpSoplex::_getPrimal(int i) const {
   1.274 +  SoplexLp::Value SoplexLp::_getPrimal(int i) const {
   1.275      if (_primal_values.empty()) {
   1.276        _primal_values.resize(soplex->nCols());
   1.277        soplex::Vector pv(_primal_values.size(), &_primal_values.front());
   1.278 @@ -293,7 +293,7 @@
   1.279      return _primal_values[i];
   1.280    }
   1.281  
   1.282 -  LpSoplex::Value LpSoplex::_getDual(int i) const {
   1.283 +  SoplexLp::Value SoplexLp::_getDual(int i) const {
   1.284      if (_dual_values.empty()) {
   1.285        _dual_values.resize(soplex->nRows());
   1.286        soplex::Vector dv(_dual_values.size(), &_dual_values.front());
   1.287 @@ -302,11 +302,11 @@
   1.288      return _dual_values[i];
   1.289    }
   1.290  
   1.291 -  LpSoplex::Value LpSoplex::_getPrimalValue() const {
   1.292 +  SoplexLp::Value SoplexLp::_getPrimalValue() const {
   1.293      return soplex->objValue();
   1.294    }
   1.295  
   1.296 -  LpSoplex::VarStatus LpSoplex::_getColStatus(int i) const {
   1.297 +  SoplexLp::VarStatus SoplexLp::_getColStatus(int i) const {
   1.298      switch (soplex->getBasisColStatus(i)) {
   1.299      case soplex::SPxSolver::BASIC:
   1.300        return BASIC;
   1.301 @@ -324,7 +324,7 @@
   1.302      }
   1.303    }
   1.304  
   1.305 -  LpSoplex::VarStatus LpSoplex::_getRowStatus(int i) const {
   1.306 +  SoplexLp::VarStatus SoplexLp::_getRowStatus(int i) const {
   1.307      switch (soplex->getBasisRowStatus(i)) {
   1.308      case soplex::SPxSolver::BASIC:
   1.309        return BASIC;
   1.310 @@ -342,7 +342,7 @@
   1.311      }
   1.312    }
   1.313  
   1.314 -  LpSoplex::Value LpSoplex::_getPrimalRay(int i) const {
   1.315 +  SoplexLp::Value SoplexLp::_getPrimalRay(int i) const {
   1.316      if (_primal_ray.empty()) {
   1.317        _primal_ray.resize(soplex->nCols());
   1.318        soplex::Vector pv(_primal_ray.size(), &_primal_ray.front());
   1.319 @@ -351,7 +351,7 @@
   1.320      return _primal_ray[i];
   1.321    }
   1.322  
   1.323 -  LpSoplex::Value LpSoplex::_getDualRay(int i) const {
   1.324 +  SoplexLp::Value SoplexLp::_getDualRay(int i) const {
   1.325      if (_dual_ray.empty()) {
   1.326        _dual_ray.resize(soplex->nRows());
   1.327        soplex::Vector dv(_dual_ray.size(), &_dual_ray.front());
   1.328 @@ -360,7 +360,7 @@
   1.329      return _dual_ray[i];
   1.330    }
   1.331  
   1.332 -  LpSoplex::ProblemType LpSoplex::_getPrimalType() const {
   1.333 +  SoplexLp::ProblemType SoplexLp::_getPrimalType() const {
   1.334      switch (soplex->status()) {
   1.335      case soplex::SPxSolver::OPTIMAL:
   1.336        return OPTIMAL;
   1.337 @@ -373,7 +373,7 @@
   1.338      }
   1.339    }
   1.340  
   1.341 -  LpSoplex::ProblemType LpSoplex::_getDualType() const {
   1.342 +  SoplexLp::ProblemType SoplexLp::_getDualType() const {
   1.343      switch (soplex->status()) {
   1.344      case soplex::SPxSolver::OPTIMAL:
   1.345        return OPTIMAL;
   1.346 @@ -386,7 +386,7 @@
   1.347      }
   1.348    }
   1.349  
   1.350 -  void LpSoplex::_setSense(Sense sense) {
   1.351 +  void SoplexLp::_setSense(Sense sense) {
   1.352      switch (sense) {
   1.353      case MIN:
   1.354        soplex->changeSense(soplex::SPxSolver::MINIMIZE);
   1.355 @@ -396,7 +396,7 @@
   1.356      }
   1.357    }
   1.358  
   1.359 -  LpSoplex::Sense LpSoplex::_getSense() const {
   1.360 +  SoplexLp::Sense SoplexLp::_getSense() const {
   1.361      switch (soplex->spxSense()) {
   1.362      case soplex::SPxSolver::MAXIMIZE:
   1.363        return MAX;
   1.364 @@ -404,11 +404,11 @@
   1.365        return MIN;
   1.366      default:
   1.367        LEMON_ASSERT(false, "Wrong sense.");
   1.368 -      return LpSoplex::Sense();
   1.369 +      return SoplexLp::Sense();
   1.370      }
   1.371    }
   1.372  
   1.373 -  void LpSoplex::_clear() {
   1.374 +  void SoplexLp::_clear() {
   1.375      soplex->clear();
   1.376      _col_names.clear();
   1.377      _col_names_ref.clear();