COIN-OR::LEMON - Graph Library

Ignore:
Files:
1 added
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    r1185 r1232  
    6262FIND_PACKAGE(Doxygen)
    6363FIND_PACKAGE(Ghostscript)
    64 FIND_PACKAGE(GLPK 4.33)
    65 FIND_PACKAGE(CPLEX)
    66 FIND_PACKAGE(COIN)
     64
     65SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
     66SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
     67SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
     68
     69IF(LEMON_ENABLE_GLPK)
     70  FIND_PACKAGE(GLPK 4.33)
     71ENDIF(LEMON_ENABLE_GLPK)
     72IF(LEMON_ENABLE_ILOG)
     73  FIND_PACKAGE(ILOG)
     74ENDIF(LEMON_ENABLE_ILOG)
     75IF(LEMON_ENABLE_COIN)
     76  FIND_PACKAGE(COIN)
     77ENDIF(LEMON_ENABLE_COIN)
     78
     79IF(GLPK_FOUND)
     80  SET(LEMON_HAVE_LP TRUE)
     81  SET(LEMON_HAVE_MIP TRUE)
     82  SET(LEMON_HAVE_GLPK TRUE)
     83ENDIF(GLPK_FOUND)
     84IF(ILOG_FOUND)
     85  SET(LEMON_HAVE_LP TRUE)
     86  SET(LEMON_HAVE_MIP TRUE)
     87  SET(LEMON_HAVE_ILOG TRUE)
     88ENDIF(ILOG_FOUND)
     89IF(COIN_FOUND)
     90  SET(LEMON_HAVE_LP TRUE)
     91  SET(LEMON_HAVE_MIP TRUE)
     92  SET(LEMON_HAVE_CLP TRUE)
     93  SET(LEMON_HAVE_CBC TRUE)
     94ENDIF(COIN_FOUND)
     95
     96IF(ILOG_FOUND)
     97  SET(DEFAULT_LP "CPLEX")
     98  SET(DEFAULT_MIP "CPLEX")
     99ELSEIF(COIN_FOUND)
     100  SET(DEFAULT_LP "CLP")
     101  SET(DEFAULT_MIP "CBC")
     102ELSEIF(GLPK_FOUND)
     103  SET(DEFAULT_LP "GLPK")
     104  SET(DEFAULT_MIP "GLPK")
     105ENDIF()
     106
     107IF(NOT LEMON_DEFAULT_LP OR
     108    (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
     109    (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
     110    (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")))
     111  SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
     112    "Default LP solver backend (GLPK, CPLEX or CLP)" FORCE)
     113ENDIF()
     114IF(NOT LEMON_DEFAULT_MIP OR
     115    (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
     116    (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
     117    (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
     118  SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
     119    "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
     120ENDIF()
     121
    67122
    68123IF(DEFINED ENV{LEMON_CXX_WARNING})
  • INSTALL

    r1208 r1233  
    135135
    136136 
     137-DLEMON_ENABLE_GLPK=NO
     138-DLEMON_ENABLE_COIN=NO
     139-DLEMON_ENABLE_ILOG=NO
     140
     141  Enable optional third party libraries. They are all enabled by default.
     142
     143-DLEMON_DEFAULT_LP=GLPK
     144
     145  Sets the default LP solver backend. The supported values are
     146  CPLEX, CLP and GLPK. By default, it is set to the first one which
     147  is enabled and succesfully discovered.
     148
     149-DLEMON_DEFAULT_MIP=GLPK
     150
     151  Sets the default MIP solver backend. The supported values are
     152  CPLEX, CBC and GLPK. By default, it is set to the first one which
     153  is enabled and succesfully discovered.
     154
    137155-DGLPK_ROOT_DIR=DIRECTORY
    138156-DCOIN_ROOT_DIR=DIRECTORY
    139 -DCPLEX_ROOT_DIR=DIRECTORY
     157-DILOG_ROOT_DIR=DIRECTORY
    140158
    141   Install root directory prefixes of optional third party libraries.
     159  Root directory prefixes of optional third party libraries.
    142160
    143161Makefile Variables
  • cmake/FindCOIN.cmake

    r1120 r1232  
    109109  COIN_BZ2_LIBRARY
    110110)
    111 
    112 IF(COIN_FOUND)
    113   SET(LEMON_HAVE_LP TRUE)
    114   SET(LEMON_HAVE_MIP TRUE)
    115   SET(LEMON_HAVE_CLP TRUE)
    116   SET(LEMON_HAVE_CBC TRUE)
    117 ENDIF(COIN_FOUND)
  • cmake/FindGLPK.cmake

    r685 r1232  
    5454
    5555MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR)
    56 
    57 IF(GLPK_FOUND)
    58   SET(LEMON_HAVE_LP TRUE)
    59   SET(LEMON_HAVE_MIP TRUE)
    60   SET(LEMON_HAVE_GLPK TRUE)
    61 ENDIF(GLPK_FOUND)
  • lemon/CMakeLists.txt

    r1133 r1230  
    3737IF(LEMON_HAVE_CPLEX)
    3838  SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc)
    39   INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS})
     39  INCLUDE_DIRECTORIES(${ILOG_INCLUDE_DIRS})
    4040ENDIF()
    4141
  • lemon/cbc.h

    r956 r1232  
    1717 */
    1818
    19 // -*- C++ -*-
    2019#ifndef LEMON_CBC_H
    2120#define LEMON_CBC_H
  • lemon/config.h.in

    r1133 r1232  
    77#cmakedefine LEMON_HAVE_CLP 1
    88#cmakedefine LEMON_HAVE_CBC 1
     9#cmakedefine LEMON_DEFAULT_LP @LEMON_DEFAULT_LP@
     10#cmakedefine LEMON_DEFAULT_MIP @LEMON_DEFAULT_MIP@
    911#cmakedefine LEMON_USE_PTHREAD 1
    1012#cmakedefine LEMON_USE_WIN32_THREADS 1
  • lemon/cplex.cc

    r1183 r1231  
    492492                   _message_enabled ? CPX_ON : CPX_OFF);
    493493  }
     494
     495  void CplexBase::_write(std::string file, std::string format) const
     496  {
     497    if(format == "MPS" || format == "LP")
     498      CPXwriteprob(cplexEnv(), cplexLp(), file.c_str(), format.c_str());
     499    else if(format == "SOL")
     500      CPXsolwrite(cplexEnv(), cplexLp(), file.c_str());
     501    else throw UnsupportedFormatError(format);
     502  }
     503
     504
    494505
    495506  // CplexLp members
  • lemon/cplex.h

    r793 r1231  
    151151    bool _message_enabled;
    152152
     153    void _write(std::string file, std::string format) const;
     154
    153155  public:
    154156
     
    171173    const cpxlp* cplexLp() const { return _prob; }
    172174
     175#ifdef DOXYGEN
     176    /// Write the problem or the solution to a file in the given format
     177
     178    /// This function writes the problem or the solution
     179    /// to a file in the given format.
     180    /// Trying to write in an unsupported format will trigger
     181    /// \ref UnsupportedFormatError.
     182    /// \param file The file path
     183    /// \param format The output file format.
     184    /// Supportted formats are "MPS", "LP" and "SOL".
     185    void write(std::string file, std::string format = "MPS") const {}
     186#endif
     187
    173188  };
    174189
  • lemon/glpk.cc

    r1142 r1231  
    581581      break;
    582582    }
     583  }
     584
     585  void GlpkBase::_write(std::string file, std::string format) const
     586  {
     587    if(format == "MPS")
     588      glp_write_mps(lp, GLP_MPS_FILE, 0, file.c_str());
     589    else if(format == "LP")
     590      glp_write_lp(lp, 0, file.c_str());
     591    else throw UnsupportedFormatError(format);
    583592  }
    584593
     
    9991008  const char* GlpkMip::_solverName() const { return "GlpkMip"; }
    10001009
     1010
     1011
    10011012} //END OF NAMESPACE LEMON
  • lemon/glpk.h

    r956 r1231  
    116116    virtual void _messageLevel(MessageLevel level);
    117117
     118    virtual void _write(std::string file, std::string format) const;
     119
    118120  private:
    119121
     
    145147    int lpxCol(Col c) const { return cols(id(c)); }
    146148
     149#ifdef DOXYGEN
     150    /// Write the problem or the solution to a file in the given format
     151   
     152    /// This function writes the problem or the solution
     153    /// to a file in the given format.
     154    /// Trying to write in an unsupported format will trigger
     155    /// \ref UnsupportedFormatError.
     156    /// \param file The file path
     157    /// \param format The output file format.
     158    /// Supportted formats are "MPS" and "LP".
     159    void write(std::string file, std::string format = "MPS") const {}
     160#endif
     161
    147162  };
    148163
  • lemon/lp.h

    r956 r1232  
    6060  ///\ingroup lp_group
    6161  ///
    62   ///Currently, the possible values are \c GLPK or \c CPLEX
     62  ///Currently, the possible values are \c GLPK, \c CPLEX or \c CBC
    6363#define LEMON_DEFAULT_MIP SOLVER
    6464  ///The default MIP solver.
     
    6767  ///\ingroup lp_group
    6868  ///
    69   ///Currently, it is either \c GlpkMip or \c CplexMip
     69  ///Currently, it is either \c GlpkMip, \c CplexMip , \c CbcMip
    7070  typedef GlpkMip Mip;
    7171#else
    72 #ifdef LEMON_HAVE_GLPK
    73 # define LEMON_DEFAULT_LP GLPK
     72#if LEMON_DEFAULT_LP == GLPK
    7473  typedef GlpkLp Lp;
    75 # define LEMON_DEFAULT_MIP GLPK
    76   typedef GlpkMip Mip;
    77 #elif LEMON_HAVE_CPLEX
    78 # define LEMON_DEFAULT_LP CPLEX
     74#elif LEMON_DEFAULT_LP == CPLEX
    7975  typedef CplexLp Lp;
    80 # define LEMON_DEFAULT_MIP CPLEX
     76#elif LEMON_DEFAULT_LP == SOPLEX
     77  typedef SoplexLp Lp;
     78#elif LEMON_DEFAULT_LP == CLP
     79  typedef ClpLp Lp;
     80#endif
     81#if LEMON_DEFAULT_MIP == GLPK
     82  typedef GlpkLp Mip;
     83#elif LEMON_DEFAULT_MIP == CPLEX
    8184  typedef CplexMip Mip;
    82 #elif LEMON_HAVE_SOPLEX
    83 # define DEFAULT_LP SOPLEX
    84   typedef SoplexLp Lp;
    85 #elif LEMON_HAVE_CLP
    86 # define DEFAULT_LP CLP
    87   typedef ClpLp Lp;
     85#elif LEMON_DEFAULT_MIP == CBC
     86  typedef CbcMip Mip;
    8887#endif
    8988#endif
  • lemon/lp_base.h

    r1143 r1231  
    10081008  public:
    10091009
     1010    ///\e
     1011    class UnsupportedFormatError : public Exception
     1012    {
     1013      std::string _format;
     1014      mutable std::string _what;
     1015    public:
     1016      explicit UnsupportedFormatError(std::string format) throw()
     1017        : _format(format) { }
     1018      virtual ~UnsupportedFormatError() throw() {}
     1019      virtual const char* what() const throw() {
     1020        try {
     1021          _what.clear();
     1022          std::ostringstream oss;
     1023          oss << "lemon::UnsupportedFormatError: " << _format;
     1024          _what = oss.str();
     1025        }
     1026        catch (...) {}
     1027        if (!_what.empty()) return _what.c_str();
     1028        else return "lemon::UnsupportedFormatError";
     1029      }
     1030    };
     1031   
     1032  protected:
     1033    virtual void _write(std::string, std::string format) const
     1034    {
     1035      throw UnsupportedFormatError(format);
     1036    }
     1037   
     1038  public:
     1039
    10101040    /// Virtual destructor
    10111041    virtual ~LpBase() {}
     
    15561586    void min() { _setSense(MIN); }
    15571587
    1558     ///Clears the problem
     1588    ///Clear the problem
    15591589    void clear() { _clear(); rows.clear(); cols.clear(); }
    15601590
    1561     /// Sets the message level of the solver
     1591    /// Set the message level of the solver
    15621592    void messageLevel(MessageLevel level) { _messageLevel(level); }
     1593
     1594    /// Write the problem to a file in the given format
     1595
     1596    /// This function writes the problem to a file in the given format.
     1597    /// Different solver backends may support different formats.
     1598    /// Trying to write in an unsupported format will trigger
     1599    /// \ref UnsupportedFormatError. For the supported formats,
     1600    /// visit the documentation of the base class of the related backends
     1601    /// (\ref CplexBase, \ref GlpkBase etc.)
     1602    /// \param file The file path
     1603    /// \param format The output file format.
     1604    void write(std::string file, std::string format = "MPS") const
     1605    {
     1606      _write(file.c_str(),format.c_str());
     1607    }
    15631608
    15641609    ///@}
  • lemon/lp_skeleton.cc

    r956 r1231  
    9292  void SkeletonSolverBase::_messageLevel(MessageLevel) {}
    9393
     94  void SkeletonSolverBase::_write(std::string, std::string) const {}
     95
    9496  LpSkeleton::SolveExitStatus LpSkeleton::_solve() { return SOLVED; }
    9597
  • lemon/lp_skeleton.h

    r956 r1231  
    145145    ///\e
    146146    virtual void _messageLevel(MessageLevel);
     147
     148    ///\e
     149    virtual void _write(std::string file, std::string format) const;
     150
    147151  };
    148152
     
    223227    ///\e
    224228    virtual const char* _solverName() const;
     229
    225230  };
    226231
  • test/CMakeLists.txt

    r1228 r1233  
    7070  ENDIF()
    7171  IF(LEMON_HAVE_CPLEX)
    72     SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
     72    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${ILOG_LIBRARIES})
    7373  ENDIF()
    7474  IF(LEMON_HAVE_CLP)
     
    9494    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    9595    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
    96       COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex.dll ${TARGET_PATH}
     96      COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH}
    9797    )
    9898  ENDIF()
     
    112112  ENDIF()
    113113  IF(LEMON_HAVE_CPLEX)
    114     SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
     114    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${ILOG_LIBRARIES})
    115115  ENDIF()
    116116  IF(LEMON_HAVE_CBC)
     
    136136    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    137137    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
    138       COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex.dll ${TARGET_PATH}
     138      COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH}
    139139    )
    140140  ENDIF()
  • test/lp_test.cc

    r1140 r1232  
    241241  {
    242242    LP::DualExpr e,f,g;
    243     LP::Row p1 = INVALID, p2 = INVALID, p3 = INVALID,
    244       p4 = INVALID, p5 = INVALID;
     243    LP::Row p1 = INVALID, p2 = INVALID;
    245244
    246245    e[p1]=2;
Note: See TracChangeset for help on using the changeset viewer.