# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1369457971 -7200
# Node ID 561cac8fe04f8e46f5324eae58a551016cc222db
# Parent 473c71baff72fa87fce601589e9ac07e88c3e98d
Enable/disable options for LP/MIP backends (#465)
diff --git a/CMakeLists.txt b/CMakeLists.txt
a
|
b
|
|
61 | 61 | |
62 | 62 | FIND_PACKAGE(Doxygen) |
63 | 63 | FIND_PACKAGE(Ghostscript) |
64 | | FIND_PACKAGE(GLPK 4.33) |
65 | | FIND_PACKAGE(CPLEX) |
66 | | FIND_PACKAGE(COIN) |
| 64 | |
| 65 | SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.") |
| 66 | SET(LEMON_ENABLE_CPLEX YES CACHE STRING "Enable CPLEX solver backend.") |
| 67 | SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.") |
| 68 | |
| 69 | IF(LEMON_ENABLE_GLPK) |
| 70 | FIND_PACKAGE(GLPK 4.33) |
| 71 | ENDIF(LEMON_ENABLE_GLPK) |
| 72 | IF(LEMON_ENABLE_CPLEX) |
| 73 | FIND_PACKAGE(CPLEX) |
| 74 | ENDIF(LEMON_ENABLE_CPLEX) |
| 75 | IF(LEMON_ENABLE_COIN) |
| 76 | FIND_PACKAGE(COIN) |
| 77 | ENDIF(LEMON_ENABLE_COIN) |
| 78 | |
| 79 | IF(GLPK_FOUND) |
| 80 | SET(LEMON_HAVE_LP TRUE) |
| 81 | SET(LEMON_HAVE_MIP TRUE) |
| 82 | SET(LEMON_HAVE_GLPK TRUE) |
| 83 | ENDIF(GLPK_FOUND) |
| 84 | IF(CPLEX_FOUND) |
| 85 | SET(LEMON_HAVE_LP TRUE) |
| 86 | SET(LEMON_HAVE_MIP TRUE) |
| 87 | SET(LEMON_HAVE_CPLEX TRUE) |
| 88 | ENDIF(CPLEX_FOUND) |
| 89 | IF(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) |
| 94 | ENDIF(COIN_FOUND) |
| 95 | |
| 96 | IF(CPLEX_FOUND) |
| 97 | SET(DEFAULT_LP "CPLEX") |
| 98 | SET(DEFAULT_MIP "CPLEX") |
| 99 | ELSEIF(COIN_FOUND) |
| 100 | SET(DEFAULT_LP "CLP") |
| 101 | SET(DEFAULT_MIP "CBC") |
| 102 | ELSEIF(GLPK_FOUND) |
| 103 | SET(DEFAULT_LP "GLPK") |
| 104 | SET(DEFAULT_MIP "GLPK") |
| 105 | ENDIF() |
| 106 | |
| 107 | IF(NOT LEMON_DEFAULT_LP OR |
| 108 | (NOT CPLEX_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) |
| 113 | ENDIF() |
| 114 | IF(NOT LEMON_DEFAULT_MIP OR |
| 115 | (NOT CPLEX_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) |
| 120 | ENDIF() |
| 121 | |
67 | 122 | |
68 | 123 | IF(DEFINED ENV{LEMON_CXX_WARNING}) |
69 | 124 | SET(CXX_WARNING $ENV{LEMON_CXX_WARNING}) |
diff --git a/INSTALL b/INSTALL
a
|
b
|
|
134 | 134 | See http://docs.mathjax.org/en/latest/installation.html for more details. |
135 | 135 | |
136 | 136 | |
| 137 | -DLEMON_ENABLE_GLPK=NO |
| 138 | -DLEMON_ENABLE_COIN=NO |
| 139 | -DLEMON_ENABLE_CPLEX=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 | |
137 | 155 | -DGLPK_ROOT_DIR=DIRECTORY |
138 | 156 | -DCOIN_ROOT_DIR=DIRECTORY |
139 | 157 | -DCPLEX_ROOT_DIR=DIRECTORY |
140 | 158 | |
141 | | Install root directory prefixes of optional third party libraries. |
| 159 | Root directory prefixes of optional third party libraries. |
142 | 160 | |
143 | 161 | Makefile Variables |
144 | 162 | ================== |
diff --git a/cmake/FindCOIN.cmake b/cmake/FindCOIN.cmake
a
|
b
|
|
108 | 108 | COIN_ZLIB_LIBRARY |
109 | 109 | COIN_BZ2_LIBRARY |
110 | 110 | ) |
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) |
diff --git a/cmake/FindCPLEX.cmake b/cmake/FindCPLEX.cmake
a
|
b
|
|
32 | 32 | ENDIF(CPLEX_FOUND) |
33 | 33 | |
34 | 34 | MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_BIN_DIR) |
35 | | |
36 | | IF(CPLEX_FOUND) |
37 | | SET(LEMON_HAVE_LP TRUE) |
38 | | SET(LEMON_HAVE_MIP TRUE) |
39 | | SET(LEMON_HAVE_CPLEX TRUE) |
40 | | ENDIF(CPLEX_FOUND) |
diff --git a/cmake/FindGLPK.cmake b/cmake/FindGLPK.cmake
a
|
b
|
|
53 | 53 | ENDIF(GLPK_FOUND) |
54 | 54 | |
55 | 55 | MARK_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) |
diff --git a/lemon/cbc.h b/lemon/cbc.h
a
|
b
|
|
16 | 16 | * |
17 | 17 | */ |
18 | 18 | |
19 | | // -*- C++ -*- |
20 | 19 | #ifndef LEMON_CBC_H |
21 | 20 | #define LEMON_CBC_H |
22 | 21 | |
diff --git a/lemon/config.h.in b/lemon/config.h.in
a
|
b
|
|
6 | 6 | #cmakedefine LEMON_HAVE_CPLEX 1 |
7 | 7 | #cmakedefine LEMON_HAVE_CLP 1 |
8 | 8 | #cmakedefine LEMON_HAVE_CBC 1 |
| 9 | #cmakedefine LEMON_DEFAULT_LP @LEMON_DEFAULT_LP@ |
| 10 | #cmakedefine LEMON_DEFAULT_MIP @LEMON_DEFAULT_MIP@ |
9 | 11 | #cmakedefine LEMON_USE_PTHREAD 1 |
10 | 12 | #cmakedefine LEMON_USE_WIN32_THREADS 1 |
diff --git a/lemon/lp.h b/lemon/lp.h
a
|
b
|
|
59 | 59 | ///The default MIP solver identifier. |
60 | 60 | ///\ingroup lp_group |
61 | 61 | /// |
62 | | ///Currently, the possible values are \c GLPK or \c CPLEX |
| 62 | ///Currently, the possible values are \c GLPK, \c CPLEX or \c CBC |
63 | 63 | #define LEMON_DEFAULT_MIP SOLVER |
64 | 64 | ///The default MIP solver. |
65 | 65 | |
66 | 66 | ///The default MIP solver. |
67 | 67 | ///\ingroup lp_group |
68 | 68 | /// |
69 | | ///Currently, it is either \c GlpkMip or \c CplexMip |
| 69 | ///Currently, it is either \c GlpkMip, \c CplexMip , \c CbcMip |
70 | 70 | typedef GlpkMip Mip; |
71 | 71 | #else |
72 | | #ifdef LEMON_HAVE_GLPK |
73 | | # define LEMON_DEFAULT_LP GLPK |
| 72 | #if LEMON_DEFAULT_LP == GLPK |
74 | 73 | 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 |
79 | 75 | 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 |
81 | 84 | 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; |
88 | 87 | #endif |
89 | 88 | #endif |
90 | 89 | |
diff --git a/test/lp_test.cc b/test/lp_test.cc
a
|
b
|
|
240 | 240 | |
241 | 241 | { |
242 | 242 | 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; |
245 | 244 | |
246 | 245 | e[p1]=2; |
247 | 246 | e[p1]+=2; |