COIN-OR::LEMON - Graph Library

Changeset 2218:50f1a780a5ff in lemon-0.x for test/mip_test.cc


Ignore:
Timestamp:
09/21/06 16:46:28 (18 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2952
Message:

Interface to the cplex MIP solver: it is little, a bit sour but it is ours.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mip_test.cc

    r2213 r2218  
    1 #include <lemon/lp.h>
    21#include "test_tools.h"
     2
     3
     4#include <lemon/mip_cplex.h>
     5#include <lemon/mip_glpk.h>
     6#include<lemon/config.h>
    37
    48using namespace lemon;
    59
    6 void solveAndCheck(Mip& lp, LpSolverBase::SolutionStatus stat,
     10void solveAndCheck(MipSolverBase& lp, MipSolverBase::SolutionStatus stat,
    711                   double exp_opt) {
    812  using std::string;
     13
    914  lp.solve();
    1015  //int decimal,sign;
     
    1217  buf << "Primalstatus should be: " << int(stat)<<" and it is "<<int(lp.primalStatus());
    1318
     19
    1420  //  itoa(stat,buf1, 10);
    1521  check(lp.mipStatus()==stat, buf.str());
    1622
    17   if (stat ==  LpSolverBase::OPTIMAL) {
     23  if (stat ==  MipSolverBase::OPTIMAL) {
    1824    std::ostringstream buf;
    1925    buf << "Wrong optimal value: the right optimum is " << exp_opt;
     
    2329}
    2430
    25 void aTest(Mip& mip)
     31void aTest(MipSolverBase& mip)
    2632{
    2733 //The following example is very simple
    2834
    29   typedef Mip::Row Row;
    30   typedef Mip::Col Col;
     35
     36  typedef MipSolverBase::Row Row;
     37  typedef MipSolverBase::Col Col;
     38
    3139
    3240
    3341  Col x1 = mip.addCol();
    3442  Col x2 = mip.addCol();
    35 
    36 
    37 
    38 
    3943
    4044
     
    6165  //over the triangle with vertices
    6266  double expected_opt=4.0/5.0;
    63   solveAndCheck(mip, Mip::OPTIMAL, expected_opt);
     67  solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
    6468
    6569  //Restrict x2 to integer
    66   mip.colType(x2,Mip::INTEGER); 
     70  mip.colType(x2,MipSolverBase::LEMON_INTEGER); 
    6771  expected_opt=1.0/2.0;
    68   solveAndCheck(mip, Mip::OPTIMAL, expected_opt);
     72  solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
    6973
    7074
    7175  //Restrict both to integer
    72   mip.colType(x1,Mip::INTEGER); 
     76  mip.colType(x1,MipSolverBase::LEMON_INTEGER); 
    7377  expected_opt=0;
    74   solveAndCheck(mip, Mip::OPTIMAL, expected_opt);
     78  solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
    7579
    7680 
     
    8791#endif
    8892
     93
     94
     95#ifdef HAVE_CPLEX
     96  //std::cout<<ATTILA<<INTEGER;
     97  MipCplex mip2;
     98  aTest(mip2);
     99#endif
     100
    89101  return 0;
    90102
Note: See TracChangeset for help on using the changeset viewer.