Changes in / [1207:eba5aa390aca:1204:736a341e604b] in lemon-main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
cmake/FindILOG.cmake
r1205 r1126 97 97 IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") 98 98 # SET(CPLEX_LIBRARIES "${CPLEX_LIBRARIES};m;pthread") 99 SET(ILOG_LIBRARIES ${ILOG_LIBRARIES} "m" "pthread" "dl")99 SET(ILOG_LIBRARIES ${ILOG_LIBRARIES} "m" "pthread") 100 100 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") 101 101 ENDIF(ILOG_FOUND) -
lemon/clp.cc
r1206 r1130 228 228 229 229 ClpLp::Value ClpLp::_getCoeff(int ix, int jx) const { 230 CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ jx];231 CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ jx];230 CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix]; 231 CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ix]; 232 232 233 233 const int* indices = _prob->clpMatrix()->getIndices(); 234 234 const double* elements = _prob->clpMatrix()->getElements(); 235 235 236 const int* it = std::lower_bound(indices + begin, indices + end, ix);237 if (it != indices + end && *it == ix) {236 const int* it = std::lower_bound(indices + begin, indices + end, jx); 237 if (it != indices + end && *it == jx) { 238 238 return elements[it - indices]; 239 239 } else { … … 462 462 } 463 463 464 void ClpLp::_write(std::string file, std::string format) const465 {466 if(format == "LP")467 _prob->writeLp(file.c_str(), "", 1e-5, 10, 5,468 sense()==ClpLp::MIN?1:-1,469 true470 );471 else throw UnsupportedFormatError(format);472 }473 474 464 } //END OF NAMESPACE LEMON -
lemon/clp.h
r1206 r1130 140 140 virtual void _messageLevel(MessageLevel); 141 141 142 void _write(std::string file, std::string format) const;143 144 142 public: 145 143 -
lemon/cplex.cc
r1205 r1140 159 159 const char s = 'R'; 160 160 double len = ub - lb; 161 CPXaddrows(cplexEnv(), _prob, 0, 1, values.size(), & lb, &s,161 CPXaddrows(cplexEnv(), _prob, 0, 1, values.size(), &ub, &s, 162 162 &rmatbeg, &indices.front(), &values.front(), 0, 0); 163 163 CPXchgrngval(cplexEnv(), _prob, 1, &i, &len); -
test/lp_test.cc
r1205 r1131 340 340 check(lp.sense() == lp.MAX,"This is a maximization!"); 341 341 check(lp.coeff(upright,x1)==1,"The coefficient in question is 1!"); 342 check(lp.coeff(upright,x2)==2,"The coefficient in question is 1!");343 342 check(lp.colLowerBound(x1)==0, 344 343 "The lower bound for variable x1 should be 0."); … … 426 425 } 427 426 428 template<class LP>429 void rangeConstraintTest()430 {431 LP lp;432 // Add two columns (variables) to the problem433 typename LP::Col x1 = lp.addCol();434 typename LP::Col x2 = lp.addCol();435 // Add rows (constraints) to the problem436 lp.addRow(x1 - 5 <= x2);437 lp.addRow(0 <= 2 * x1 + x2 <= 25);438 439 // Set lower and upper bounds for the columns (variables)440 lp.colLowerBound(x1, 0);441 lp.colUpperBound(x2, 10);442 443 // Specify the objective function444 lp.max();445 lp.obj(5 * x1 + 3 * x2);446 447 // Solve the problem using the underlying LP solver448 lp.solve();449 // Print the results450 check(lp.primalType() == LP::OPTIMAL, "Optimal solution is not found");451 check(lp.primal() <= 67.501 && lp.primal() >= 67.499, "Wrong objective value");452 check(lp.primal(x1) <= 7.501 && lp.primal(x1) >= 7.499, "Wrong value for x1");453 check(lp.primal(x2) <= 10.001 && lp.primal(x2) >= 9.999, "Wrong value for x2");454 }455 456 427 int main() 457 428 { … … 474 445 aTest(lp_glpk2); 475 446 cloneTest<GlpkLp>(); 476 rangeConstraintTest<GlpkLp>();477 447 } 478 448 #endif … … 484 454 aTest(lp_cplex2); 485 455 cloneTest<CplexLp>(); 486 rangeConstraintTest<CplexLp>();487 456 } catch (CplexEnv::LicenseError& error) { 488 457 check(false, error.what()); … … 496 465 aTest(lp_soplex2); 497 466 cloneTest<SoplexLp>(); 498 rangeConstraintTest<Soplex>();499 467 } 500 468 #endif … … 506 474 aTest(lp_clp2); 507 475 cloneTest<ClpLp>(); 508 rangeConstraintTest<ClpLp>();509 476 } 510 477 #endif -
test/mip_test.cc
r1205 r1105 62 62 } 63 63 64 void aTest(MipSolver& mip , bool solve_empty=true)64 void aTest(MipSolver& mip) 65 65 { 66 66 //The following example is very simple … … 81 81 82 82 //Unconstrained optimization 83 if(solve_empty) 84 mip.solve(); 83 mip.solve(); 85 84 //Check it out! 86 85 … … 137 136 { 138 137 Mip mip1; 139 #if LEMON_DEFAULT_MIP==LEMON_CBC_140 aTest(mip1, false);141 #else142 138 aTest(mip1); 143 #endif144 139 cloneTest<Mip>(); 145 140 } … … 167 162 { 168 163 CbcMip mip1; 169 aTest(mip1 , false);164 aTest(mip1); 170 165 cloneTest<CbcMip>(); 171 166 }
Note: See TracChangeset
for help on using the changeset viewer.