# HG changeset patch # User alpar # Date 1113603171 0 # Node ID a32f990b73d9888c46c28607ac4a79ff1bfc175d # Parent b4330c52caebcfdaf7a068727b76f96f0a053446 An unnecessary duplicate removed. diff -r b4330c52caeb -r a32f990b73d9 src/work/athos/lp/lp_sample.cc --- a/src/work/athos/lp/lp_sample.cc Fri Apr 15 21:15:30 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -#include -#include -using namespace lemon; - -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) - LpGlpk lp; - typedef LpGlpk::Row Row; - typedef LpGlpk::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!"<