diff -r 751a14b992f2 -r bfbdded3763a lemon/lp_soplex.cc --- a/lemon/lp_soplex.cc Fri Feb 16 15:57:48 2007 +0000 +++ b/lemon/lp_soplex.cc Fri Feb 16 19:11:31 2007 +0000 @@ -90,12 +90,26 @@ solved = false; } - void LpSoplex::_getColName(int col, std::string &name) { + void LpSoplex::_getColName(int col, std::string &name) const { name = colNames[col]; } void LpSoplex::_setColName(int col, const std::string &name) { + invColNames.erase(colNames[col]); colNames[col] = name; + if (!name.empty()) { + invColNames.insert(std::make_pair(name, col)); + } + } + + int LpSoplex::_colByName(const std::string& name) const { + std::map::const_iterator it = + invColNames.find(name); + if (it != invColNames.end()) { + return it->second; + } else { + return -1; + } } @@ -109,7 +123,7 @@ solved = false; } - void LpSoplex::_getRowCoeffs(int i, RowIterator b) { + void LpSoplex::_getRowCoeffs(int i, RowIterator b) const { const soplex::SVector& vec = soplex->rowVector(i); for (int k = 0; k < vec.size(); ++k) { *b = std::make_pair(vec.index(k), vec.value(k)); @@ -127,7 +141,7 @@ solved = false; } - void LpSoplex::_getColCoeffs(int i, ColIterator b) { + void LpSoplex::_getColCoeffs(int i, ColIterator b) const { const soplex::SVector& vec = soplex->colVector(i); for (int k = 0; k < vec.size(); ++k) { *b = std::make_pair(vec.index(k), vec.value(k)); @@ -140,7 +154,7 @@ solved = false; } - LpSoplex::Value LpSoplex::_getCoeff(int i, int j) { + LpSoplex::Value LpSoplex::_getCoeff(int i, int j) const { return soplex->rowVector(i)[j]; } @@ -149,7 +163,7 @@ solved = false; } - LpSoplex::Value LpSoplex::_getColLowerBound(int i) { + LpSoplex::Value LpSoplex::_getColLowerBound(int i) const { double value = soplex->lower(i); return value != -soplex::infinity ? value : -INF; } @@ -159,7 +173,7 @@ solved = false; } - LpSoplex::Value LpSoplex::_getColUpperBound(int i) { + LpSoplex::Value LpSoplex::_getColUpperBound(int i) const { double value = soplex->upper(i); return value != soplex::infinity ? value : INF; } @@ -169,7 +183,7 @@ ub != INF ? ub : soplex::infinity); solved = false; } - void LpSoplex::_getRowBounds(int i, Value &lower, Value &upper) { + void LpSoplex::_getRowBounds(int i, Value &lower, Value &upper) const { lower = soplex->lhs(i); if (lower == -soplex::infinity) lower = -INF; upper = soplex->rhs(i); @@ -181,7 +195,7 @@ solved = false; } - LpSoplex::Value LpSoplex::_getObjCoeff(int i) { + LpSoplex::Value LpSoplex::_getObjCoeff(int i) const { return soplex->obj(i); } @@ -212,23 +226,23 @@ } } - LpSoplex::Value LpSoplex::_getPrimal(int i) { + LpSoplex::Value LpSoplex::_getPrimal(int i) const { return primal_value[i]; } - LpSoplex::Value LpSoplex::_getDual(int i) { + LpSoplex::Value LpSoplex::_getDual(int i) const { return dual_value[i]; } - LpSoplex::Value LpSoplex::_getPrimalValue() { + LpSoplex::Value LpSoplex::_getPrimalValue() const { return soplex->objValue(); } - bool LpSoplex::_isBasicCol(int i) { + bool LpSoplex::_isBasicCol(int i) const { return soplex->getBasisColStatus(i) == soplex::SPxSolver::BASIC; } - LpSoplex::SolutionStatus LpSoplex::_getPrimalStatus() { + LpSoplex::SolutionStatus LpSoplex::_getPrimalStatus() const { if (!solved) return UNDEFINED; switch (soplex->status()) { case soplex::SPxSolver::OPTIMAL: @@ -242,7 +256,7 @@ } } - LpSoplex::SolutionStatus LpSoplex::_getDualStatus() { + LpSoplex::SolutionStatus LpSoplex::_getDualStatus() const { if (!solved) return UNDEFINED; switch (soplex->status()) { case soplex::SPxSolver::OPTIMAL: @@ -254,7 +268,7 @@ } } - LpSoplex::ProblemTypes LpSoplex::_getProblemType() { + LpSoplex::ProblemTypes LpSoplex::_getProblemType() const { if (!solved) return UNKNOWN; switch (soplex->status()) { case soplex::SPxSolver::OPTIMAL: @@ -274,7 +288,7 @@ soplex->changeSense(soplex::SPxSolver::MINIMIZE); solved = false; } - bool LpSoplex::_isMax() { + bool LpSoplex::_isMax() const { return soplex->spxSense() == soplex::SPxSolver::MAXIMIZE; }