diff -r d8475431bbbb -r 8e85e6bbefdf src/demo/lp_demo.cc --- a/src/demo/lp_demo.cc Sat May 21 21:04:57 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - - -#ifdef HAVE_GLPK -#include -#elif HAVE_CPLEX -#include -#endif - -using namespace lemon; - -#ifdef HAVE_GLPK -typedef LpGlpk LpDefault; -#elif HAVE_CPLEX -typedef LpCplex LpDefault; -#endif - -int main() -{ - //The following example is taken from the documentation of the GLPK library. - //See it in the GLPK reference manual and among the GLPK sample files (sample.c) - LpDefault lp; - typedef LpDefault::Row Row; - typedef LpDefault::Col Col; - - lp.max(); - - Col x1 = lp.addCol(); - Col x2 = lp.addCol(); - Col x3 = lp.addCol(); - - //One solution - // Row p = lp.addRow(); - // Row q = lp.addRow(); - // Row r = lp.addRow(); - // lp.setRow(p,x1+x2+x3 <=100); - // lp.setRow(q,10*x1+4*x2+5*x3<=600); - // lp.setRow(r,2*x1+2*x2+6*x3<=300); - - //A more elegant one - //Constraints - lp.addRow(x1+x2+x3 <=100); - lp.addRow(10*x1+4*x2+5*x3<=600); - lp.addRow(2*x1+2*x2+6*x3<=300); - //Nonnegativity of the variables - lp.colLowerBound(x1, 0); - lp.colLowerBound(x2, 0); - lp.colLowerBound(x3, 0); - //Objective function - lp.setObj(10*x1+6*x2+4*x3); - - lp.solve(); - - if (lp.primalStatus()==LpSolverBase::OPTIMAL){ - printf("Z = %g; x1 = %g; x2 = %g; x3 = %g\n", - lp.primalValue(), - lp.primal(x1), lp.primal(x2), lp.primal(x3)); - } - else{ - std::cout<<"Optimal solution not found!"<