Deleted _setRowLowerBound() and _setRowUpperBound() functions. Cplex worked (now it does not because of _getPrimalStatus()).
1.1 --- a/src/lemon/lp_base.h Thu May 05 15:34:43 2005 +0000
1.2 +++ b/src/lemon/lp_base.h Thu May 05 15:43:43 2005 +0000
1.3 @@ -431,8 +431,8 @@
1.4 Value const * values ) = 0;
1.5 virtual void _setColLowerBound(int i, Value value) = 0;
1.6 virtual void _setColUpperBound(int i, Value value) = 0;
1.7 - virtual void _setRowLowerBound(int i, Value value) = 0;
1.8 - virtual void _setRowUpperBound(int i, Value value) = 0;
1.9 +// virtual void _setRowLowerBound(int i, Value value) = 0;
1.10 +// virtual void _setRowUpperBound(int i, Value value) = 0;
1.11 virtual void _setRowBounds(int i, Value lower, Value upper) = 0;
1.12 virtual void _setObjCoeff(int i, Value obj_coef) = 0;
1.13 virtual void _clearObj()=0;
1.14 @@ -567,8 +567,9 @@
1.15 }
1.16 _setRowCoeffs(rows.floatingId(r.id),indices.size()-1,
1.17 &indices[0],&values[0]);
1.18 - _setRowLowerBound(rows.floatingId(r.id),l-e.constComp());
1.19 - _setRowUpperBound(rows.floatingId(r.id),u-e.constComp());
1.20 +// _setRowLowerBound(rows.floatingId(r.id),l-e.constComp());
1.21 +// _setRowUpperBound(rows.floatingId(r.id),u-e.constComp());
1.22 + _setRowBounds(rows.floatingId(r.id),l-e.constComp(),u-e.constComp());
1.23 }
1.24
1.25 ///Set a row (i.e a constaint) of the LP
1.26 @@ -633,23 +634,24 @@
1.27 _setColUpperBound(cols.floatingId(c.id),upper);
1.28 }
1.29
1.30 - /// Set the lower bound of a row (i.e a constraint)
1.31 +// /// Set the lower bound of a row (i.e a constraint)
1.32
1.33 - /// The lower bound of a linear expression (row) has to be given by an
1.34 - /// extended number of type Value, i.e. a finite number of type
1.35 - /// Value or -\ref INF.
1.36 - void rowLowerBound(Row r, Value value) {
1.37 - _setRowLowerBound(rows.floatingId(r.id),value);
1.38 - };
1.39 - /// Set the upper bound of a row (i.e a constraint)
1.40 +// /// The lower bound of a linear expression (row) has to be given by an
1.41 +// /// extended number of type Value, i.e. a finite number of type
1.42 +// /// Value or -\ref INF.
1.43 +// void rowLowerBound(Row r, Value value) {
1.44 +// _setRowLowerBound(rows.floatingId(r.id),value);
1.45 +// };
1.46 +// /// Set the upper bound of a row (i.e a constraint)
1.47
1.48 - /// The upper bound of a linear expression (row) has to be given by an
1.49 - /// extended number of type Value, i.e. a finite number of type
1.50 - /// Value or \ref INF.
1.51 - void rowUpperBound(Row r, Value value) {
1.52 - _setRowUpperBound(rows.floatingId(r.id),value);
1.53 - };
1.54 - /// Set the lower and the upper bounds of a row (i.e a variable)
1.55 +// /// The upper bound of a linear expression (row) has to be given by an
1.56 +// /// extended number of type Value, i.e. a finite number of type
1.57 +// /// Value or \ref INF.
1.58 +// void rowUpperBound(Row r, Value value) {
1.59 +// _setRowUpperBound(rows.floatingId(r.id),value);
1.60 +// };
1.61 +
1.62 + /// Set the lower and the upper bounds of a row (i.e a constraint)
1.63
1.64 /// The lower and the upper bounds of
1.65 /// a constraint (row) have to be given by an
2.1 --- a/src/lemon/lp_cplex.cc Thu May 05 15:34:43 2005 +0000
2.2 +++ b/src/lemon/lp_cplex.cc Thu May 05 15:43:43 2005 +0000
2.3 @@ -14,8 +14,8 @@
2.4 * purpose.
2.5 *
2.6 */
2.7 -
2.8 -#include"lp_cplex.h"
2.9 +#include <iostream>
2.10 +#include<lemon/lp_cplex.h>
2.11
2.12 ///\file
2.13 ///\brief Implementation of the LEMON-CPLEX lp solver interface.
2.14 @@ -65,8 +65,14 @@
2.15
2.16 }
2.17
2.18 - LpSolverBase &LpCplex::_newLp() {return *(LpSolverBase*)0;}
2.19 - LpSolverBase &LpCplex::_copyLp() {return *(LpSolverBase*)0;}
2.20 + LpSolverBase &LpCplex::_newLp()
2.21 + {
2.22 + return *(LpSolverBase*)0;
2.23 + }
2.24 + LpSolverBase &LpCplex::_copyLp() {
2.25 + return *(LpSolverBase*)0;
2.26 + //Ez lesz majd CPXcloneprob (env, lp, &status);
2.27 + }
2.28
2.29 int LpCplex::_addCol()
2.30 {
2.31 @@ -155,7 +161,7 @@
2.32 if (lb==INF || ub==-INF) {
2.33 //FIXME error
2.34 }
2.35 -
2.36 +
2.37 int cnt=1;
2.38 int indices[1];
2.39 indices[0]=i;
2.40 @@ -165,6 +171,7 @@
2.41 sense[0]='L';
2.42 CPXchgsense (env, lp, cnt, indices, sense);
2.43 CPXchgcoef (env, lp, i, -1, ub);
2.44 +
2.45 }
2.46 else{
2.47 if (ub==INF){
2.48 @@ -188,36 +195,36 @@
2.49 }
2.50 }
2.51
2.52 - void LpCplex::_setRowLowerBound(int i, Value value)
2.53 - {
2.54 - //Not implemented, obsolete
2.55 - }
2.56 +// void LpCplex::_setRowLowerBound(int i, Value value)
2.57 +// {
2.58 +// //Not implemented, obsolete
2.59 +// }
2.60
2.61 - void LpCplex::_setRowUpperBound(int i, Value value)
2.62 - {
2.63 - //Not implemented, obsolete
2.64 -// //TODO Ezt kell meg megirni
2.65 -// //type of the problem
2.66 -// char sense[1];
2.67 -// status = CPXgetsense (env, lp, sense, i, i);
2.68 -// Value rhs[1];
2.69 -// status = CPXgetrhs (env, lp, rhs, i, i);
2.70 +// void LpCplex::_setRowUpperBound(int i, Value value)
2.71 +// {
2.72 +// //Not implemented, obsolete
2.73 +// // //TODO Ezt kell meg megirni
2.74 +// // //type of the problem
2.75 +// // char sense[1];
2.76 +// // status = CPXgetsense (env, lp, sense, i, i);
2.77 +// // Value rhs[1];
2.78 +// // status = CPXgetrhs (env, lp, rhs, i, i);
2.79
2.80 -// switch (sense[0]) {
2.81 -// case 'L'://<= constraint
2.82 -// break;
2.83 -// case 'E'://= constraint
2.84 -// break;
2.85 -// case 'G'://>= constraint
2.86 -// break;
2.87 -// case 'R'://ranged constraint
2.88 -// break;
2.89 -// default: ;
2.90 -// //FIXME error
2.91 -// }
2.92 +// // switch (sense[0]) {
2.93 +// // case 'L'://<= constraint
2.94 +// // break;
2.95 +// // case 'E'://= constraint
2.96 +// // break;
2.97 +// // case 'G'://>= constraint
2.98 +// // break;
2.99 +// // case 'R'://ranged constraint
2.100 +// // break;
2.101 +// // default: ;
2.102 +// // //FIXME error
2.103 +// // }
2.104
2.105 -// status = CPXchgcoef (env, lp, i, -2, value_rng);
2.106 - }
2.107 +// // status = CPXchgcoef (env, lp, i, -2, value_rng);
2.108 +// }
2.109
2.110 void LpCplex::_setObjCoeff(int i, Value obj_coef)
2.111 {
2.112 @@ -254,30 +261,41 @@
2.113
2.114 LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
2.115 {
2.116 +// CPX_STAT_ABORT_DUAL_OBJ_LIM
2.117 +// CPX_STAT_ABORT_IT_LIM
2.118 +// CPX_STAT_ABORT_OBJ_LIM
2.119 +// CPX_STAT_ABORT_PRIM_OBJ_LIM
2.120 +// CPX_STAT_ABORT_TIME_LIM
2.121 +// CPX_STAT_ABORT_USER
2.122 +// CPX_STAT_FEASIBLE_RELAXED
2.123 +// CPX_STAT_INFEASIBLE
2.124 +// CPX_STAT_INForUNBD
2.125 +// CPX_STAT_NUM_BEST
2.126 +// CPX_STAT_OPTIMAL
2.127 +// CPX_STAT_OPTIMAL_FACE_UNBOUNDED
2.128 +// CPX_STAT_OPTIMAL_INFEAS
2.129 +// CPX_STAT_OPTIMAL_RELAXED
2.130 +// CPX_STAT_UNBOUNDED
2.131 +
2.132 //Unimplemented
2.133 - return OPTIMAL;
2.134 -// int stat= lpx_get_status(lp);
2.135 -// switch (stat) {
2.136 -// case LPX_UNDEF://Undefined (no solve has been run yet)
2.137 -// return UNDEFINED;
2.138 -// break;
2.139 -// case LPX_NOFEAS://There is no feasible solution (primal, I guess)
2.140 -// case LPX_INFEAS://Infeasible
2.141 -// return INFEASIBLE;
2.142 -// break;
2.143 -// case LPX_UNBND://Unbounded
2.144 -// return INFINITE;
2.145 -// break;
2.146 -// case LPX_FEAS://Feasible
2.147 -// return FEASIBLE;
2.148 -// break;
2.149 -// case LPX_OPT://Feasible
2.150 -// return OPTIMAL;
2.151 -// break;
2.152 -// default:
2.153 -// return UNDEFINED; //to avoid gcc warning
2.154 -// //FIXME error
2.155 -// }
2.156 + int stat = CPXgetstat (env, lp);
2.157 + switch (stat) {
2.158 + case CPX_STAT_OPTIMAL://Optimal
2.159 + return OPTIMAL;
2.160 + break;
2.161 + case CPX_STAT_INFEASIBLE://Infeasible
2.162 + return INFEASIBLE;
2.163 + break;
2.164 + case CPX_STAT_UNBOUNDED://Unbounded
2.165 + return INFINITE;
2.166 + break;
2.167 + case CPX_STAT_NUM_BEST://Feasible
2.168 + return FEASIBLE;
2.169 + break;
2.170 + default:
2.171 + return UNDEFINED; //Everything else comes here
2.172 + //FIXME error
2.173 + }
2.174 }
2.175
2.176 LpCplex::Value LpCplex::_getPrimal(int i)
2.177 @@ -289,8 +307,10 @@
2.178
2.179 LpCplex::Value LpCplex::_getPrimalValue()
2.180 {
2.181 - //Unimplemented
2.182 - return 0;
2.183 + Value objval;
2.184 + //method = CPXgetmethod (env, lp);
2.185 + status = CPXgetobjval (env, lp, &objval);
2.186 + return objval;
2.187 }
2.188
2.189
3.1 --- a/src/lemon/lp_cplex.h Thu May 05 15:34:43 2005 +0000
3.2 +++ b/src/lemon/lp_cplex.h Thu May 05 15:43:43 2005 +0000
3.3 @@ -65,8 +65,8 @@
3.4 const Value * values);
3.5 virtual void _setColLowerBound(int i, Value value);
3.6 virtual void _setColUpperBound(int i, Value value);
3.7 - virtual void _setRowLowerBound(int i, Value value);
3.8 - virtual void _setRowUpperBound(int i, Value value);
3.9 +// virtual void _setRowLowerBound(int i, Value value);
3.10 +// virtual void _setRowUpperBound(int i, Value value);
3.11 virtual void _setRowBounds(int i, Value lower, Value upper);
3.12 virtual void _setObjCoeff(int i, Value obj_coef);
3.13 virtual void _clearObj();
4.1 --- a/src/lemon/lp_glpk.cc Thu May 05 15:34:43 2005 +0000
4.2 +++ b/src/lemon/lp_glpk.cc Thu May 05 15:43:43 2005 +0000
4.3 @@ -175,91 +175,91 @@
4.4 }
4.5 }
4.6
4.7 - void LpGlpk::_setRowLowerBound(int i, Value lo)
4.8 - {
4.9 - if (lo==INF) {
4.10 - //FIXME error
4.11 - }
4.12 - int b=lpx_get_row_type(lp, i);
4.13 - double up=lpx_get_row_ub(lp, i);
4.14 - if (lo==-INF) {
4.15 - switch (b) {
4.16 - case LPX_FR:
4.17 - case LPX_LO:
4.18 - lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
4.19 - break;
4.20 - case LPX_UP:
4.21 - break;
4.22 - case LPX_DB:
4.23 - case LPX_FX:
4.24 - lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
4.25 - break;
4.26 - default: ;
4.27 - //FIXME error
4.28 - }
4.29 - } else {
4.30 - switch (b) {
4.31 - case LPX_FR:
4.32 - case LPX_LO:
4.33 - lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
4.34 - break;
4.35 - case LPX_UP:
4.36 - case LPX_DB:
4.37 - case LPX_FX:
4.38 - if (lo==up)
4.39 - lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
4.40 - else
4.41 - lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
4.42 - break;
4.43 - default: ;
4.44 - //FIXME error
4.45 - }
4.46 - }
4.47 - }
4.48 +// void LpGlpk::_setRowLowerBound(int i, Value lo)
4.49 +// {
4.50 +// if (lo==INF) {
4.51 +// //FIXME error
4.52 +// }
4.53 +// int b=lpx_get_row_type(lp, i);
4.54 +// double up=lpx_get_row_ub(lp, i);
4.55 +// if (lo==-INF) {
4.56 +// switch (b) {
4.57 +// case LPX_FR:
4.58 +// case LPX_LO:
4.59 +// lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
4.60 +// break;
4.61 +// case LPX_UP:
4.62 +// break;
4.63 +// case LPX_DB:
4.64 +// case LPX_FX:
4.65 +// lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
4.66 +// break;
4.67 +// default: ;
4.68 +// //FIXME error
4.69 +// }
4.70 +// } else {
4.71 +// switch (b) {
4.72 +// case LPX_FR:
4.73 +// case LPX_LO:
4.74 +// lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
4.75 +// break;
4.76 +// case LPX_UP:
4.77 +// case LPX_DB:
4.78 +// case LPX_FX:
4.79 +// if (lo==up)
4.80 +// lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
4.81 +// else
4.82 +// lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
4.83 +// break;
4.84 +// default: ;
4.85 +// //FIXME error
4.86 +// }
4.87 +// }
4.88 +// }
4.89
4.90 - void LpGlpk::_setRowUpperBound(int i, Value up)
4.91 - {
4.92 - if (up==-INF) {
4.93 - //FIXME error
4.94 - }
4.95 - int b=lpx_get_row_type(lp, i);
4.96 - double lo=lpx_get_row_lb(lp, i);
4.97 - if (up==INF) {
4.98 - switch (b) {
4.99 - case LPX_FR:
4.100 - case LPX_LO:
4.101 - break;
4.102 - case LPX_UP:
4.103 - lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
4.104 - break;
4.105 - case LPX_DB:
4.106 - case LPX_FX:
4.107 - lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
4.108 - break;
4.109 - default: ;
4.110 - //FIXME error
4.111 - }
4.112 - } else {
4.113 - switch (b) {
4.114 - case LPX_FR:
4.115 - lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
4.116 - break;
4.117 - case LPX_UP:
4.118 - lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
4.119 - break;
4.120 - case LPX_LO:
4.121 - case LPX_DB:
4.122 - case LPX_FX:
4.123 - if (lo==up)
4.124 - lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
4.125 - else
4.126 - lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
4.127 - break;
4.128 - default: ;
4.129 - //FIXME error
4.130 - }
4.131 - }
4.132 - }
4.133 +// void LpGlpk::_setRowUpperBound(int i, Value up)
4.134 +// {
4.135 +// if (up==-INF) {
4.136 +// //FIXME error
4.137 +// }
4.138 +// int b=lpx_get_row_type(lp, i);
4.139 +// double lo=lpx_get_row_lb(lp, i);
4.140 +// if (up==INF) {
4.141 +// switch (b) {
4.142 +// case LPX_FR:
4.143 +// case LPX_LO:
4.144 +// break;
4.145 +// case LPX_UP:
4.146 +// lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
4.147 +// break;
4.148 +// case LPX_DB:
4.149 +// case LPX_FX:
4.150 +// lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
4.151 +// break;
4.152 +// default: ;
4.153 +// //FIXME error
4.154 +// }
4.155 +// } else {
4.156 +// switch (b) {
4.157 +// case LPX_FR:
4.158 +// lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
4.159 +// break;
4.160 +// case LPX_UP:
4.161 +// lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
4.162 +// break;
4.163 +// case LPX_LO:
4.164 +// case LPX_DB:
4.165 +// case LPX_FX:
4.166 +// if (lo==up)
4.167 +// lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
4.168 +// else
4.169 +// lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
4.170 +// break;
4.171 +// default: ;
4.172 +// //FIXME error
4.173 +// }
4.174 +// }
4.175 +// }
4.176
4.177 void LpGlpk::_setRowBounds(int i, Value lb, Value ub)
4.178 {
5.1 --- a/src/lemon/lp_glpk.h Thu May 05 15:34:43 2005 +0000
5.2 +++ b/src/lemon/lp_glpk.h Thu May 05 15:43:43 2005 +0000
5.3 @@ -60,8 +60,8 @@
5.4 const Value * values);
5.5 virtual void _setColLowerBound(int i, Value value);
5.6 virtual void _setColUpperBound(int i, Value value);
5.7 - virtual void _setRowLowerBound(int i, Value value);
5.8 - virtual void _setRowUpperBound(int i, Value value);
5.9 +// virtual void _setRowLowerBound(int i, Value value);
5.10 +// virtual void _setRowUpperBound(int i, Value value);
5.11 virtual void _setRowBounds(int i, Value lower, Value upper);
5.12 virtual void _setObjCoeff(int i, Value obj_coef);
5.13 virtual void _clearObj();
6.1 --- a/src/lemon/lp_skeleton.cc Thu May 05 15:34:43 2005 +0000
6.2 +++ b/src/lemon/lp_skeleton.cc Thu May 05 15:43:43 2005 +0000
6.3 @@ -65,13 +65,13 @@
6.4 {
6.5 }
6.6
6.7 - void LpSkeleton::_setRowLowerBound(int, Value)
6.8 - {
6.9 - }
6.10 +// void LpSkeleton::_setRowLowerBound(int, Value)
6.11 +// {
6.12 +// }
6.13
6.14 - void LpSkeleton::_setRowUpperBound(int, Value)
6.15 - {
6.16 - }
6.17 +// void LpSkeleton::_setRowUpperBound(int, Value)
6.18 +// {
6.19 +// }
6.20
6.21 void LpSkeleton::_setRowBounds(int, Value, Value)
6.22 {
7.1 --- a/src/lemon/lp_skeleton.h Thu May 05 15:34:43 2005 +0000
7.2 +++ b/src/lemon/lp_skeleton.h Thu May 05 15:43:43 2005 +0000
7.3 @@ -68,20 +68,24 @@
7.4 virtual void _setColUpperBound(int i, Value value);
7.5 /// \e
7.6
7.7 - /// The lower bound of a linear expression (row) have to be given by an
7.8 +// /// The lower bound of a linear expression (row) have to be given by an
7.9 +// /// extended number of type Value, i.e. a finite number of type
7.10 +// /// Value or -\ref INF.
7.11 +// virtual void _setRowLowerBound(int i, Value value);
7.12 +// /// \e
7.13 +
7.14 +// /// The upper bound of a linear expression (row) have to be given by an
7.15 +// /// extended number of type Value, i.e. a finite number of type
7.16 +// /// Value or \ref INF.
7.17 +// virtual void _setRowUpperBound(int i, Value value);
7.18 +
7.19 + /// The lower and upper bound of a linear expression (row) have to be
7.20 + /// given by an
7.21 /// extended number of type Value, i.e. a finite number of type
7.22 - /// Value or -\ref INF.
7.23 - virtual void _setRowLowerBound(int i, Value value);
7.24 - /// \e
7.25 -
7.26 - /// \e
7.27 + /// Value or +/-\ref INF.
7.28 virtual void _setRowBounds(int i, Value lb, Value ub);
7.29 /// \e
7.30
7.31 - /// The upper bound of a linear expression (row) have to be given by an
7.32 - /// extended number of type Value, i.e. a finite number of type
7.33 - /// Value or \ref INF.
7.34 - virtual void _setRowUpperBound(int i, Value value);
7.35
7.36 /// \e
7.37 virtual void _clearObj();