Changeset 1508:389a94a1d9eb in lemon0.x
 Timestamp:
 06/21/05 17:58:57 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1989
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

lemon/lp_base.h
r1493 r1508 152 152 UNKNOWN = 4 153 153 }; 154 154 155 155 ///The floating point type used by the solver 156 156 typedef double Value; 
lemon/lp_cplex.cc
r1473 r1508 46 46 //object and copy all the problem data from an existing problem 47 47 //object to it. Solution and starting information is not copied. 48 newlp>lp = CPXcloneprob 48 newlp>lp = CPXcloneprob(env, lp, &status); 49 49 return *newlp; 50 50 } … … 52 52 int LpCplex::_addCol() 53 53 { 54 int i = CPXgetnumcols 54 int i = CPXgetnumcols(env, lp); 55 55 Value lb[1],ub[1]; 56 56 lb[0]=INF;//CPX_INFBOUND; 57 57 ub[0]=INF;//CPX_INFBOUND; 58 status = CPXnewcols 58 status = CPXnewcols(env, lp, 1, NULL, lb, ub, NULL, NULL); 59 59 return i; 60 60 } … … 68 68 Value rhs[1]; 69 69 rhs[0]=INF; 70 int i = CPXgetnumrows 71 status = CPXnewrows 70 int i = CPXgetnumrows(env, lp); 71 status = CPXnewrows(env, lp, 1, rhs, sense, NULL, NULL); 72 72 return i; 73 73 } … … 75 75 76 76 void LpCplex::_eraseCol(int i) { 77 CPXdelcols 77 CPXdelcols(env, lp, i, i); 78 78 } 79 79 80 80 void LpCplex::_eraseRow(int i) { 81 CPXdelrows 81 CPXdelrows(env, lp, i, i); 82 82 } 83 83 … … 120 120 void LpCplex::_setCoeff(int row, int col, Value value) 121 121 { 122 CPXchgcoef 122 CPXchgcoef(env, lp, row, col, value); 123 123 } 124 124 … … 131 131 Value bd[1]; 132 132 bd[0]=value; 133 status = CPXchgbds 133 status = CPXchgbds(env, lp, 1, indices, lu, bd); 134 134 135 135 } … … 143 143 Value bd[1]; 144 144 bd[0]=value; 145 status = CPXchgbds 145 status = CPXchgbds(env, lp, 1, indices, lu, bd); 146 146 } 147 147 … … 161 161 if (lb==INF){ 162 162 sense[0]='L'; 163 CPXchgsense 164 CPXchgcoef 163 CPXchgsense(env, lp, cnt, indices, sense); 164 CPXchgcoef(env, lp, i, 1, ub); 165 165 166 166 } … … 168 168 if (ub==INF){ 169 169 sense[0]='G'; 170 CPXchgsense 171 CPXchgcoef 170 CPXchgsense(env, lp, cnt, indices, sense); 171 CPXchgcoef(env, lp, i, 1, lb); 172 172 } 173 173 else{ 174 174 if (lb == ub){ 175 175 sense[0]='E'; 176 CPXchgsense 177 CPXchgcoef 176 CPXchgsense(env, lp, cnt, indices, sense); 177 CPXchgcoef(env, lp, i, 1, lb); 178 178 } 179 179 else{ 180 180 sense[0]='R'; 181 CPXchgsense 182 CPXchgcoef 183 CPXchgcoef 181 CPXchgsense(env, lp, cnt, indices, sense); 182 CPXchgcoef(env, lp, i, 1, lb); 183 CPXchgcoef(env, lp, i, 2, ublb); 184 184 } 185 185 } … … 198 198 // // //type of the problem 199 199 // // char sense[1]; 200 // // status = CPXgetsense 200 // // status = CPXgetsense(env, lp, sense, i, i); 201 201 // // Value rhs[1]; 202 // // status = CPXgetrhs 202 // // status = CPXgetrhs(env, lp, rhs, i, i); 203 203 204 204 // // switch (sense[0]) { … … 215 215 // // } 216 216 217 // // status = CPXchgcoef 217 // // status = CPXchgcoef(env, lp, i, 2, value_rng); 218 218 // } 219 219 220 220 void LpCplex::_setObjCoeff(int i, Value obj_coef) 221 221 { 222 CPXchgcoef 222 CPXchgcoef(env, lp, 1, i, obj_coef); 223 223 } 224 224 225 225 void LpCplex::_clearObj() 226 226 { 227 for (int i=0;i< CPXgetnumcols 228 CPXchgcoef 227 for (int i=0;i< CPXgetnumcols(env, lp);++i){ 228 CPXchgcoef(env, lp, 1, i, 0); 229 229 } 230 230 … … 242 242 { 243 243 //CPX_PARAM_LPMETHOD 244 status = CPXlpopt 244 status = CPXlpopt(env, lp); 245 245 if (status == 0){ 246 246 //We want to exclude some cases 247 switch (CPXgetstat 247 switch (CPXgetstat(env, lp)){ 248 248 case CPX_OBJ_LIM: 249 249 case CPX_IT_LIM_FEAS: … … 264 264 { 265 265 Value x; 266 CPXgetx 266 CPXgetx(env, lp, &x, i, i); 267 267 return x; 268 268 } … … 272 272 Value objval; 273 273 //method = CPXgetmethod (env, lp); 274 status = CPXgetobjval (env, lp, &objval); 274 //printf("CPXgetprobtype %d \n",CPXgetprobtype(env,lp)); 275 status = CPXgetobjval(env, lp, &objval); 276 //printf("Objective value: %g \n",objval); 275 277 return objval; 276 278 } … … 330 332 LpCplex::SolutionStatus LpCplex::_getPrimalStatus() 331 333 { 332 int stat = CPXgetstat (env, lp); 334 int stat = CPXgetstat(env, lp); 335 //printf("A primal status: %d, CPX_OPTIMAL=%d \n",stat,CPX_OPTIMAL); 333 336 switch (stat) { 334 337 case 0: … … 380 383 LpCplex::SolutionStatus LpCplex::_getDualStatus() 381 384 { 382 int stat = CPXgetstat 385 int stat = CPXgetstat(env, lp); 383 386 switch (stat) { 384 387 case 0: … … 396 399 LpCplex::ProblemTypes LpCplex::_getProblemType() 397 400 { 398 int stat = CPXgetstat 401 int stat = CPXgetstat(env, lp); 399 402 switch (stat) { 400 403 case CPX_OPTIMAL://Optimal … … 415 418 void LpCplex::_setMax() 416 419 { 417 CPXchgobjsen 420 CPXchgobjsen(env, lp, CPX_MAX); 418 421 } 419 422 void LpCplex::_setMin() 420 423 { 421 CPXchgobjsen 424 CPXchgobjsen(env, lp, CPX_MIN); 422 425 } 423 426 
lemon/lp_skeleton.h
r1460 r1508 23 23 ///\brief A skeleton file to implement LP solver interfaces 24 24 namespace lemon { 25 25 26 26 ///A skeleton class to implement LP solver interfaces 27 27 class LpSkeleton :public LpSolverBase { 
test/lp_test.cc
r1493 r1508 18 18 void lpTest(LpSolverBase & lp) 19 19 { 20 21 22 20 23 typedef LpSolverBase LP; 21 24 … … 23 26 // for(int i=0;i<10;i++) x.push_back(lp.addCol()); 24 27 lp.addColSet(x); 28 29 #ifndef GYORSITAS 25 30 26 31 std::vector<LP::Col> y(10); … … 175 180 } 176 181 177 182 #endif 178 183 } 179 184 … … 241 246 242 247 #ifdef HAVE_CPLEX 243 // LpCplex lp_cplex; 244 // lpTest(lp_cplex); 248 LpCplex lp_cplex; 249 lpTest(lp_cplex); 250 aTest(lp_cplex); 245 251 #endif 246 252
Note: See TracChangeset
for help on using the changeset viewer.