Changeset 2218:50f1a780a5ff in lemon-0.x
- Timestamp:
- 09/21/06 16:46:28 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2952
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/Makefile.am
r2211 r2218 26 26 if HAVE_CPLEX 27 27 lemon_libemon_la_SOURCES += lemon/lp_cplex.cc 28 lemon_libemon_la_SOURCES += lemon/mip_cplex.cc 28 29 endif 29 30 … … 79 80 lemon/min_cut.h \ 80 81 lemon/mip_glpk.h \ 82 lemon/mip_cplex.h \ 81 83 lemon/path.h \ 82 84 lemon/polynomial.h \ -
lemon/lp.h
r2144 r2218 22 22 #include<lemon/config.h> 23 23 24 24 25 #ifdef HAVE_GLPK 25 26 #include <lemon/lp_glpk.h> … … 27 28 #elif HAVE_CPLEX 28 29 #include <lemon/lp_cplex.h> 30 #include <lemon/mip_cplex.h> 29 31 #endif 30 32 … … 33 35 ///\ingroup gen_opt_group 34 36 namespace lemon { 35 37 36 38 #ifdef DOXYGEN 37 39 ///The default LP solver identifier … … 73 75 #define DEFAULT_LP CPLEX 74 76 typedef LpCplex Lp; 77 typedef MipCplex Mip; 75 78 const char default_solver_name[]="CPLEX"; 76 79 #endif -
lemon/lp_base.h
r2185 r2218 76 76 return cross[n]; 77 77 } 78 ///\todo Create an own exception type. 79 else throw LogicError(); //floatingId-s must form a continuous range; 78 else { 79 ///\todo Create an own exception type. 80 throw LogicError(); //floatingId-s must form a continuous range; 81 } 80 82 } 81 83 ///Remove a fix id. … … 1170 1172 REAL = 0, 1171 1173 ///Integer variable 1172 INTEGER = 1 1174 1175 ///Unfortunately, cplex 7.5 somewhere writes something like 1176 ///#define INTEGER 'I' 1177 LEMON_INTEGER = 1 1173 1178 ///\todo No support for other types yet. 1174 1179 }; … … 1193 1198 void integer(Col c, bool enable) { 1194 1199 if (enable) 1195 colType(c, INTEGER);1200 colType(c,LEMON_INTEGER); 1196 1201 else 1197 1202 colType(c,REAL); … … 1203 1208 ///\return true if the column has integer type and false if not. 1204 1209 bool integer(Col c){ 1205 return (colType(c)== INTEGER);1210 return (colType(c)==LEMON_INTEGER); 1206 1211 } 1207 1212 -
lemon/lp_cplex.cc
r2168 r2218 270 270 status = CPXlpopt(env, lp); 271 271 //status = CPXprimopt(env, lp); 272 #if CPX_VERSION >= 900272 #if CPX_VERSION >= 800 273 273 if (status) 274 274 { … … 417 417 LpCplex::SolutionStatus LpCplex::_getPrimalStatus() 418 418 { 419 //Unboundedness not treated well: the following is from cplex 9.0 doc 420 // About Unboundedness 421 422 // The treatment of models that are unbounded involves a few 423 // subtleties. Specifically, a declaration of unboundedness means that 424 // ILOG CPLEX has determined that the model has an unbounded 425 // ray. Given any feasible solution x with objective z, a multiple of 426 // the unbounded ray can be added to x to give a feasible solution 427 // with objective z-1 (or z+1 for maximization models). Thus, if a 428 // feasible solution exists, then the optimal objective is 429 // unbounded. Note that ILOG CPLEX has not necessarily concluded that 430 // a feasible solution exists. Users can call the routine CPXsolninfo 431 // to determine whether ILOG CPLEX has also concluded that the model 432 // has a feasible solution. 433 419 434 int stat = CPXgetstat(env, lp); 420 #if CPX_VERSION >= 900435 #if CPX_VERSION >= 800 421 436 switch (stat) 422 437 { … … 486 501 { 487 502 int stat = CPXgetstat(env, lp); 488 #if CPX_VERSION >= 900503 #if CPX_VERSION >= 800 489 504 switch (stat) 490 505 { … … 515 530 { 516 531 int stat = CPXgetstat(env, lp); 517 #if CPX_VERSION >= 900532 #if CPX_VERSION >= 800 518 533 switch (stat) 519 534 { -
lemon/lp_cplex.h
r1956 r2218 35 35 /// 36 36 /// This class implements an interface for the CPLEX LP solver. 37 class LpCplex : public LpSolverBase {37 class LpCplex :virtual public LpSolverBase { 38 38 39 39 public: -
lemon/mip_glpk.cc
r2213 r2218 17 17 */ 18 18 19 #ifndef LEMON_ ILP_GLPK_CC20 #define LEMON_ ILP_GLPK_CC19 #ifndef LEMON_MIP_GLPK_CC 20 #define LEMON_MIP_GLPK_CC 21 21 22 22 ///\file 23 ///\brief Implementation of the LEMON-GLPK lp solver interface.23 ///\brief Implementation of the LEMON-GLPK mip solver interface. 24 24 25 25 #include <lemon/mip_glpk.h> … … 33 33 void MipGlpk::_colType(int i, MipGlpk::ColTypes col_type){ 34 34 switch (col_type){ 35 case INTEGER:35 case LEMON_INTEGER: 36 36 lpx_set_col_kind(lp,i,LPX_IV); 37 37 break; … … 47 47 switch (lpx_get_col_kind(lp,i)){ 48 48 case LPX_IV: 49 return INTEGER;//Or binary49 return LEMON_INTEGER;//Or binary 50 50 case LPX_CV: 51 51 return REAL; … … 111 111 return lpx_mip_obj_val(lp); 112 112 } 113 } //END O GNAMESPACE LEMON113 } //END OF NAMESPACE LEMON 114 114 115 #endif 115 #endif //END OF MIP_GLPK_CC -
lemon/mip_glpk.h
r2185 r2218 17 17 */ 18 18 19 #ifndef LEMON_ ILP_GLPK_H20 #define LEMON_ ILP_GLPK_H19 #ifndef LEMON_MIP_GLPK_H 20 #define LEMON_MIP_GLPK_H 21 21 22 22 ///\file 23 ///\brief Header of the LEMON-GLPK lp solver interface.23 ///\brief Header of the LEMON-GLPK mip solver interface. 24 24 ///\ingroup gen_opt_group 25 25 … … 28 28 29 29 namespace lemon { 30 /// \brief Interface for the GLPK ILP solver30 /// \brief Interface for the GLPK MIP solver 31 31 /// 32 /// This class implements an interface for the GLPK ILP solver.32 /// This class implements an interface for the GLPK MIP solver. 33 33 ///\ingroup gen_opt_group 34 34 class MipGlpk : public MipSolverBase, public LpGlpk{ … … 57 57 } //END OF NAMESPACE LEMON 58 58 59 #endif // END OF LEMON_ ILP_GLPK_H59 #endif // END OF LEMON_MIP_GLPK_H -
test/mip_test.cc
r2213 r2218 1 #include <lemon/lp.h>2 1 #include "test_tools.h" 2 3 4 #include <lemon/mip_cplex.h> 5 #include <lemon/mip_glpk.h> 6 #include<lemon/config.h> 3 7 4 8 using namespace lemon; 5 9 6 void solveAndCheck(Mip & lp, LpSolverBase::SolutionStatus stat,10 void solveAndCheck(MipSolverBase& lp, MipSolverBase::SolutionStatus stat, 7 11 double exp_opt) { 8 12 using std::string; 13 9 14 lp.solve(); 10 15 //int decimal,sign; … … 12 17 buf << "Primalstatus should be: " << int(stat)<<" and it is "<<int(lp.primalStatus()); 13 18 19 14 20 // itoa(stat,buf1, 10); 15 21 check(lp.mipStatus()==stat, buf.str()); 16 22 17 if (stat == LpSolverBase::OPTIMAL) {23 if (stat == MipSolverBase::OPTIMAL) { 18 24 std::ostringstream buf; 19 25 buf << "Wrong optimal value: the right optimum is " << exp_opt; … … 23 29 } 24 30 25 void aTest(Mip & mip)31 void aTest(MipSolverBase& mip) 26 32 { 27 33 //The following example is very simple 28 34 29 typedef Mip::Row Row; 30 typedef Mip::Col Col; 35 36 typedef MipSolverBase::Row Row; 37 typedef MipSolverBase::Col Col; 38 31 39 32 40 33 41 Col x1 = mip.addCol(); 34 42 Col x2 = mip.addCol(); 35 36 37 38 39 43 40 44 … … 61 65 //over the triangle with vertices 62 66 double expected_opt=4.0/5.0; 63 solveAndCheck(mip, Mip ::OPTIMAL, expected_opt);67 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt); 64 68 65 69 //Restrict x2 to integer 66 mip.colType(x2,Mip ::INTEGER);70 mip.colType(x2,MipSolverBase::LEMON_INTEGER); 67 71 expected_opt=1.0/2.0; 68 solveAndCheck(mip, Mip ::OPTIMAL, expected_opt);72 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt); 69 73 70 74 71 75 //Restrict both to integer 72 mip.colType(x1,Mip ::INTEGER);76 mip.colType(x1,MipSolverBase::LEMON_INTEGER); 73 77 expected_opt=0; 74 solveAndCheck(mip, Mip ::OPTIMAL, expected_opt);78 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt); 75 79 76 80 … … 87 91 #endif 88 92 93 94 95 #ifdef HAVE_CPLEX 96 //std::cout<<ATTILA<<INTEGER; 97 MipCplex mip2; 98 aTest(mip2); 99 #endif 100 89 101 return 0; 90 102
Note: See TracChangeset
for help on using the changeset viewer.