1.1 --- a/src/work/athos/lp/lp_cplex.cc Thu Apr 07 12:54:35 2005 +0000
1.2 +++ b/src/work/athos/lp/lp_cplex.cc Thu Apr 07 15:22:03 2005 +0000
1.3 @@ -24,7 +24,7 @@
1.4 int LpCplex::_addCol()
1.5 {
1.6 int i = CPXgetnumcols (env, lp);
1.7 - int lb[1],ub[1];
1.8 + Value lb[1],ub[1];
1.9 lb[0]=-INF;//-CPX_INFBOUND;
1.10 ub[0]=INF;//CPX_INFBOUND;
1.11 status = CPXnewcols (env, lp, 1, NULL, lb, ub, NULL, NULL);
1.12 @@ -33,8 +33,12 @@
1.13
1.14 int LpCplex::_addRow()
1.15 {
1.16 + //We want a ranged row
1.17 + char sense[1];
1.18 + sense[0]='R';
1.19 +
1.20 int i = CPXgetnumrows (env, lp);
1.21 - status = CPXnewrows (env, lp, 1, NULL, NULL, NULL, NULL, NULL);
1.22 + status = CPXnewrows (env, lp, 1, NULL, sense, NULL, NULL);
1.23 return i;
1.24 }
1.25
1.26 @@ -45,14 +49,15 @@
1.27 Value const * values )
1.28 {
1.29 int rowlist[length+1];
1.30 + int* p=rowlist;
1.31 for (int k=1;k<=length;++k){
1.32 rowlist[k]=i;
1.33 }
1.34 status = CPXchgcoeflist(env, lp,
1.35 length,
1.36 - rowlist++,
1.37 - inices++,
1.38 - values++);
1.39 + p++,
1.40 + const_cast<int * >(indices++),
1.41 + const_cast<Value * >(values++));
1.42 }
1.43
1.44 void LpCplex::_setColCoeffs(int i,
1.45 @@ -61,45 +66,117 @@
1.46 Value const * values)
1.47 {
1.48 int collist[length+1];
1.49 + int* p=collist;
1.50 for (int k=1;k<=length;++k){
1.51 collist[k]=i;
1.52 }
1.53 status = CPXchgcoeflist(env, lp,
1.54 length,
1.55 - inices++,
1.56 - collist++,
1.57 - values++);
1.58 + const_cast<int * >(indices++),
1.59 + p++,
1.60 + const_cast<Value * >(values++));
1.61 }
1.62
1.63 void LpCplex::_setColLowerBound(int i, Value value)
1.64 {
1.65 + int indices[1];
1.66 + indices[0]=i;
1.67 + char lu[1];
1.68 + lu[0]='L';
1.69 + Value bd[1];
1.70 + bd[0]=value;
1.71 + status = CPXchgbds (env, lp, 1, indices, lu, bd);
1.72 +
1.73 }
1.74
1.75 void LpCplex::_setColUpperBound(int i, Value value)
1.76 {
1.77 + int indices[1];
1.78 + indices[0]=i;
1.79 + char lu[1];
1.80 + lu[0]='U';
1.81 + Value bd[1];
1.82 + bd[0]=value;
1.83 + status = CPXchgbds (env, lp, 1, indices, lu, bd);
1.84 }
1.85
1.86 void LpCplex::_setRowLowerBound(int i, Value value)
1.87 {
1.88 + status = CPXchgcoef (env, lp, i, -1, value);
1.89 +
1.90 }
1.91
1.92 void LpCplex::_setRowUpperBound(int i, Value value)
1.93 {
1.94 + //TODO Ezt kell meg megirni
1.95 + // Value lo=CPX
1.96 }
1.97
1.98 void LpCplex::_setObjCoeff(int i, Value obj_coef)
1.99 {
1.100 + status = CPXchgcoef (env, lp, -1, i, obj_coef);
1.101 + }
1.102 +
1.103 + LpCplex::SolveExitStatus LpCplex::_solve()
1.104 + {
1.105 + return SOLVED;
1.106 +// int i= lpx_simplex(lp);
1.107 +// switch (i) {
1.108 +// case LPX_E_OK:
1.109 +// return SOLVED;
1.110 +// break;
1.111 +// default:
1.112 +// return UNSOLVED;
1.113 +// }
1.114 }
1.115
1.116 - LpCplex::SolutionStatus LpCplex::_solve()
1.117 - {
1.118 - return OPTIMAL;
1.119 - }
1.120 -
1.121 - LpCplex::Value LpCplex::_getSolution(int i)
1.122 + LpCplex::Value LpCplex::_getPrimal(int i)
1.123 {
1.124 return 0;
1.125 }
1.126
1.127 + LpCplex::Value LpCplex::_getPrimalValue()
1.128 + {
1.129 + return 0;
1.130 + }
1.131 +
1.132 +
1.133 + LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
1.134 + {
1.135 + return OPTIMAL;
1.136 +// int stat= lpx_get_status(lp);
1.137 +// switch (stat) {
1.138 +// case LPX_UNDEF://Undefined (no solve has been run yet)
1.139 +// return UNDEFINED;
1.140 +// break;
1.141 +// case LPX_NOFEAS://There is no feasible solution (primal, I guess)
1.142 +// case LPX_INFEAS://Infeasible
1.143 +// return INFEASIBLE;
1.144 +// break;
1.145 +// case LPX_UNBND://Unbounded
1.146 +// return INFINITE;
1.147 +// break;
1.148 +// case LPX_FEAS://Feasible
1.149 +// return FEASIBLE;
1.150 +// break;
1.151 +// case LPX_OPT://Feasible
1.152 +// return OPTIMAL;
1.153 +// break;
1.154 +// default:
1.155 +// return UNDEFINED; //to avoid gcc warning
1.156 +// //FIXME error
1.157 +// }
1.158 + }
1.159 +
1.160 +
1.161 + void LpCplex::_setMax()
1.162 + {
1.163 + CPXchgobjsen (env, lp, CPX_MAX);
1.164 + }
1.165 + void LpCplex::_setMin()
1.166 + {
1.167 + CPXchgobjsen (env, lp, CPX_MIN);
1.168 + }
1.169 +
1.170 } //namespace lemon
1.171