COIN-OR::LEMON - Graph Library

Changeset 567:3314f58e7b25 in lemon-1.2 for test


Ignore:
Timestamp:
04/01/09 22:58:58 (15 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

Add CBC support (#204)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mip_test.cc

    r551 r567  
    1919#include "test_tools.h"
    2020
    21 
    2221#ifdef HAVE_CONFIG_H
    2322#include <lemon/config.h>
     
    3029#ifdef HAVE_GLPK
    3130#include <lemon/glpk.h>
     31#endif
     32
     33#ifdef HAVE_CBC
     34#include <lemon/cbc.h>
    3235#endif
    3336
     
    5861void aTest(MipSolver& mip)
    5962{
    60  //The following example is very simple
     63  //The following example is very simple
    6164
    6265
    6366  typedef MipSolver::Row Row;
    6467  typedef MipSolver::Col Col;
    65 
    6668
    6769
     
    7577  mip.max();
    7678
    77 
    7879  //Unconstrained optimization
    7980  mip.solve();
     
    8182
    8283  //Constraints
    83   mip.addRow(2*x1+x2 <=2);
    84   mip.addRow(x1-2*x2 <=0);
     84  mip.addRow(2 * x1 + x2 <= 2);
     85  Row y2 = mip.addRow(x1 - 2 * x2 <= 0);
    8586
    8687  //Nonnegativity of the variable x1
    8788  mip.colLowerBound(x1, 0);
     89
    8890
    8991  //Maximization of x1
     
    9193  double expected_opt=4.0/5.0;
    9294  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
     95
    9396
    9497  //Restrict x2 to integer
     
    103106  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    104107
    105 
     108  //Erase a variable
     109  mip.erase(x2);
     110  mip.rowUpperBound(y2, 8);
     111  expected_opt=1;
     112  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    106113
    107114}
     115
    108116
    109117template<class MIP>
     
    145153#endif
    146154
     155#ifdef HAVE_CBC
     156  {
     157    CbcMip mip1;
     158    aTest(mip1);
     159    cloneTest<CbcMip>();
     160  }
     161#endif
     162
    147163  return 0;
    148164
Note: See TracChangeset for help on using the changeset viewer.