# HG changeset patch # User athos # Date 1118407843 0 # Node ID 876c7b7f4dae5f3b5ecb6d099bca5219884490ed # Parent c3bda060cfa375dc593f950d01e2e93b42122ba6 Some tests have been developed, bugs got fixed. diff -r c3bda060cfa3 -r 876c7b7f4dae lemon/lp_cplex.cc --- a/lemon/lp_cplex.cc Fri Jun 10 12:22:22 2005 +0000 +++ b/lemon/lp_cplex.cc Fri Jun 10 12:50:43 2005 +0000 @@ -391,8 +391,8 @@ return UNDEFINED; //Everything else comes here //FIXME error } + } - LpCplex::ProblemTypes LpCplex::_getProblemType() { int stat = CPXgetstat (env, lp); @@ -410,7 +410,7 @@ return UNKNOWN; //FIXME error } - + } void LpCplex::_setMax() { diff -r c3bda060cfa3 -r 876c7b7f4dae lemon/lp_glpk.cc --- a/lemon/lp_glpk.cc Fri Jun 10 12:22:22 2005 +0000 +++ b/lemon/lp_glpk.cc Fri Jun 10 12:50:43 2005 +0000 @@ -21,7 +21,7 @@ ///\brief Implementation of the LEMON-GLPK lp solver interface. #include - +//#include namespace lemon { @@ -439,15 +439,18 @@ LpGlpk::SolutionStatus LpGlpk::_getDualStatus() { +// std::cout<<"Itt megy: "< +#include "test_tools.h" #ifdef HAVE_CONFIG_H #include @@ -170,6 +171,53 @@ } +void aTest(LpSolverBase & lp) +{ + typedef LpSolverBase LP; + + //The following example is taken from the book by Gáspár and Temesi, page 39. + + typedef LpSolverBase::Row Row; + typedef LpSolverBase::Col Col; + + + Col x1 = lp.addCol(); + Col x2 = lp.addCol(); + + + //Constraints + lp.addRow(3*x1+2*x2 >=6); + lp.addRow(-1*x1+x2<=4); + lp.addRow(5*x1+8*x2<=40); + lp.addRow(x1-2*x2<=4); + //Nonnegativity of the variables + lp.colLowerBound(x1, 0); + lp.colLowerBound(x2, 0); + //Objective function + lp.setObj(2*x1+x2); + + lp.max(); + lp.solve(); + + + if (lp.primalStatus()==LpSolverBase::OPTIMAL){ + printf("Z = %g; x1 = %g; x2 = %g\n", + lp.primalValue(), + lp.primal(x1), lp.primal(x2)); + } + else{ + std::cout<<"Optimal solution not found!"<