lemon/clp.cc
changeset 462 9b082b3fb33f
parent 461 08d495d48089
child 528 9db62975c32b
     1.1 --- a/lemon/clp.cc	Mon Jan 12 12:26:01 2009 +0000
     1.2 +++ b/lemon/clp.cc	Mon Jan 12 12:26:02 2009 +0000
     1.3 @@ -21,13 +21,13 @@
     1.4  
     1.5  namespace lemon {
     1.6  
     1.7 -  LpClp::LpClp() {
     1.8 +  ClpLp::ClpLp() {
     1.9      _prob = new ClpSimplex();
    1.10      _init_temporals();
    1.11      messageLevel(MESSAGE_NO_OUTPUT);
    1.12    }
    1.13  
    1.14 -  LpClp::LpClp(const LpClp& other) {
    1.15 +  ClpLp::ClpLp(const ClpLp& other) {
    1.16      _prob = new ClpSimplex(*other._prob);
    1.17      rows = other.rows;
    1.18      cols = other.cols;
    1.19 @@ -35,17 +35,17 @@
    1.20      messageLevel(MESSAGE_NO_OUTPUT);
    1.21    }
    1.22  
    1.23 -  LpClp::~LpClp() {
    1.24 +  ClpLp::~ClpLp() {
    1.25      delete _prob;
    1.26      _clear_temporals();
    1.27    }
    1.28  
    1.29 -  void LpClp::_init_temporals() {
    1.30 +  void ClpLp::_init_temporals() {
    1.31      _primal_ray = 0;
    1.32      _dual_ray = 0;
    1.33    }
    1.34  
    1.35 -  void LpClp::_clear_temporals() {
    1.36 +  void ClpLp::_clear_temporals() {
    1.37      if (_primal_ray) {
    1.38        delete[] _primal_ray;
    1.39        _primal_ray = 0;
    1.40 @@ -56,79 +56,79 @@
    1.41      }
    1.42    }
    1.43  
    1.44 -  LpClp* LpClp::_newSolver() const {
    1.45 -    LpClp* newlp = new LpClp;
    1.46 +  ClpLp* ClpLp::_newSolver() const {
    1.47 +    ClpLp* newlp = new ClpLp;
    1.48      return newlp;
    1.49    }
    1.50  
    1.51 -  LpClp* LpClp::_cloneSolver() const {
    1.52 -    LpClp* copylp = new LpClp(*this);
    1.53 +  ClpLp* ClpLp::_cloneSolver() const {
    1.54 +    ClpLp* copylp = new ClpLp(*this);
    1.55      return copylp;
    1.56    }
    1.57  
    1.58 -  const char* LpClp::_solverName() const { return "LpClp"; }
    1.59 +  const char* ClpLp::_solverName() const { return "ClpLp"; }
    1.60  
    1.61 -  int LpClp::_addCol() {
    1.62 +  int ClpLp::_addCol() {
    1.63      _prob->addColumn(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX, 0.0);
    1.64      return _prob->numberColumns() - 1;
    1.65    }
    1.66  
    1.67 -  int LpClp::_addRow() {
    1.68 +  int ClpLp::_addRow() {
    1.69      _prob->addRow(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX);
    1.70      return _prob->numberRows() - 1;
    1.71    }
    1.72  
    1.73  
    1.74 -  void LpClp::_eraseCol(int c) {
    1.75 +  void ClpLp::_eraseCol(int c) {
    1.76      _col_names_ref.erase(_prob->getColumnName(c));
    1.77      _prob->deleteColumns(1, &c);
    1.78    }
    1.79  
    1.80 -  void LpClp::_eraseRow(int r) {
    1.81 +  void ClpLp::_eraseRow(int r) {
    1.82      _row_names_ref.erase(_prob->getRowName(r));
    1.83      _prob->deleteRows(1, &r);
    1.84    }
    1.85  
    1.86 -  void LpClp::_eraseColId(int i) {
    1.87 +  void ClpLp::_eraseColId(int i) {
    1.88      cols.eraseIndex(i);
    1.89      cols.shiftIndices(i);
    1.90    }
    1.91  
    1.92 -  void LpClp::_eraseRowId(int i) {
    1.93 +  void ClpLp::_eraseRowId(int i) {
    1.94      rows.eraseIndex(i);
    1.95      rows.shiftIndices(i);
    1.96    }
    1.97  
    1.98 -  void LpClp::_getColName(int c, std::string& name) const {
    1.99 +  void ClpLp::_getColName(int c, std::string& name) const {
   1.100      name = _prob->getColumnName(c);
   1.101    }
   1.102  
   1.103 -  void LpClp::_setColName(int c, const std::string& name) {
   1.104 +  void ClpLp::_setColName(int c, const std::string& name) {
   1.105      _prob->setColumnName(c, const_cast<std::string&>(name));
   1.106      _col_names_ref[name] = c;
   1.107    }
   1.108  
   1.109 -  int LpClp::_colByName(const std::string& name) const {
   1.110 +  int ClpLp::_colByName(const std::string& name) const {
   1.111      std::map<std::string, int>::const_iterator it = _col_names_ref.find(name);
   1.112      return it != _col_names_ref.end() ? it->second : -1;
   1.113    }
   1.114  
   1.115 -  void LpClp::_getRowName(int r, std::string& name) const {
   1.116 +  void ClpLp::_getRowName(int r, std::string& name) const {
   1.117      name = _prob->getRowName(r);
   1.118    }
   1.119  
   1.120 -  void LpClp::_setRowName(int r, const std::string& name) {
   1.121 +  void ClpLp::_setRowName(int r, const std::string& name) {
   1.122      _prob->setRowName(r, const_cast<std::string&>(name));
   1.123      _row_names_ref[name] = r;
   1.124    }
   1.125  
   1.126 -  int LpClp::_rowByName(const std::string& name) const {
   1.127 +  int ClpLp::_rowByName(const std::string& name) const {
   1.128      std::map<std::string, int>::const_iterator it = _row_names_ref.find(name);
   1.129      return it != _row_names_ref.end() ? it->second : -1;
   1.130    }
   1.131  
   1.132  
   1.133 -  void LpClp::_setRowCoeffs(int ix, ExprIterator b, ExprIterator e) {
   1.134 +  void ClpLp::_setRowCoeffs(int ix, ExprIterator b, ExprIterator e) {
   1.135      std::map<int, Value> coeffs;
   1.136  
   1.137      int n = _prob->clpMatrix()->getNumCols();
   1.138 @@ -156,7 +156,7 @@
   1.139      }
   1.140    }
   1.141  
   1.142 -  void LpClp::_getRowCoeffs(int ix, InsertIterator b) const {
   1.143 +  void ClpLp::_getRowCoeffs(int ix, InsertIterator b) const {
   1.144      int n = _prob->clpMatrix()->getNumCols();
   1.145  
   1.146      const int* indices = _prob->clpMatrix()->getIndices();
   1.147 @@ -173,7 +173,7 @@
   1.148      }
   1.149    }
   1.150  
   1.151 -  void LpClp::_setColCoeffs(int ix, ExprIterator b, ExprIterator e) {
   1.152 +  void ClpLp::_setColCoeffs(int ix, ExprIterator b, ExprIterator e) {
   1.153      std::map<int, Value> coeffs;
   1.154  
   1.155      CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix];
   1.156 @@ -196,7 +196,7 @@
   1.157      }
   1.158    }
   1.159  
   1.160 -  void LpClp::_getColCoeffs(int ix, InsertIterator b) const {
   1.161 +  void ClpLp::_getColCoeffs(int ix, InsertIterator b) const {
   1.162      CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix];
   1.163      CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ix];
   1.164  
   1.165 @@ -209,11 +209,11 @@
   1.166      }
   1.167    }
   1.168  
   1.169 -  void LpClp::_setCoeff(int ix, int jx, Value value) {
   1.170 +  void ClpLp::_setCoeff(int ix, int jx, Value value) {
   1.171      _prob->modifyCoefficient(ix, jx, value);
   1.172    }
   1.173  
   1.174 -  LpClp::Value LpClp::_getCoeff(int ix, int jx) const {
   1.175 +  ClpLp::Value ClpLp::_getCoeff(int ix, int jx) const {
   1.176      CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix];
   1.177      CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ix];
   1.178  
   1.179 @@ -228,43 +228,43 @@
   1.180      }
   1.181    }
   1.182  
   1.183 -  void LpClp::_setColLowerBound(int i, Value lo) {
   1.184 +  void ClpLp::_setColLowerBound(int i, Value lo) {
   1.185      _prob->setColumnLower(i, lo == - INF ? - COIN_DBL_MAX : lo);
   1.186    }
   1.187  
   1.188 -  LpClp::Value LpClp::_getColLowerBound(int i) const {
   1.189 +  ClpLp::Value ClpLp::_getColLowerBound(int i) const {
   1.190      double val = _prob->getColLower()[i];
   1.191      return val == - COIN_DBL_MAX ? - INF : val;
   1.192    }
   1.193  
   1.194 -  void LpClp::_setColUpperBound(int i, Value up) {
   1.195 +  void ClpLp::_setColUpperBound(int i, Value up) {
   1.196      _prob->setColumnUpper(i, up == INF ? COIN_DBL_MAX : up);
   1.197    }
   1.198  
   1.199 -  LpClp::Value LpClp::_getColUpperBound(int i) const {
   1.200 +  ClpLp::Value ClpLp::_getColUpperBound(int i) const {
   1.201      double val = _prob->getColUpper()[i];
   1.202      return val == COIN_DBL_MAX ? INF : val;
   1.203    }
   1.204  
   1.205 -  void LpClp::_setRowLowerBound(int i, Value lo) {
   1.206 +  void ClpLp::_setRowLowerBound(int i, Value lo) {
   1.207      _prob->setRowLower(i, lo == - INF ? - COIN_DBL_MAX : lo);
   1.208    }
   1.209  
   1.210 -  LpClp::Value LpClp::_getRowLowerBound(int i) const {
   1.211 +  ClpLp::Value ClpLp::_getRowLowerBound(int i) const {
   1.212      double val = _prob->getRowLower()[i];
   1.213      return val == - COIN_DBL_MAX ? - INF : val;
   1.214    }
   1.215  
   1.216 -  void LpClp::_setRowUpperBound(int i, Value up) {
   1.217 +  void ClpLp::_setRowUpperBound(int i, Value up) {
   1.218      _prob->setRowUpper(i, up == INF ? COIN_DBL_MAX : up);
   1.219    }
   1.220  
   1.221 -  LpClp::Value LpClp::_getRowUpperBound(int i) const {
   1.222 +  ClpLp::Value ClpLp::_getRowUpperBound(int i) const {
   1.223      double val = _prob->getRowUpper()[i];
   1.224      return val == COIN_DBL_MAX ? INF : val;
   1.225    }
   1.226  
   1.227 -  void LpClp::_setObjCoeffs(ExprIterator b, ExprIterator e) {
   1.228 +  void ClpLp::_setObjCoeffs(ExprIterator b, ExprIterator e) {
   1.229      int num = _prob->clpMatrix()->getNumCols();
   1.230      for (int i = 0; i < num; ++i) {
   1.231        _prob->setObjectiveCoefficient(i, 0.0);
   1.232 @@ -274,7 +274,7 @@
   1.233      }
   1.234    }
   1.235  
   1.236 -  void LpClp::_getObjCoeffs(InsertIterator b) const {
   1.237 +  void ClpLp::_getObjCoeffs(InsertIterator b) const {
   1.238      int num = _prob->clpMatrix()->getNumCols();
   1.239      for (int i = 0; i < num; ++i) {
   1.240        Value coef = _prob->getObjCoefficients()[i];
   1.241 @@ -285,42 +285,42 @@
   1.242      }
   1.243    }
   1.244  
   1.245 -  void LpClp::_setObjCoeff(int i, Value obj_coef) {
   1.246 +  void ClpLp::_setObjCoeff(int i, Value obj_coef) {
   1.247      _prob->setObjectiveCoefficient(i, obj_coef);
   1.248    }
   1.249  
   1.250 -  LpClp::Value LpClp::_getObjCoeff(int i) const {
   1.251 +  ClpLp::Value ClpLp::_getObjCoeff(int i) const {
   1.252      return _prob->getObjCoefficients()[i];
   1.253    }
   1.254  
   1.255 -  LpClp::SolveExitStatus LpClp::_solve() {
   1.256 +  ClpLp::SolveExitStatus ClpLp::_solve() {
   1.257      return _prob->primal() >= 0 ? SOLVED : UNSOLVED;
   1.258    }
   1.259  
   1.260 -  LpClp::SolveExitStatus LpClp::solvePrimal() {
   1.261 +  ClpLp::SolveExitStatus ClpLp::solvePrimal() {
   1.262      return _prob->primal() >= 0 ? SOLVED : UNSOLVED;
   1.263    }
   1.264  
   1.265 -  LpClp::SolveExitStatus LpClp::solveDual() {
   1.266 +  ClpLp::SolveExitStatus ClpLp::solveDual() {
   1.267      return _prob->dual() >= 0 ? SOLVED : UNSOLVED;
   1.268    }
   1.269  
   1.270 -  LpClp::SolveExitStatus LpClp::solveBarrier() {
   1.271 +  ClpLp::SolveExitStatus ClpLp::solveBarrier() {
   1.272      return _prob->barrier() >= 0 ? SOLVED : UNSOLVED;
   1.273    }
   1.274  
   1.275 -  LpClp::Value LpClp::_getPrimal(int i) const {
   1.276 +  ClpLp::Value ClpLp::_getPrimal(int i) const {
   1.277      return _prob->primalColumnSolution()[i];
   1.278    }
   1.279 -  LpClp::Value LpClp::_getPrimalValue() const {
   1.280 +  ClpLp::Value ClpLp::_getPrimalValue() const {
   1.281      return _prob->objectiveValue();
   1.282    }
   1.283  
   1.284 -  LpClp::Value LpClp::_getDual(int i) const {
   1.285 +  ClpLp::Value ClpLp::_getDual(int i) const {
   1.286      return _prob->dualRowSolution()[i];
   1.287    }
   1.288  
   1.289 -  LpClp::Value LpClp::_getPrimalRay(int i) const {
   1.290 +  ClpLp::Value ClpLp::_getPrimalRay(int i) const {
   1.291      if (!_primal_ray) {
   1.292        _primal_ray = _prob->unboundedRay();
   1.293        LEMON_ASSERT(_primal_ray != 0, "Primal ray is not provided");
   1.294 @@ -328,7 +328,7 @@
   1.295      return _primal_ray[i];
   1.296    }
   1.297  
   1.298 -  LpClp::Value LpClp::_getDualRay(int i) const {
   1.299 +  ClpLp::Value ClpLp::_getDualRay(int i) const {
   1.300      if (!_dual_ray) {
   1.301        _dual_ray = _prob->infeasibilityRay();
   1.302        LEMON_ASSERT(_dual_ray != 0, "Dual ray is not provided");
   1.303 @@ -336,7 +336,7 @@
   1.304      return _dual_ray[i];
   1.305    }
   1.306  
   1.307 -  LpClp::VarStatus LpClp::_getColStatus(int i) const {
   1.308 +  ClpLp::VarStatus ClpLp::_getColStatus(int i) const {
   1.309      switch (_prob->getColumnStatus(i)) {
   1.310      case ClpSimplex::basic:
   1.311        return BASIC;
   1.312 @@ -356,7 +356,7 @@
   1.313      }
   1.314    }
   1.315  
   1.316 -  LpClp::VarStatus LpClp::_getRowStatus(int i) const {
   1.317 +  ClpLp::VarStatus ClpLp::_getRowStatus(int i) const {
   1.318      switch (_prob->getColumnStatus(i)) {
   1.319      case ClpSimplex::basic:
   1.320        return BASIC;
   1.321 @@ -377,7 +377,7 @@
   1.322    }
   1.323  
   1.324  
   1.325 -  LpClp::ProblemType LpClp::_getPrimalType() const {
   1.326 +  ClpLp::ProblemType ClpLp::_getPrimalType() const {
   1.327      if (_prob->isProvenOptimal()) {
   1.328        return OPTIMAL;
   1.329      } else if (_prob->isProvenPrimalInfeasible()) {
   1.330 @@ -389,7 +389,7 @@
   1.331      }
   1.332    }
   1.333  
   1.334 -  LpClp::ProblemType LpClp::_getDualType() const {
   1.335 +  ClpLp::ProblemType ClpLp::_getDualType() const {
   1.336      if (_prob->isProvenOptimal()) {
   1.337        return OPTIMAL;
   1.338      } else if (_prob->isProvenDualInfeasible()) {
   1.339 @@ -401,7 +401,7 @@
   1.340      }
   1.341    }
   1.342  
   1.343 -  void LpClp::_setSense(LpClp::Sense sense) {
   1.344 +  void ClpLp::_setSense(ClpLp::Sense sense) {
   1.345      switch (sense) {
   1.346      case MIN:
   1.347        _prob->setOptimizationDirection(1);
   1.348 @@ -412,7 +412,7 @@
   1.349      }
   1.350    }
   1.351  
   1.352 -  LpClp::Sense LpClp::_getSense() const {
   1.353 +  ClpLp::Sense ClpLp::_getSense() const {
   1.354      double dir = _prob->optimizationDirection();
   1.355      if (dir > 0.0) {
   1.356        return MIN;
   1.357 @@ -421,7 +421,7 @@
   1.358      }
   1.359    }
   1.360  
   1.361 -  void LpClp::_clear() {
   1.362 +  void ClpLp::_clear() {
   1.363      delete _prob;
   1.364      _prob = new ClpSimplex();
   1.365      rows.clear();
   1.366 @@ -430,7 +430,7 @@
   1.367      _clear_temporals();
   1.368    }
   1.369  
   1.370 -  void LpClp::messageLevel(MessageLevel m) {
   1.371 +  void ClpLp::messageLevel(MessageLevel m) {
   1.372      _prob->setLogLevel(static_cast<int>(m));
   1.373    }
   1.374