1.1 --- a/lemon/lp_cplex.cc Fri Feb 16 15:57:48 2007 +0000
1.2 +++ b/lemon/lp_cplex.cc Fri Feb 16 19:11:31 2007 +0000
1.3 @@ -84,7 +84,7 @@
1.4 CPXdelrows(env, lp, i, i);
1.5 }
1.6
1.7 - void LpCplex::_getColName(int col, std::string &name)
1.8 + void LpCplex::_getColName(int col, std::string &name) const
1.9 {
1.10 ///\bug Untested
1.11 int storespace;
1.12 @@ -107,6 +107,16 @@
1.13 ///\bug return code unchecked for error
1.14 CPXchgcolname(env, lp, 1, &col, names);
1.15 }
1.16 +
1.17 + int LpCplex::_colByName(const std::string& name) const
1.18 + {
1.19 + int index;
1.20 + if (CPXgetcolindex(env, lp,
1.21 + const_cast<char*>(name.c_str()), &index) == 0) {
1.22 + return index;
1.23 + }
1.24 + return -1;
1.25 + }
1.26
1.27 ///\warning Data at index 0 is ignored in the arrays.
1.28 void LpCplex::_setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e)
1.29 @@ -125,7 +135,7 @@
1.30 &rowlist[0], &indices[0], &values[0]);
1.31 }
1.32
1.33 - void LpSoplex::_getRowCoeffs(int i, RowIterator b) {
1.34 + void LpSoplex::_getRowCoeffs(int i, RowIterator b) const {
1.35 /// \todo implement
1.36 }
1.37
1.38 @@ -145,7 +155,7 @@
1.39 &indices[0], &collist[0], &values[0]);
1.40 }
1.41
1.42 - void LpSoplex::_getColCoeffs(int i, ColIterator b) {
1.43 + void LpSoplex::_getColCoeffs(int i, ColIterator b) const {
1.44 /// \todo implement
1.45 }
1.46
1.47 @@ -154,7 +164,7 @@
1.48 CPXchgcoef(env, lp, row, col, value);
1.49 }
1.50
1.51 - LpCplex::Value LpCplex::_getCoeff(int row, int col)
1.52 + LpCplex::Value LpCplex::_getCoeff(int row, int col) const
1.53 {
1.54 LpCplex::Value value;
1.55 CPXgetcoef(env, lp, row, col, &value);
1.56 @@ -173,7 +183,7 @@
1.57
1.58 }
1.59
1.60 - LpCplex::Value LpCplex::_getColLowerBound(int i)
1.61 + LpCplex::Value LpCplex::_getColLowerBound(int i) const
1.62 {
1.63 LpCplex::Value x;
1.64 CPXgetlb (env, lp, &x, i, i);
1.65 @@ -191,7 +201,7 @@
1.66 status = CPXchgbds(env, lp, 1, indices, lu, bd);
1.67 }
1.68
1.69 - LpCplex::Value LpCplex::_getColUpperBound(int i)
1.70 + LpCplex::Value LpCplex::_getColUpperBound(int i) const
1.71 {
1.72 LpCplex::Value x;
1.73 CPXgetub (env, lp, &x, i, i);
1.74 @@ -270,7 +280,7 @@
1.75 // // status = CPXchgcoef(env, lp, i, -2, value_rng);
1.76 // }
1.77
1.78 - void LpCplex::_getRowBounds(int i, Value &lb, Value &ub)
1.79 + void LpCplex::_getRowBounds(int i, Value &lb, Value &ub) const
1.80 {
1.81 char sense;
1.82 CPXgetsense(env, lp, &sense,i,i);
1.83 @@ -302,7 +312,7 @@
1.84 CPXchgcoef(env, lp, -1, i, obj_coef);
1.85 }
1.86
1.87 - LpCplex::Value LpCplex::_getObjCoeff(int i)
1.88 + LpCplex::Value LpCplex::_getObjCoeff(int i) const
1.89 {
1.90 Value x;
1.91 CPXgetcoef(env, lp, -1, i, &x);
1.92 @@ -367,21 +377,21 @@
1.93 #endif
1.94 }
1.95
1.96 - LpCplex::Value LpCplex::_getPrimal(int i)
1.97 + LpCplex::Value LpCplex::_getPrimal(int i) const
1.98 {
1.99 Value x;
1.100 CPXgetx(env, lp, &x, i, i);
1.101 return x;
1.102 }
1.103
1.104 - LpCplex::Value LpCplex::_getDual(int i)
1.105 + LpCplex::Value LpCplex::_getDual(int i) const
1.106 {
1.107 Value y;
1.108 CPXgetpi(env, lp, &y, i, i);
1.109 return y;
1.110 }
1.111
1.112 - LpCplex::Value LpCplex::_getPrimalValue()
1.113 + LpCplex::Value LpCplex::_getPrimalValue() const
1.114 {
1.115 Value objval;
1.116 //method = CPXgetmethod (env, lp);
1.117 @@ -390,7 +400,8 @@
1.118 //printf("Objective value: %g \n",objval);
1.119 return objval;
1.120 }
1.121 - bool LpCplex::_isBasicCol(int i) {
1.122 + bool LpCplex::_isBasicCol(int i) const
1.123 + {
1.124 int cstat[CPXgetnumcols(env, lp)];
1.125 CPXgetbase(env, lp, cstat, NULL);
1.126 return (cstat[i]==CPX_BASIC);
1.127 @@ -458,7 +469,6 @@
1.128 // Default: 0
1.129 // Description: Method for linear optimization.
1.130 // 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
1.131 - //Hulye cplex
1.132 void statusSwitch(CPXENVptr env,int& stat){
1.133 #if CPX_VERSION < 900
1.134 int lpmethod;
1.135 @@ -475,7 +485,7 @@
1.136 #endif
1.137 }
1.138
1.139 - LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
1.140 + LpCplex::SolutionStatus LpCplex::_getPrimalStatus() const
1.141 {
1.142 //Unboundedness not treated well: the following is from cplex 9.0 doc
1.143 // About Unboundedness
1.144 @@ -558,7 +568,7 @@
1.145 // CPX_STAT_OPTIMAL_RELAXED
1.146 // CPX_STAT_UNBOUNDED
1.147
1.148 - LpCplex::SolutionStatus LpCplex::_getDualStatus()
1.149 + LpCplex::SolutionStatus LpCplex::_getDualStatus() const
1.150 {
1.151 int stat = CPXgetstat(env, lp);
1.152 #if CPX_VERSION >= 800
1.153 @@ -587,7 +597,7 @@
1.154 #endif
1.155 }
1.156
1.157 - LpCplex::ProblemTypes LpCplex::_getProblemType()
1.158 + LpCplex::ProblemTypes LpCplex::_getProblemType() const
1.159 {
1.160 int stat = CPXgetstat(env, lp);
1.161 #if CPX_VERSION >= 800
1.162 @@ -627,7 +637,7 @@
1.163 CPXchgobjsen(env, lp, CPX_MIN);
1.164 }
1.165
1.166 - bool LpCplex::_isMax()
1.167 + bool LpCplex::_isMax() const
1.168 {
1.169 if (CPXgetobjsen(env, lp)==CPX_MAX)
1.170 return true;