diff -r 751a14b992f2 -r bfbdded3763a lemon/lp_cplex.cc --- a/lemon/lp_cplex.cc Fri Feb 16 15:57:48 2007 +0000 +++ b/lemon/lp_cplex.cc Fri Feb 16 19:11:31 2007 +0000 @@ -84,7 +84,7 @@ CPXdelrows(env, lp, i, i); } - void LpCplex::_getColName(int col, std::string &name) + void LpCplex::_getColName(int col, std::string &name) const { ///\bug Untested int storespace; @@ -107,6 +107,16 @@ ///\bug return code unchecked for error CPXchgcolname(env, lp, 1, &col, names); } + + int LpCplex::_colByName(const std::string& name) const + { + int index; + if (CPXgetcolindex(env, lp, + const_cast(name.c_str()), &index) == 0) { + return index; + } + return -1; + } ///\warning Data at index 0 is ignored in the arrays. void LpCplex::_setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e) @@ -125,7 +135,7 @@ &rowlist[0], &indices[0], &values[0]); } - void LpSoplex::_getRowCoeffs(int i, RowIterator b) { + void LpSoplex::_getRowCoeffs(int i, RowIterator b) const { /// \todo implement } @@ -145,7 +155,7 @@ &indices[0], &collist[0], &values[0]); } - void LpSoplex::_getColCoeffs(int i, ColIterator b) { + void LpSoplex::_getColCoeffs(int i, ColIterator b) const { /// \todo implement } @@ -154,7 +164,7 @@ CPXchgcoef(env, lp, row, col, value); } - LpCplex::Value LpCplex::_getCoeff(int row, int col) + LpCplex::Value LpCplex::_getCoeff(int row, int col) const { LpCplex::Value value; CPXgetcoef(env, lp, row, col, &value); @@ -173,7 +183,7 @@ } - LpCplex::Value LpCplex::_getColLowerBound(int i) + LpCplex::Value LpCplex::_getColLowerBound(int i) const { LpCplex::Value x; CPXgetlb (env, lp, &x, i, i); @@ -191,7 +201,7 @@ status = CPXchgbds(env, lp, 1, indices, lu, bd); } - LpCplex::Value LpCplex::_getColUpperBound(int i) + LpCplex::Value LpCplex::_getColUpperBound(int i) const { LpCplex::Value x; CPXgetub (env, lp, &x, i, i); @@ -270,7 +280,7 @@ // // status = CPXchgcoef(env, lp, i, -2, value_rng); // } - void LpCplex::_getRowBounds(int i, Value &lb, Value &ub) + void LpCplex::_getRowBounds(int i, Value &lb, Value &ub) const { char sense; CPXgetsense(env, lp, &sense,i,i); @@ -302,7 +312,7 @@ CPXchgcoef(env, lp, -1, i, obj_coef); } - LpCplex::Value LpCplex::_getObjCoeff(int i) + LpCplex::Value LpCplex::_getObjCoeff(int i) const { Value x; CPXgetcoef(env, lp, -1, i, &x); @@ -367,21 +377,21 @@ #endif } - LpCplex::Value LpCplex::_getPrimal(int i) + LpCplex::Value LpCplex::_getPrimal(int i) const { Value x; CPXgetx(env, lp, &x, i, i); return x; } - LpCplex::Value LpCplex::_getDual(int i) + LpCplex::Value LpCplex::_getDual(int i) const { Value y; CPXgetpi(env, lp, &y, i, i); return y; } - LpCplex::Value LpCplex::_getPrimalValue() + LpCplex::Value LpCplex::_getPrimalValue() const { Value objval; //method = CPXgetmethod (env, lp); @@ -390,7 +400,8 @@ //printf("Objective value: %g \n",objval); return objval; } - bool LpCplex::_isBasicCol(int i) { + bool LpCplex::_isBasicCol(int i) const + { int cstat[CPXgetnumcols(env, lp)]; CPXgetbase(env, lp, cstat, NULL); return (cstat[i]==CPX_BASIC); @@ -458,7 +469,6 @@ // Default: 0 // Description: Method for linear optimization. // Determines which algorithm is used when CPXlpopt() (or "optimize" in the Interactive Optimizer) is called. Currently the behavior of the "Automatic" setting is that CPLEX simply invokes the dual simplex method, but this capability may be expanded in the future so that CPLEX chooses the method based on problem characteristics - //Hulye cplex void statusSwitch(CPXENVptr env,int& stat){ #if CPX_VERSION < 900 int lpmethod; @@ -475,7 +485,7 @@ #endif } - LpCplex::SolutionStatus LpCplex::_getPrimalStatus() + LpCplex::SolutionStatus LpCplex::_getPrimalStatus() const { //Unboundedness not treated well: the following is from cplex 9.0 doc // About Unboundedness @@ -558,7 +568,7 @@ // CPX_STAT_OPTIMAL_RELAXED // CPX_STAT_UNBOUNDED - LpCplex::SolutionStatus LpCplex::_getDualStatus() + LpCplex::SolutionStatus LpCplex::_getDualStatus() const { int stat = CPXgetstat(env, lp); #if CPX_VERSION >= 800 @@ -587,7 +597,7 @@ #endif } - LpCplex::ProblemTypes LpCplex::_getProblemType() + LpCplex::ProblemTypes LpCplex::_getProblemType() const { int stat = CPXgetstat(env, lp); #if CPX_VERSION >= 800 @@ -627,7 +637,7 @@ CPXchgobjsen(env, lp, CPX_MIN); } - bool LpCplex::_isMax() + bool LpCplex::_isMax() const { if (CPXgetobjsen(env, lp)==CPX_MAX) return true;