COIN-OR::LEMON - Graph Library

Changeset 459:ed54c0d13df0 in lemon-1.2 for test/mip_test.cc


Ignore:
Timestamp:
12/02/08 22:48:28 (11 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Children:
460:76ec7bd57026, 502:17cabb114d52
Phase:
public
Message:

Thorough redesign of the LP/MIP interface (#44)

  • Redesigned class structure
  • Redesigned iterators
  • Some functions in the basic interface redesigned
  • More complete setting functions
  • Ray retrieving functions
  • Lot of improvements
  • Cplex common env
  • CLP macro definition to config.h.in
  • Update lp.h to also use soplex and clp
  • Remove default_solver_name
  • New solverName() function in solvers
  • Handle exceptions for MipCplex? test
  • Rename tolerance parameter to epsilon
  • Rename MapIt? to CoeffIt?
  • Lot of documentation improvements
  • Various bugfixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mip_test.cc

    r458 r459  
    2525
    2626#ifdef HAVE_CPLEX
    27 #include <lemon/mip_cplex.h>
     27#include <lemon/lp_cplex.h>
    2828#endif
    2929
    3030#ifdef HAVE_GLPK
    31 #include <lemon/mip_glpk.h>
     31#include <lemon/lp_glpk.h>
    3232#endif
    3333
     
    3535using namespace lemon;
    3636
    37 void solveAndCheck(MipSolverBase& lp, MipSolverBase::SolutionStatus stat,
     37void solveAndCheck(MipSolver& mip, MipSolver::ProblemType stat,
    3838                   double exp_opt) {
    3939  using std::string;
    4040
    41   lp.solve();
     41  mip.solve();
    4242  //int decimal,sign;
    4343  std::ostringstream buf;
    44   buf << "Primalstatus should be: " << int(stat)
    45       <<" and it is "<<int(lp.mipStatus());
     44  buf << "Type should be: " << int(stat)<<" and it is "<<int(mip.type());
    4645
    4746
    4847  //  itoa(stat,buf1, 10);
    49   check(lp.mipStatus()==stat, buf.str());
     48  check(mip.type()==stat, buf.str());
    5049
    51   if (stat ==  MipSolverBase::OPTIMAL) {
     50  if (stat ==  MipSolver::OPTIMAL) {
    5251    std::ostringstream sbuf;
    5352    buf << "Wrong optimal value: the right optimum is " << exp_opt;
    54     check(std::abs(lp.primalValue()-exp_opt) < 1e-3, sbuf.str());
     53    check(std::abs(mip.solValue()-exp_opt) < 1e-3, sbuf.str());
    5554    //+ecvt(exp_opt,2)
    5655  }
    5756}
    5857
    59 void aTest(MipSolverBase& mip)
     58void aTest(MipSolver& mip)
    6059{
    6160 //The following example is very simple
    6261
    6362
    64   typedef MipSolverBase::Row Row;
    65   typedef MipSolverBase::Col Col;
     63  typedef MipSolver::Row Row;
     64  typedef MipSolver::Col Col;
    6665
    6766
     
    9190  //over the triangle with vertices (0,0),(4/5,2/5),(0,2)
    9291  double expected_opt=4.0/5.0;
    93   solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
     92  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    9493
    9594  //Restrict x2 to integer
    96   mip.colType(x2,MipSolverBase::INT);
     95  mip.colType(x2,MipSolver::INTEGER);
    9796  expected_opt=1.0/2.0;
    98   solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
     97  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    9998
    10099
    101100  //Restrict both to integer
    102   mip.colType(x1,MipSolverBase::INT);
     101  mip.colType(x1,MipSolver::INTEGER);
    103102  expected_opt=0;
    104   solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
     103  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    105104
    106105
     
    113112
    114113#ifdef HAVE_GLPK
    115   MipGlpk mip1;
    116   aTest(mip1);
     114  {
     115    MipGlpk mip1;
     116    aTest(mip1);
     117  }
    117118#endif
    118119
    119120#ifdef HAVE_CPLEX
    120   MipCplex mip2;
    121   aTest(mip2);
     121  try {
     122    MipCplex mip2;
     123    aTest(mip2);
     124  } catch (CplexEnv::LicenseError& error) {
     125#ifdef LEMON_FORCE_CPLEX_CHECK
     126    check(false, error.what());
     127#else
     128    std::cerr << error.what() << std::endl;
     129    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
     130#endif
     131  }
    122132#endif
    123133
Note: See TracChangeset for help on using the changeset viewer.