COIN-OR::LEMON - Graph Library

Changes in / [572:be6646ac5d89:573:37216ca5b9c6] in lemon-main


Ignore:
Files:
3 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • INSTALL

    r564 r568  
    151151
    152152   Disable SoPlex support.
     153
     154--with-coin[=PREFIX]
     155
     156   Enable support for COIN-OR solvers (CLP and CBC). You should
     157   specify the prefix too. (by default, COIN-OR tools install
     158   themselves to the source code directory). This command enables the
     159   solvers that are actually found.
     160
     161--with-coin-includedir=DIR
     162
     163   The directory where the COIN-OR header files are located. This is
     164   only useful when the COIN-OR headers and libraries are not under
     165   the same prefix (which is unlikely).
     166
     167--with-coin-libdir=DIR
     168
     169   The directory where the COIN-OR libraries are located. This is only
     170   useful when the COIN-OR headers and libraries are not under the
     171   same prefix (which is unlikely).
     172
     173--without-coin
     174
     175   Disable COIN-OR support.
  • Makefile.am

    r564 r567  
    1212        m4/lx_check_glpk.m4 \
    1313        m4/lx_check_soplex.m4 \
     14        m4/lx_check_clp.m4 \
     15        m4/lx_check_cbc.m4 \
    1416        CMakeLists.txt \
    1517        cmake/FindGhostscript.cmake \
  • configure.ac

    r564 r568  
    6060LX_CHECK_CPLEX
    6161LX_CHECK_SOPLEX
    62 LX_CHECK_CLP
     62LX_CHECK_COIN
    6363
    6464AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"])
     
    120120echo SOPLEX support................ : $lx_soplex_found
    121121echo CLP support................... : $lx_clp_found
     122echo CBC support................... : $lx_cbc_found
    122123echo
    123124echo Build additional tools........ : $enable_tools
  • lemon/Makefile.am

    r550 r567  
    1313        lemon/lp_base.cc \
    1414        lemon/lp_skeleton.cc \
    15         lemon/random.cc \
     15        lemon/random.cc \
    1616        lemon/bits/windows.cc
    1717
     
    2222        $(CPLEX_CFLAGS) \
    2323        $(SOPLEX_CXXFLAGS) \
    24         $(CLP_CXXFLAGS)
     24        $(CLP_CXXFLAGS) \
     25        $(CBC_CXXFLAGS)
    2526
    2627lemon_libemon_la_LDFLAGS = \
     
    2829        $(CPLEX_LIBS) \
    2930        $(SOPLEX_LIBS) \
    30         $(CLP_LIBS)
     31        $(CLP_LIBS) \
     32        $(CBC_LIBS)
    3133
    3234if HAVE_GLPK
     
    4446if HAVE_CLP
    4547lemon_libemon_la_SOURCES += lemon/clp.cc
     48endif
     49
     50if HAVE_CBC
     51lemon_libemon_la_SOURCES += lemon/cbc.cc
    4652endif
    4753
  • lemon/config.h.in

    r517 r567  
    1919/* Define to 1 if you have CLP */
    2020#undef HAVE_CLP
     21
     22/* Define to 1 if you have CBC */
     23#undef HAVE_CBC
  • lemon/glpk.cc

    r551 r566  
    534534    : LpBase(), LpSolver(), GlpkBase() {
    535535    messageLevel(MESSAGE_NO_OUTPUT);
     536    presolver(false);
    536537  }
    537538
     
    539540    : LpBase(other), LpSolver(other), GlpkBase(other) {
    540541    messageLevel(MESSAGE_NO_OUTPUT);
     542    presolver(false);
    541543  }
    542544
     
    575577      break;
    576578    }
    577 
    578     if (glp_simplex(lp, &smcp) != 0) return UNSOLVED;
     579    smcp.presolve = _presolve;
     580
     581    // If the basis is not valid we get an error return value.
     582    // In this case we can try to create a new basis.
     583    switch (glp_simplex(lp, &smcp)) {
     584    case 0:
     585      break;
     586    case GLP_EBADB:
     587    case GLP_ESING:
     588    case GLP_ECOND:
     589      glp_term_out(false);
     590      glp_adv_basis(lp, 0);
     591      glp_term_out(true);
     592      if (glp_simplex(lp, &smcp) != 0) return UNSOLVED;
     593      break;
     594    default:
     595      return UNSOLVED;
     596    }
     597
    579598    return SOLVED;
    580599  }
     
    601620    }
    602621    smcp.meth = GLP_DUAL;
    603 
    604     if (glp_simplex(lp, &smcp) != 0) return UNSOLVED;
     622    smcp.presolve = _presolve;
     623
     624    // If the basis is not valid we get an error return value.
     625    // In this case we can try to create a new basis.
     626    switch (glp_simplex(lp, &smcp)) {
     627    case 0:
     628      break;
     629    case GLP_EBADB:
     630    case GLP_ESING:
     631    case GLP_ECOND:
     632      glp_term_out(false);
     633      glp_adv_basis(lp, 0);
     634      glp_term_out(true);
     635      if (glp_simplex(lp, &smcp) != 0) return UNSOLVED;
     636      break;
     637    default:
     638      return UNSOLVED;
     639    }
    605640    return SOLVED;
    606641  }
     
    820855  }
    821856
    822   void GlpkLp::presolver(bool b) {
    823     lpx_set_int_parm(lp, LPX_K_PRESOL, b ? 1 : 0);
     857  void GlpkLp::presolver(bool presolve) {
     858    _presolve = presolve;
    824859  }
    825860
     
    882917    smcp.meth = GLP_DUAL;
    883918
    884     if (glp_simplex(lp, &smcp) != 0) return UNSOLVED;
     919    // If the basis is not valid we get an error return value.
     920    // In this case we can try to create a new basis.
     921    switch (glp_simplex(lp, &smcp)) {
     922    case 0:
     923      break;
     924    case GLP_EBADB:
     925    case GLP_ESING:
     926    case GLP_ECOND:
     927      glp_term_out(false);
     928      glp_adv_basis(lp, 0);
     929      glp_term_out(true);
     930      if (glp_simplex(lp, &smcp) != 0) return UNSOLVED;
     931      break;
     932    default:
     933      return UNSOLVED;
     934    }
     935
    885936    if (glp_get_status(lp) != GLP_OPT) return SOLVED;
    886937
  • lemon/glpk.h

    r542 r565  
    179179    SolveExitStatus solveDual();
    180180
     181  private:
     182
     183    bool _presolve;
     184
     185  public:
     186
    181187    ///Turns on or off the presolver
    182188
     
    184190    ///
    185191    ///The presolver is off by default.
    186     void presolver(bool b);
     192    void presolver(bool presolve);
    187193
    188194    ///Enum for \c messageLevel() parameter
  • 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
  • tools/dimacs-solver.cc

    r561 r569  
    116116           DimacsDescriptor &desc)
    117117{
    118   std::stringstream iss(ap["infcap"]);
     118  std::stringstream iss(static_cast<std::string>(ap["infcap"]));
    119119  Value infty;
    120120  iss >> infty;
  • tools/lgf-gen.cc

    r524 r570  
    3333#include <algorithm>
    3434#include <set>
     35#include <ctime>
    3536#include <lemon/list_graph.h>
    3637#include <lemon/random.h>
Note: See TracChangeset for help on using the changeset viewer.