COIN-OR::LEMON - Graph Library

Changeset 2147:63d293ff1bef in lemon-0.x


Ignore:
Timestamp:
07/17/06 11:31:41 (18 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2861
Message:

mip_test file went to mip_demo.

Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • demo/Makefile.am

    r2119 r2147  
    2525
    2626if HAVE_GLPK
    27 noinst_PROGRAMS += demo/lp_demo demo/lp_maxflow_demo
     27noinst_PROGRAMS += demo/lp_demo demo/lp_maxflow_demo demo/mip_demo
    2828else !HAVE_GLPK
    2929if HAVE_CPLEX
     
    6363demo_lp_demo_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS)
    6464
     65demo_mip_demo_SOURCES = demo/mip_demo.cc
     66demo_mip_demo_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS)
     67
    6568demo_lp_maxflow_demo_SOURCES = demo/lp_maxflow_demo.cc
    6669demo_lp_maxflow_demo_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS)
  • test/mip_test.cc

    r2146 r2147  
    11#include <lemon/lp.h>
    2 //#include <lemon/ilp_glpk.h>
    32
    43using namespace lemon;
     
    65int main(){
    76
    8   //MipGlpk ilp;
    97
    10    Mip ilp;
     8#ifdef HAVE_GLPK
     9  //This needs some thinking
     10#endif
    1111
    12    
    13   typedef Mip::Row Row;
    14   typedef Mip::Col Col;
    15  
    16   ilp.max();
    17  
    18   Col x1 = ilp.addCol();
    19   Col x2 = ilp.addCol();
    20   Col x3 = ilp.addCol();
    21  
    22   ilp.integer(x1,true);
    23   ilp.integer(x2,true);
    24   ilp.integer(x3,true);
    25  
    26   ilp.addRow(x1+x2+x3 <=100); 
    27   ilp.addRow(10*x1+4*x2+5*x3<=600); 
    28   ilp.addRow(2*x1+2*x2+6*x3<=300);
    29  
    30   ilp.colLowerBound(x1, 0);
    31   ilp.colLowerBound(x2, 0);
    32   ilp.colLowerBound(x3, 0);
    33   //Objective function
    34   ilp.setObj(10*x1+6*x2+4*x3);
    35  
    36   //Call the routine of the underlying LP solver
    37   ilp.solve();
    38  
    39   //Print results
    40   if (ilp.primalStatus()==LpSolverBase::OPTIMAL){
    41     std::cout<<"Optimal solution found!"<<std::endl;
    42     printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n",
    43            ilp.primalValue(),
    44            ilp.primal(x1), ilp.primal(x2), ilp.primal(x3));
    45   }
    46   else{
    47     std::cout<<"Optimal solution not found!"<<std::endl;
    48   }
     12  return 0;
    4913
    5014}
Note: See TracChangeset for help on using the changeset viewer.