0
20
0
1
1
8
8
24
24
1 | 1 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
2 | 2 |
|
3 | 3 |
IF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake) |
4 | 4 |
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/version.cmake) |
5 | 5 |
ELSE(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake) |
6 | 6 |
SET(PROJECT_NAME "LEMON") |
7 | 7 |
SET(PROJECT_VERSION "hg-tip" CACHE STRING "LEMON version string.") |
8 | 8 |
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake) |
9 | 9 |
|
10 | 10 |
PROJECT(${PROJECT_NAME}) |
11 | 11 |
|
12 | 12 |
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
13 | 13 |
|
14 | 14 |
INCLUDE(FindDoxygen) |
15 | 15 |
INCLUDE(FindGhostscript) |
16 | 16 |
FIND_PACKAGE(GLPK 4.33) |
17 | 17 |
FIND_PACKAGE(CPLEX) |
18 | 18 |
FIND_PACKAGE(COIN) |
19 | 19 |
|
20 | 20 |
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
21 | 21 |
|
22 | 22 |
IF(MSVC) |
23 | 23 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4800 /wd4996") |
24 | 24 |
# Suppressed warnings: |
25 | 25 |
# C4250: 'class1' : inherits 'class2::member' via dominance |
26 | 26 |
# C4355: 'this' : used in base member initializer list |
27 | 27 |
# C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning) |
28 | 28 |
# C4996: 'function': was declared deprecated |
29 | 29 |
ENDIF(MSVC) |
30 | 30 |
|
31 |
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
|
32 |
|
|
31 | 33 |
INCLUDE(CheckTypeSize) |
32 |
CHECK_TYPE_SIZE("long long" |
|
34 |
CHECK_TYPE_SIZE("long long" LEMON_LONG_LONG) |
|
33 | 35 |
|
34 | 36 |
ENABLE_TESTING() |
35 | 37 |
|
36 | 38 |
ADD_SUBDIRECTORY(lemon) |
37 | 39 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
38 | 40 |
ADD_SUBDIRECTORY(demo) |
39 | 41 |
ADD_SUBDIRECTORY(tools) |
40 | 42 |
ADD_SUBDIRECTORY(doc) |
41 | 43 |
ADD_SUBDIRECTORY(test) |
42 | 44 |
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
43 | 45 |
|
44 | 46 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
45 | 47 |
IF(WIN32) |
46 | 48 |
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) |
47 | 49 |
SET(CPACK_PACKAGE_VENDOR "EGRES") |
48 | 50 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
49 | 51 |
"LEMON - Library of Efficient Models and Optimization in Networks") |
50 | 52 |
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") |
51 | 53 |
|
52 | 54 |
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) |
53 | 55 |
|
54 | 56 |
SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
55 | 57 |
"${PROJECT_NAME} ${PROJECT_VERSION}") |
56 | 58 |
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
57 | 59 |
"${PROJECT_NAME} ${PROJECT_VERSION}") |
58 | 60 |
|
59 | 61 |
SET(CPACK_COMPONENTS_ALL headers library html_documentation bin) |
60 | 62 |
|
61 | 63 |
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") |
62 | 64 |
SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") |
63 | 65 |
SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities") |
64 | 66 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") |
65 | 67 |
|
66 | 68 |
SET(CPACK_COMPONENT_HEADERS_DESCRIPTION |
67 | 69 |
"C++ header files") |
68 | 70 |
SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION |
69 | 71 |
"DLL and import library") |
70 | 72 |
SET(CPACK_COMPONENT_BIN_DESCRIPTION |
71 | 73 |
"Command line utilities") |
72 | 74 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION |
73 | 75 |
"Doxygen generated documentation") |
74 | 76 |
|
75 | 77 |
SET(CPACK_COMPONENT_HEADERS_DEPENDS library) |
76 | 78 |
|
77 | 79 |
SET(CPACK_COMPONENT_HEADERS_GROUP "Development") |
78 | 80 |
SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") |
79 | 81 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation") |
80 | 82 |
|
81 | 83 |
SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION |
82 | 84 |
"Components needed to develop software using LEMON") |
83 | 85 |
SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION |
84 | 86 |
"Documentation of LEMON") |
85 | 87 |
|
86 | 88 |
SET(CPACK_ALL_INSTALL_TYPES Full Developer) |
87 | 89 |
|
88 | 90 |
SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) |
89 | 91 |
SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full) |
90 | 92 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full) |
91 | 93 |
|
92 | 94 |
SET(CPACK_GENERATOR "NSIS") |
93 | 95 |
SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico") |
94 | 96 |
SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico") |
95 | 97 |
#SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp") |
96 | 98 |
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico") |
97 | 99 |
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") |
98 | 100 |
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu") |
99 | 101 |
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu") |
100 | 102 |
SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu") |
101 | 103 |
SET(CPACK_NSIS_CREATE_ICONS_EXTRA " |
102 | 104 |
CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\" |
103 | 105 |
") |
104 | 106 |
SET(CPACK_NSIS_DELETE_ICONS_EXTRA " |
105 | 107 |
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP |
106 | 108 |
Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\" |
107 | 109 |
") |
108 | 110 |
|
109 | 111 |
INCLUDE(CPack) |
110 | 112 |
ENDIF(WIN32) |
111 | 113 |
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
1 | 1 |
SET(COIN_ROOT_DIR "" CACHE PATH "COIN root directory") |
2 | 2 |
|
3 | 3 |
FIND_PATH(COIN_INCLUDE_DIR coin/CoinUtilsConfig.h |
4 | 4 |
PATHS ${COIN_ROOT_DIR}/include) |
5 | 5 |
|
6 | 6 |
FIND_LIBRARY(COIN_CBC_LIBRARY libCbc |
7 | 7 |
PATHS ${COIN_ROOT_DIR}/lib) |
8 | 8 |
FIND_LIBRARY(COIN_CBC_SOLVER_LIBRARY libCbcSolver |
9 | 9 |
PATHS ${COIN_ROOT_DIR}/lib) |
10 | 10 |
FIND_LIBRARY(COIN_CGL_LIBRARY libCgl |
11 | 11 |
PATHS ${COIN_ROOT_DIR}/lib) |
12 | 12 |
FIND_LIBRARY(COIN_CLP_LIBRARY libClp |
13 | 13 |
PATHS ${COIN_ROOT_DIR}/lib) |
14 | 14 |
FIND_LIBRARY(COIN_COIN_UTILS_LIBRARY libCoinUtils |
15 | 15 |
PATHS ${COIN_ROOT_DIR}/lib) |
16 | 16 |
FIND_LIBRARY(COIN_OSI_LIBRARY libOsi |
17 | 17 |
PATHS ${COIN_ROOT_DIR}/lib) |
18 | 18 |
FIND_LIBRARY(COIN_OSI_CBC_LIBRARY libOsiCbc |
19 | 19 |
PATHS ${COIN_ROOT_DIR}/lib) |
20 | 20 |
FIND_LIBRARY(COIN_OSI_CLP_LIBRARY libOsiClp |
21 | 21 |
PATHS ${COIN_ROOT_DIR}/lib) |
22 | 22 |
FIND_LIBRARY(COIN_OSI_VOL_LIBRARY libOsiVol |
23 | 23 |
PATHS ${COIN_ROOT_DIR}/lib) |
24 | 24 |
FIND_LIBRARY(COIN_VOL_LIBRARY libVol |
25 | 25 |
PATHS ${COIN_ROOT_DIR}/lib) |
26 | 26 |
|
27 | 27 |
INCLUDE(FindPackageHandleStandardArgs) |
28 | 28 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG |
29 | 29 |
COIN_INCLUDE_DIR |
30 | 30 |
COIN_CBC_LIBRARY |
31 | 31 |
COIN_CBC_SOLVER_LIBRARY |
32 | 32 |
COIN_CGL_LIBRARY |
33 | 33 |
COIN_CLP_LIBRARY |
34 | 34 |
COIN_COIN_UTILS_LIBRARY |
35 | 35 |
COIN_OSI_LIBRARY |
36 | 36 |
COIN_OSI_CBC_LIBRARY |
37 | 37 |
COIN_OSI_CLP_LIBRARY |
38 | 38 |
COIN_OSI_VOL_LIBRARY |
39 | 39 |
COIN_VOL_LIBRARY |
40 | 40 |
) |
41 | 41 |
|
42 | 42 |
IF(COIN_FOUND) |
43 | 43 |
SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR}) |
44 | 44 |
SET(COIN_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_OSI_VOL_LIBRARY};${COIN_VOL_LIBRARY}") |
45 | 45 |
SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY}") |
46 | 46 |
SET(COIN_CBC_LIBRARIES ${COIN_LIBRARIES}) |
47 | 47 |
ENDIF(COIN_FOUND) |
48 | 48 |
|
49 | 49 |
MARK_AS_ADVANCED( |
50 | 50 |
COIN_INCLUDE_DIR |
51 | 51 |
COIN_CBC_LIBRARY |
52 | 52 |
COIN_CBC_SOLVER_LIBRARY |
53 | 53 |
COIN_CGL_LIBRARY |
54 | 54 |
COIN_CLP_LIBRARY |
55 | 55 |
COIN_COIN_UTILS_LIBRARY |
56 | 56 |
COIN_OSI_LIBRARY |
57 | 57 |
COIN_OSI_CBC_LIBRARY |
58 | 58 |
COIN_OSI_CLP_LIBRARY |
59 | 59 |
COIN_OSI_VOL_LIBRARY |
60 | 60 |
COIN_VOL_LIBRARY |
61 | 61 |
) |
62 | 62 |
|
63 | 63 |
IF(COIN_FOUND) |
64 |
SET(HAVE_LP TRUE) |
|
65 |
SET(HAVE_MIP TRUE) |
|
66 |
SET(HAVE_CLP TRUE) |
|
67 |
SET(HAVE_CBC TRUE) |
|
64 |
SET(LEMON_HAVE_LP TRUE) |
|
65 |
SET(LEMON_HAVE_MIP TRUE) |
|
66 |
SET(LEMON_HAVE_CLP TRUE) |
|
67 |
SET(LEMON_HAVE_CBC TRUE) |
|
68 | 68 |
ENDIF(COIN_FOUND) |
1 | 1 |
FIND_PATH(CPLEX_INCLUDE_DIR |
2 | 2 |
ilcplex/cplex.h |
3 | 3 |
PATHS "C:/ILOG/CPLEX91/include") |
4 | 4 |
|
5 | 5 |
FIND_LIBRARY(CPLEX_LIBRARY |
6 | 6 |
NAMES cplex91 |
7 | 7 |
PATHS "C:/ILOG/CPLEX91/lib/msvc7/stat_mda") |
8 | 8 |
|
9 | 9 |
INCLUDE(FindPackageHandleStandardArgs) |
10 | 10 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPLEX DEFAULT_MSG CPLEX_LIBRARY CPLEX_INCLUDE_DIR) |
11 | 11 |
|
12 | 12 |
FIND_PATH(CPLEX_BIN_DIR |
13 | 13 |
cplex91.dll |
14 | 14 |
PATHS "C:/ILOG/CPLEX91/bin/x86_win32") |
15 | 15 |
|
16 | 16 |
IF(CPLEX_FOUND) |
17 | 17 |
SET(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE_DIR}) |
18 | 18 |
SET(CPLEX_LIBRARIES ${CPLEX_LIBRARY}) |
19 | 19 |
ENDIF(CPLEX_FOUND) |
20 | 20 |
|
21 | 21 |
MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_BIN_DIR) |
22 | 22 |
|
23 | 23 |
IF(CPLEX_FOUND) |
24 |
SET(HAVE_LP TRUE) |
|
25 |
SET(HAVE_MIP TRUE) |
|
26 |
SET( |
|
24 |
SET(LEMON_HAVE_LP TRUE) |
|
25 |
SET(LEMON_HAVE_MIP TRUE) |
|
26 |
SET(LEMON_HAVE_CPLEX TRUE) |
|
27 | 27 |
ENDIF(CPLEX_FOUND) |
1 | 1 |
SET(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]") |
2 | 2 |
GET_FILENAME_COMPONENT(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE) |
3 | 3 |
|
4 | 4 |
FIND_PATH(GLPK_INCLUDE_DIR |
5 | 5 |
glpk.h |
6 | 6 |
PATHS ${GLPK_REGKEY}/include) |
7 | 7 |
|
8 | 8 |
FIND_LIBRARY(GLPK_LIBRARY |
9 | 9 |
NAMES glpk |
10 | 10 |
PATHS ${GLPK_REGKEY}/lib) |
11 | 11 |
|
12 | 12 |
INCLUDE(FindPackageHandleStandardArgs) |
13 | 13 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR) |
14 | 14 |
|
15 | 15 |
IF(GLPK_FOUND) |
16 | 16 |
SET(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR}) |
17 | 17 |
SET(GLPK_LIBRARIES ${GLPK_LIBRARY}) |
18 | 18 |
SET(GLPK_BIN_DIR ${GLPK_ROOT_PATH}/bin) |
19 | 19 |
ENDIF(GLPK_FOUND) |
20 | 20 |
|
21 | 21 |
MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR) |
22 | 22 |
|
23 | 23 |
IF(GLPK_FOUND) |
24 |
SET(HAVE_LP TRUE) |
|
25 |
SET(HAVE_MIP TRUE) |
|
26 |
SET( |
|
24 |
SET(LEMON_HAVE_LP TRUE) |
|
25 |
SET(LEMON_HAVE_MIP TRUE) |
|
26 |
SET(LEMON_HAVE_GLPK TRUE) |
|
27 | 27 |
ENDIF(GLPK_FOUND) |
1 | 1 |
dnl Process this file with autoconf to produce a configure script. |
2 | 2 |
|
3 | 3 |
dnl Version information. |
4 | 4 |
m4_define([lemon_version_number], |
5 | 5 |
[m4_normalize(esyscmd([echo ${LEMON_VERSION}]))]) |
6 | 6 |
dnl m4_define([lemon_version_number], []) |
7 | 7 |
m4_define([lemon_hg_path], [m4_normalize(esyscmd([./scripts/chg-len.py]))]) |
8 | 8 |
m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i]))]) |
9 | 9 |
m4_define([lemon_version], [ifelse(lemon_version_number(), |
10 | 10 |
[], |
11 | 11 |
[lemon_hg_path().lemon_hg_revision()], |
12 | 12 |
[lemon_version_number()])]) |
13 | 13 |
|
14 | 14 |
AC_PREREQ([2.59]) |
15 | 15 |
AC_INIT([LEMON], [lemon_version()], [lemon-user@lemon.cs.elte.hu], [lemon]) |
16 | 16 |
AC_CONFIG_AUX_DIR([build-aux]) |
17 | 17 |
AC_CONFIG_MACRO_DIR([m4]) |
18 | 18 |
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects nostdinc]) |
19 | 19 |
AC_CONFIG_SRCDIR([lemon/list_graph.h]) |
20 | 20 |
AC_CONFIG_HEADERS([config.h lemon/config.h]) |
21 | 21 |
|
22 | 22 |
dnl Do compilation tests using the C++ compiler. |
23 | 23 |
AC_LANG([C++]) |
24 | 24 |
|
25 | 25 |
dnl Check the existence of long long type. |
26 | 26 |
AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no]) |
27 | 27 |
if test x"$long_long_found" = x"yes"; then |
28 |
AC_DEFINE([ |
|
28 |
AC_DEFINE([LEMON_HAVE_LONG_LONG], [1], [Define to 1 if you have long long.]) |
|
29 | 29 |
fi |
30 | 30 |
|
31 | 31 |
dnl Checks for programs. |
32 | 32 |
AC_PROG_CXX |
33 | 33 |
AC_PROG_CXXCPP |
34 | 34 |
AC_PROG_INSTALL |
35 | 35 |
AC_DISABLE_SHARED |
36 | 36 |
AC_PROG_LIBTOOL |
37 | 37 |
|
38 | 38 |
AC_CHECK_PROG([doxygen_found],[doxygen],[yes],[no]) |
39 | 39 |
AC_CHECK_PROG([gs_found],[gs],[yes],[no]) |
40 | 40 |
|
41 | 41 |
dnl Detect Intel compiler. |
42 | 42 |
AC_MSG_CHECKING([whether we are using the Intel C++ compiler]) |
43 | 43 |
AC_COMPILE_IFELSE([#ifndef __INTEL_COMPILER |
44 | 44 |
choke me |
45 | 45 |
#endif], [ICC=[yes]], [ICC=[no]]) |
46 | 46 |
if test x"$ICC" = x"yes"; then |
47 | 47 |
AC_MSG_RESULT([yes]) |
48 | 48 |
else |
49 | 49 |
AC_MSG_RESULT([no]) |
50 | 50 |
fi |
51 | 51 |
|
52 | 52 |
dnl Set custom compiler flags when using g++. |
53 | 53 |
if test "$GXX" = yes -a "$ICC" = no; then |
54 | 54 |
WARNINGCXXFLAGS="-Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas" |
55 | 55 |
fi |
56 | 56 |
AC_SUBST([WARNINGCXXFLAGS]) |
57 | 57 |
|
58 | 58 |
dnl Checks for libraries. |
59 | 59 |
LX_CHECK_GLPK |
60 | 60 |
LX_CHECK_CPLEX |
61 | 61 |
LX_CHECK_SOPLEX |
62 | 62 |
LX_CHECK_COIN |
63 | 63 |
|
64 | 64 |
AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"]) |
65 | 65 |
AM_CONDITIONAL([HAVE_MIP], [test x"$lx_mip_found" = x"yes"]) |
66 | 66 |
|
67 | 67 |
dnl Disable/enable building the binary tools. |
68 | 68 |
AC_ARG_ENABLE([tools], |
69 | 69 |
AS_HELP_STRING([--enable-tools], [build additional tools @<:@default@:>@]) |
70 | 70 |
AS_HELP_STRING([--disable-tools], [do not build additional tools]), |
71 | 71 |
[], [enable_tools=yes]) |
72 | 72 |
AC_MSG_CHECKING([whether to build the additional tools]) |
73 | 73 |
if test x"$enable_tools" != x"no"; then |
74 | 74 |
AC_MSG_RESULT([yes]) |
75 | 75 |
else |
76 | 76 |
AC_MSG_RESULT([no]) |
77 | 77 |
fi |
78 | 78 |
AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"]) |
79 | 79 |
|
80 | 80 |
dnl Checks for header files. |
81 | 81 |
AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h unistd.h) |
82 | 82 |
|
83 | 83 |
dnl Checks for typedefs, structures, and compiler characteristics. |
84 | 84 |
AC_C_CONST |
85 | 85 |
AC_C_INLINE |
86 | 86 |
AC_TYPE_SIZE_T |
87 | 87 |
AC_HEADER_TIME |
88 | 88 |
AC_STRUCT_TM |
89 | 89 |
|
90 | 90 |
dnl Checks for library functions. |
91 | 91 |
AC_HEADER_STDC |
92 | 92 |
AC_CHECK_FUNCS(gettimeofday times ctime_r) |
93 | 93 |
|
94 | 94 |
dnl Add dependencies on files generated by configure. |
95 | 95 |
AC_SUBST([CONFIG_STATUS_DEPENDENCIES], |
96 | 96 |
['$(top_srcdir)/doc/Doxyfile.in $(top_srcdir)/lemon/lemon.pc.in $(top_srcdir)/cmake/version.cmake.in']) |
97 | 97 |
|
98 | 98 |
AC_CONFIG_FILES([ |
99 | 99 |
Makefile |
100 | 100 |
demo/Makefile |
101 | 101 |
cmake/version.cmake |
102 | 102 |
doc/Doxyfile |
103 | 103 |
lemon/lemon.pc |
104 | 104 |
]) |
105 | 105 |
|
106 | 106 |
AC_OUTPUT |
107 | 107 |
|
108 | 108 |
echo |
109 | 109 |
echo '****************************** SUMMARY ******************************' |
110 | 110 |
echo |
111 | 111 |
echo Package version............... : $PACKAGE-$VERSION |
112 | 112 |
echo |
113 | 113 |
echo C++ compiler.................. : $CXX |
114 | 114 |
echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS |
115 | 115 |
echo |
116 | 116 |
echo Compiler supports long long... : $long_long_found |
117 | 117 |
echo |
118 | 118 |
echo GLPK support.................. : $lx_glpk_found |
119 | 119 |
echo CPLEX support................. : $lx_cplex_found |
120 | 120 |
echo SOPLEX support................ : $lx_soplex_found |
121 | 121 |
echo CLP support................... : $lx_clp_found |
122 | 122 |
echo CBC support................... : $lx_cbc_found |
123 | 123 |
echo |
124 | 124 |
echo Build additional tools........ : $enable_tools |
1 | 1 |
INCLUDE_DIRECTORIES( |
2 | 2 |
${PROJECT_SOURCE_DIR} |
3 | 3 |
${PROJECT_BINARY_DIR} |
4 | 4 |
) |
5 | 5 |
|
6 | 6 |
CONFIGURE_FILE( |
7 | 7 |
${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake |
8 | 8 |
${CMAKE_CURRENT_BINARY_DIR}/config.h |
9 | 9 |
) |
10 | 10 |
|
11 | 11 |
SET(LEMON_SOURCES |
12 | 12 |
arg_parser.cc |
13 | 13 |
base.cc |
14 | 14 |
color.cc |
15 | 15 |
lp_base.cc |
16 | 16 |
lp_skeleton.cc |
17 | 17 |
random.cc |
18 | 18 |
bits/windows.cc |
19 | 19 |
) |
20 | 20 |
|
21 |
IF( |
|
21 |
IF(LEMON_HAVE_GLPK) |
|
22 | 22 |
SET(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc) |
23 | 23 |
INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIRS}) |
24 | 24 |
IF(WIN32) |
25 | 25 |
INSTALL(FILES ${GLPK_BIN_DIR}/glpk.dll DESTINATION bin) |
26 | 26 |
INSTALL(FILES ${GLPK_BIN_DIR}/libltdl3.dll DESTINATION bin) |
27 | 27 |
INSTALL(FILES ${GLPK_BIN_DIR}/zlib1.dll DESTINATION bin) |
28 | 28 |
ENDIF(WIN32) |
29 |
ENDIF( |
|
29 |
ENDIF(LEMON_HAVE_GLPK) |
|
30 | 30 |
|
31 |
IF( |
|
31 |
IF(LEMON_HAVE_CPLEX) |
|
32 | 32 |
SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc) |
33 | 33 |
INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS}) |
34 |
ENDIF( |
|
34 |
ENDIF(LEMON_HAVE_CPLEX) |
|
35 | 35 |
|
36 |
IF( |
|
36 |
IF(LEMON_HAVE_CLP) |
|
37 | 37 |
SET(LEMON_SOURCES ${LEMON_SOURCES} clp.cc) |
38 | 38 |
INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS}) |
39 |
ENDIF( |
|
39 |
ENDIF(LEMON_HAVE_CLP) |
|
40 | 40 |
|
41 |
IF( |
|
41 |
IF(LEMON_HAVE_CBC) |
|
42 | 42 |
SET(LEMON_SOURCES ${LEMON_SOURCES} cbc.cc) |
43 | 43 |
INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS}) |
44 |
ENDIF( |
|
44 |
ENDIF(LEMON_HAVE_CBC) |
|
45 | 45 |
|
46 | 46 |
ADD_LIBRARY(lemon ${LEMON_SOURCES}) |
47 | 47 |
|
48 | 48 |
INSTALL( |
49 | 49 |
TARGETS lemon |
50 | 50 |
ARCHIVE DESTINATION lib |
51 | 51 |
COMPONENT library) |
52 | 52 |
|
53 | 53 |
INSTALL( |
54 | 54 |
DIRECTORY . bits concepts |
55 | 55 |
DESTINATION include/lemon |
56 | 56 |
COMPONENT headers |
57 | 57 |
FILES_MATCHING PATTERN "*.h") |
58 |
|
|
59 |
INSTALL( |
|
60 |
FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h |
|
61 |
DESTINATION include/lemon |
|
62 |
COMPONENT headers) |
1 | 1 |
EXTRA_DIST += \ |
2 | 2 |
lemon/lemon.pc.in \ |
3 | 3 |
lemon/CMakeLists.txt |
4 | 4 |
|
5 | 5 |
pkgconfig_DATA += lemon/lemon.pc |
6 | 6 |
|
7 | 7 |
lib_LTLIBRARIES += lemon/libemon.la |
8 | 8 |
|
9 | 9 |
lemon_libemon_la_SOURCES = \ |
10 | 10 |
lemon/arg_parser.cc \ |
11 | 11 |
lemon/base.cc \ |
12 | 12 |
lemon/color.cc \ |
13 | 13 |
lemon/lp_base.cc \ |
14 | 14 |
lemon/lp_skeleton.cc \ |
15 | 15 |
lemon/random.cc \ |
16 | 16 |
lemon/bits/windows.cc |
17 | 17 |
|
18 | 18 |
|
19 | 19 |
lemon_libemon_la_CXXFLAGS = \ |
20 | 20 |
$(AM_CXXFLAGS) \ |
21 | 21 |
$(GLPK_CFLAGS) \ |
22 | 22 |
$(CPLEX_CFLAGS) \ |
23 | 23 |
$(SOPLEX_CXXFLAGS) \ |
24 | 24 |
$(CLP_CXXFLAGS) \ |
25 | 25 |
$(CBC_CXXFLAGS) |
26 | 26 |
|
27 | 27 |
lemon_libemon_la_LDFLAGS = \ |
28 | 28 |
$(GLPK_LIBS) \ |
29 | 29 |
$(CPLEX_LIBS) \ |
30 | 30 |
$(SOPLEX_LIBS) \ |
31 | 31 |
$(CLP_LIBS) \ |
32 | 32 |
$(CBC_LIBS) |
33 | 33 |
|
34 | 34 |
if HAVE_GLPK |
35 | 35 |
lemon_libemon_la_SOURCES += lemon/glpk.cc |
36 | 36 |
endif |
37 | 37 |
|
38 | 38 |
if HAVE_CPLEX |
39 | 39 |
lemon_libemon_la_SOURCES += lemon/cplex.cc |
40 | 40 |
endif |
41 | 41 |
|
42 | 42 |
if HAVE_SOPLEX |
43 | 43 |
lemon_libemon_la_SOURCES += lemon/soplex.cc |
44 | 44 |
endif |
45 | 45 |
|
46 | 46 |
if HAVE_CLP |
47 | 47 |
lemon_libemon_la_SOURCES += lemon/clp.cc |
48 | 48 |
endif |
49 | 49 |
|
50 | 50 |
if HAVE_CBC |
51 | 51 |
lemon_libemon_la_SOURCES += lemon/cbc.cc |
52 | 52 |
endif |
53 | 53 |
|
54 | 54 |
lemon_HEADERS += \ |
55 | 55 |
lemon/adaptors.h \ |
56 | 56 |
lemon/arg_parser.h \ |
57 | 57 |
lemon/assert.h \ |
58 | 58 |
lemon/bfs.h \ |
59 | 59 |
lemon/bin_heap.h \ |
60 | 60 |
lemon/circulation.h \ |
61 | 61 |
lemon/clp.h \ |
62 | 62 |
lemon/color.h \ |
63 | 63 |
lemon/concept_check.h \ |
64 |
lemon/config.h \ |
|
64 | 65 |
lemon/connectivity.h \ |
65 | 66 |
lemon/counter.h \ |
66 | 67 |
lemon/core.h \ |
67 | 68 |
lemon/cplex.h \ |
68 | 69 |
lemon/dfs.h \ |
69 | 70 |
lemon/dijkstra.h \ |
70 | 71 |
lemon/dim2.h \ |
71 | 72 |
lemon/dimacs.h \ |
72 | 73 |
lemon/edge_set.h \ |
73 | 74 |
lemon/elevator.h \ |
74 | 75 |
lemon/error.h \ |
75 | 76 |
lemon/euler.h \ |
76 | 77 |
lemon/full_graph.h \ |
77 | 78 |
lemon/glpk.h \ |
78 | 79 |
lemon/gomory_hu.h \ |
79 | 80 |
lemon/graph_to_eps.h \ |
80 | 81 |
lemon/grid_graph.h \ |
81 | 82 |
lemon/hypercube_graph.h \ |
82 | 83 |
lemon/kruskal.h \ |
83 | 84 |
lemon/hao_orlin.h \ |
84 | 85 |
lemon/lgf_reader.h \ |
85 | 86 |
lemon/lgf_writer.h \ |
86 | 87 |
lemon/list_graph.h \ |
87 | 88 |
lemon/lp.h \ |
88 | 89 |
lemon/lp_base.h \ |
89 | 90 |
lemon/lp_skeleton.h \ |
90 | 91 |
lemon/list_graph.h \ |
91 | 92 |
lemon/maps.h \ |
92 | 93 |
lemon/matching.h \ |
93 | 94 |
lemon/math.h \ |
94 | 95 |
lemon/min_cost_arborescence.h \ |
95 | 96 |
lemon/nauty_reader.h \ |
96 | 97 |
lemon/network_simplex.h \ |
97 | 98 |
lemon/path.h \ |
98 | 99 |
lemon/preflow.h \ |
99 | 100 |
lemon/radix_sort.h \ |
100 | 101 |
lemon/random.h \ |
101 | 102 |
lemon/smart_graph.h \ |
102 | 103 |
lemon/soplex.h \ |
103 | 104 |
lemon/suurballe.h \ |
104 | 105 |
lemon/time_measure.h \ |
105 | 106 |
lemon/tolerance.h \ |
106 | 107 |
lemon/unionfind.h \ |
107 | 108 |
lemon/bits/windows.h |
108 | 109 |
|
109 | 110 |
bits_HEADERS += \ |
110 | 111 |
lemon/bits/alteration_notifier.h \ |
111 | 112 |
lemon/bits/array_map.h \ |
112 | 113 |
lemon/bits/base_extender.h \ |
113 | 114 |
lemon/bits/bezier.h \ |
114 | 115 |
lemon/bits/default_map.h \ |
115 | 116 |
lemon/bits/edge_set_extender.h \ |
116 | 117 |
lemon/bits/enable_if.h \ |
117 | 118 |
lemon/bits/graph_adaptor_extender.h \ |
118 | 119 |
lemon/bits/graph_extender.h \ |
119 | 120 |
lemon/bits/map_extender.h \ |
120 | 121 |
lemon/bits/path_dump.h \ |
121 | 122 |
lemon/bits/solver_bits.h \ |
122 | 123 |
lemon/bits/traits.h \ |
123 | 124 |
lemon/bits/variant.h \ |
124 | 125 |
lemon/bits/vector_map.h |
125 | 126 |
|
126 | 127 |
concept_HEADERS += \ |
127 | 128 |
lemon/concepts/digraph.h \ |
128 | 129 |
lemon/concepts/graph.h \ |
129 | 130 |
lemon/concepts/graph_components.h \ |
130 | 131 |
lemon/concepts/heap.h \ |
131 | 132 |
lemon/concepts/maps.h \ |
132 | 133 |
lemon/concepts/path.h |
... | ... |
@@ -4,179 +4,179 @@ |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_DEFAULT_MAP_H |
20 | 20 |
#define LEMON_BITS_DEFAULT_MAP_H |
21 | 21 |
|
22 | 22 |
#include <lemon/config.h> |
23 | 23 |
#include <lemon/bits/array_map.h> |
24 | 24 |
#include <lemon/bits/vector_map.h> |
25 | 25 |
//#include <lemon/bits/debug_map.h> |
26 | 26 |
|
27 | 27 |
//\ingroup graphbits |
28 | 28 |
//\file |
29 | 29 |
//\brief Graph maps that construct and destruct their elements dynamically. |
30 | 30 |
|
31 | 31 |
namespace lemon { |
32 | 32 |
|
33 | 33 |
|
34 | 34 |
//#ifndef LEMON_USE_DEBUG_MAP |
35 | 35 |
|
36 | 36 |
template <typename _Graph, typename _Item, typename _Value> |
37 | 37 |
struct DefaultMapSelector { |
38 | 38 |
typedef ArrayMap<_Graph, _Item, _Value> Map; |
39 | 39 |
}; |
40 | 40 |
|
41 | 41 |
// bool |
42 | 42 |
template <typename _Graph, typename _Item> |
43 | 43 |
struct DefaultMapSelector<_Graph, _Item, bool> { |
44 | 44 |
typedef VectorMap<_Graph, _Item, bool> Map; |
45 | 45 |
}; |
46 | 46 |
|
47 | 47 |
// char |
48 | 48 |
template <typename _Graph, typename _Item> |
49 | 49 |
struct DefaultMapSelector<_Graph, _Item, char> { |
50 | 50 |
typedef VectorMap<_Graph, _Item, char> Map; |
51 | 51 |
}; |
52 | 52 |
|
53 | 53 |
template <typename _Graph, typename _Item> |
54 | 54 |
struct DefaultMapSelector<_Graph, _Item, signed char> { |
55 | 55 |
typedef VectorMap<_Graph, _Item, signed char> Map; |
56 | 56 |
}; |
57 | 57 |
|
58 | 58 |
template <typename _Graph, typename _Item> |
59 | 59 |
struct DefaultMapSelector<_Graph, _Item, unsigned char> { |
60 | 60 |
typedef VectorMap<_Graph, _Item, unsigned char> Map; |
61 | 61 |
}; |
62 | 62 |
|
63 | 63 |
|
64 | 64 |
// int |
65 | 65 |
template <typename _Graph, typename _Item> |
66 | 66 |
struct DefaultMapSelector<_Graph, _Item, signed int> { |
67 | 67 |
typedef VectorMap<_Graph, _Item, signed int> Map; |
68 | 68 |
}; |
69 | 69 |
|
70 | 70 |
template <typename _Graph, typename _Item> |
71 | 71 |
struct DefaultMapSelector<_Graph, _Item, unsigned int> { |
72 | 72 |
typedef VectorMap<_Graph, _Item, unsigned int> Map; |
73 | 73 |
}; |
74 | 74 |
|
75 | 75 |
|
76 | 76 |
// short |
77 | 77 |
template <typename _Graph, typename _Item> |
78 | 78 |
struct DefaultMapSelector<_Graph, _Item, signed short> { |
79 | 79 |
typedef VectorMap<_Graph, _Item, signed short> Map; |
80 | 80 |
}; |
81 | 81 |
|
82 | 82 |
template <typename _Graph, typename _Item> |
83 | 83 |
struct DefaultMapSelector<_Graph, _Item, unsigned short> { |
84 | 84 |
typedef VectorMap<_Graph, _Item, unsigned short> Map; |
85 | 85 |
}; |
86 | 86 |
|
87 | 87 |
|
88 | 88 |
// long |
89 | 89 |
template <typename _Graph, typename _Item> |
90 | 90 |
struct DefaultMapSelector<_Graph, _Item, signed long> { |
91 | 91 |
typedef VectorMap<_Graph, _Item, signed long> Map; |
92 | 92 |
}; |
93 | 93 |
|
94 | 94 |
template <typename _Graph, typename _Item> |
95 | 95 |
struct DefaultMapSelector<_Graph, _Item, unsigned long> { |
96 | 96 |
typedef VectorMap<_Graph, _Item, unsigned long> Map; |
97 | 97 |
}; |
98 | 98 |
|
99 | 99 |
|
100 |
#if defined |
|
100 |
#if defined LEMON_HAVE_LONG_LONG |
|
101 | 101 |
|
102 | 102 |
// long long |
103 | 103 |
template <typename _Graph, typename _Item> |
104 | 104 |
struct DefaultMapSelector<_Graph, _Item, signed long long> { |
105 | 105 |
typedef VectorMap<_Graph, _Item, signed long long> Map; |
106 | 106 |
}; |
107 | 107 |
|
108 | 108 |
template <typename _Graph, typename _Item> |
109 | 109 |
struct DefaultMapSelector<_Graph, _Item, unsigned long long> { |
110 | 110 |
typedef VectorMap<_Graph, _Item, unsigned long long> Map; |
111 | 111 |
}; |
112 | 112 |
|
113 | 113 |
#endif |
114 | 114 |
|
115 | 115 |
|
116 | 116 |
// float |
117 | 117 |
template <typename _Graph, typename _Item> |
118 | 118 |
struct DefaultMapSelector<_Graph, _Item, float> { |
119 | 119 |
typedef VectorMap<_Graph, _Item, float> Map; |
120 | 120 |
}; |
121 | 121 |
|
122 | 122 |
|
123 | 123 |
// double |
124 | 124 |
template <typename _Graph, typename _Item> |
125 | 125 |
struct DefaultMapSelector<_Graph, _Item, double> { |
126 | 126 |
typedef VectorMap<_Graph, _Item, double> Map; |
127 | 127 |
}; |
128 | 128 |
|
129 | 129 |
|
130 | 130 |
// long double |
131 | 131 |
template <typename _Graph, typename _Item> |
132 | 132 |
struct DefaultMapSelector<_Graph, _Item, long double> { |
133 | 133 |
typedef VectorMap<_Graph, _Item, long double> Map; |
134 | 134 |
}; |
135 | 135 |
|
136 | 136 |
|
137 | 137 |
// pointer |
138 | 138 |
template <typename _Graph, typename _Item, typename _Ptr> |
139 | 139 |
struct DefaultMapSelector<_Graph, _Item, _Ptr*> { |
140 | 140 |
typedef VectorMap<_Graph, _Item, _Ptr*> Map; |
141 | 141 |
}; |
142 | 142 |
|
143 | 143 |
// #else |
144 | 144 |
|
145 | 145 |
// template <typename _Graph, typename _Item, typename _Value> |
146 | 146 |
// struct DefaultMapSelector { |
147 | 147 |
// typedef DebugMap<_Graph, _Item, _Value> Map; |
148 | 148 |
// }; |
149 | 149 |
|
150 | 150 |
// #endif |
151 | 151 |
|
152 | 152 |
// DefaultMap class |
153 | 153 |
template <typename _Graph, typename _Item, typename _Value> |
154 | 154 |
class DefaultMap |
155 | 155 |
: public DefaultMapSelector<_Graph, _Item, _Value>::Map { |
156 | 156 |
typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; |
157 | 157 |
|
158 | 158 |
public: |
159 | 159 |
typedef DefaultMap<_Graph, _Item, _Value> Map; |
160 | 160 |
|
161 | 161 |
typedef typename Parent::GraphType GraphType; |
162 | 162 |
typedef typename Parent::Value Value; |
163 | 163 |
|
164 | 164 |
explicit DefaultMap(const GraphType& graph) : Parent(graph) {} |
165 | 165 |
DefaultMap(const GraphType& graph, const Value& value) |
166 | 166 |
: Parent(graph, value) {} |
167 | 167 |
|
168 | 168 |
DefaultMap& operator=(const DefaultMap& cmap) { |
169 | 169 |
return operator=<DefaultMap>(cmap); |
170 | 170 |
} |
171 | 171 |
|
172 | 172 |
template <typename CMap> |
173 | 173 |
DefaultMap& operator=(const CMap& cmap) { |
174 | 174 |
Parent::operator=(cmap); |
175 | 175 |
return *this; |
176 | 176 |
} |
177 | 177 |
|
178 | 178 |
}; |
179 | 179 |
|
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
#endif |
1 |
#cmakedefine HAVE_LONG_LONG 1 |
|
2 |
#cmakedefine HAVE_LP 1 |
|
3 |
#cmakedefine HAVE_MIP 1 |
|
4 |
#cmakedefine HAVE_GLPK 1 |
|
5 |
#cmakedefine HAVE_CPLEX 1 |
|
6 |
#cmakedefine HAVE_CLP 1 |
|
7 |
#cmakedefine |
|
1 |
#cmakedefine LEMON_HAVE_LONG_LONG 1 |
|
2 |
#cmakedefine LEMON_HAVE_LP 1 |
|
3 |
#cmakedefine LEMON_HAVE_MIP 1 |
|
4 |
#cmakedefine LEMON_HAVE_GLPK 1 |
|
5 |
#cmakedefine LEMON_HAVE_CPLEX 1 |
|
6 |
#cmakedefine LEMON_HAVE_CLP 1 |
|
7 |
#cmakedefine LEMON_HAVE_CBC 1 |
1 | 1 |
/* Define to 1 if you have long long */ |
2 |
#undef |
|
2 |
#undef LEMON_HAVE_LONG_LONG |
|
3 | 3 |
|
4 | 4 |
/* Define to 1 if you have any LP solver. */ |
5 |
#undef |
|
5 |
#undef LEMON_HAVE_LP |
|
6 | 6 |
|
7 | 7 |
/* Define to 1 if you have any MIP solver. */ |
8 |
#undef |
|
8 |
#undef LEMON_HAVE_MIP |
|
9 | 9 |
|
10 | 10 |
/* Define to 1 if you have CPLEX. */ |
11 |
#undef |
|
11 |
#undef LEMON_HAVE_CPLEX |
|
12 | 12 |
|
13 | 13 |
/* Define to 1 if you have GLPK. */ |
14 |
#undef |
|
14 |
#undef LEMON_HAVE_GLPK |
|
15 | 15 |
|
16 | 16 |
/* Define to 1 if you have SOPLEX */ |
17 |
#undef |
|
17 |
#undef LEMON_HAVE_SOPLEX |
|
18 | 18 |
|
19 | 19 |
/* Define to 1 if you have CLP */ |
20 |
#undef |
|
20 |
#undef LEMON_HAVE_CLP |
|
21 | 21 |
|
22 | 22 |
/* Define to 1 if you have CBC */ |
23 |
#undef |
|
23 |
#undef LEMON_HAVE_CBC |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2008 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_LP_H |
20 | 20 |
#define LEMON_LP_H |
21 | 21 |
|
22 | 22 |
#include<lemon/config.h> |
23 | 23 |
|
24 | 24 |
|
25 |
#ifdef |
|
25 |
#ifdef LEMON_HAVE_GLPK |
|
26 | 26 |
#include <lemon/glpk.h> |
27 |
#elif |
|
27 |
#elif LEMON_HAVE_CPLEX |
|
28 | 28 |
#include <lemon/cplex.h> |
29 |
#elif |
|
29 |
#elif LEMON_HAVE_SOPLEX |
|
30 | 30 |
#include <lemon/soplex.h> |
31 |
#elif |
|
31 |
#elif LEMON_HAVE_CLP |
|
32 | 32 |
#include <lemon/clp.h> |
33 | 33 |
#endif |
34 | 34 |
|
35 | 35 |
///\file |
36 | 36 |
///\brief Defines a default LP solver |
37 | 37 |
///\ingroup lp_group |
38 | 38 |
namespace lemon { |
39 | 39 |
|
40 | 40 |
#ifdef DOXYGEN |
41 | 41 |
///The default LP solver identifier |
42 | 42 |
|
43 | 43 |
///The default LP solver identifier. |
44 | 44 |
///\ingroup lp_group |
45 | 45 |
/// |
46 | 46 |
///Currently, the possible values are \c GLPK, \c CPLEX, |
47 | 47 |
///\c SOPLEX or \c CLP |
48 | 48 |
#define LEMON_DEFAULT_LP SOLVER |
49 | 49 |
///The default LP solver |
50 | 50 |
|
51 | 51 |
///The default LP solver. |
52 | 52 |
///\ingroup lp_group |
53 | 53 |
/// |
54 | 54 |
///Currently, it is either \c GlpkLp, \c CplexLp, \c SoplexLp or \c ClpLp |
55 | 55 |
typedef GlpkLp Lp; |
56 | 56 |
|
57 | 57 |
///The default MIP solver identifier |
58 | 58 |
|
59 | 59 |
///The default MIP solver identifier. |
60 | 60 |
///\ingroup lp_group |
61 | 61 |
/// |
62 | 62 |
///Currently, the possible values are \c GLPK or \c CPLEX |
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 | 69 |
///Currently, it is either \c GlpkMip or \c CplexMip |
70 | 70 |
typedef GlpkMip Mip; |
71 | 71 |
#else |
72 |
#ifdef |
|
72 |
#ifdef LEMON_HAVE_GLPK |
|
73 | 73 |
# define LEMON_DEFAULT_LP GLPK |
74 | 74 |
typedef GlpkLp Lp; |
75 | 75 |
# define LEMON_DEFAULT_MIP GLPK |
76 | 76 |
typedef GlpkMip Mip; |
77 |
#elif |
|
77 |
#elif LEMON_HAVE_CPLEX |
|
78 | 78 |
# define LEMON_DEFAULT_LP CPLEX |
79 | 79 |
typedef CplexLp Lp; |
80 | 80 |
# define LEMON_DEFAULT_MIP CPLEX |
81 | 81 |
typedef CplexMip Mip; |
82 |
#elif |
|
82 |
#elif LEMON_HAVE_SOPLEX |
|
83 | 83 |
# define DEFAULT_LP SOPLEX |
84 | 84 |
typedef SoplexLp Lp; |
85 |
#elif |
|
85 |
#elif LEMON_HAVE_CLP |
|
86 | 86 |
# define DEFAULT_LP CLP |
87 | 87 |
typedef ClpLp Lp; |
88 | 88 |
#endif |
89 | 89 |
#endif |
90 | 90 |
|
91 | 91 |
} //namespace lemon |
92 | 92 |
|
93 | 93 |
#endif //LEMON_LP_H |
1 | 1 |
AC_DEFUN([LX_CHECK_COIN], |
2 | 2 |
[ |
3 | 3 |
AC_ARG_WITH([coin], |
4 | 4 |
AS_HELP_STRING([--with-coin@<:@=PREFIX@:>@], [search for CLP under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@]) |
5 | 5 |
AS_HELP_STRING([--without-coin], [disable checking for CLP]), |
6 | 6 |
[], [with_coin=yes]) |
7 | 7 |
|
8 | 8 |
AC_ARG_WITH([coin-includedir], |
9 | 9 |
AS_HELP_STRING([--with-coin-includedir=DIR], [search for CLP headers in DIR]), |
10 | 10 |
[], [with_coin_includedir=no]) |
11 | 11 |
|
12 | 12 |
AC_ARG_WITH([coin-libdir], |
13 | 13 |
AS_HELP_STRING([--with-coin-libdir=DIR], [search for CLP libraries in DIR]), |
14 | 14 |
[], [with_coin_libdir=no]) |
15 | 15 |
|
16 | 16 |
lx_clp_found=no |
17 | 17 |
if test x"$with_coin" != x"no"; then |
18 | 18 |
AC_MSG_CHECKING([for CLP]) |
19 | 19 |
|
20 | 20 |
if test x"$with_coin_includedir" != x"no"; then |
21 | 21 |
CLP_CXXFLAGS="-I$with_coin_includedir" |
22 | 22 |
elif test x"$with_coin" != x"yes"; then |
23 | 23 |
CLP_CXXFLAGS="-I$with_coin/include" |
24 | 24 |
fi |
25 | 25 |
|
26 | 26 |
if test x"$with_coin_libdir" != x"no"; then |
27 | 27 |
CLP_LDFLAGS="-L$with_coin_libdir" |
28 | 28 |
elif test x"$with_coin" != x"yes"; then |
29 | 29 |
CLP_LDFLAGS="-L$with_coin/lib" |
30 | 30 |
fi |
31 | 31 |
CLP_LIBS="-lClp -lCoinUtils -lm" |
32 | 32 |
|
33 | 33 |
lx_save_cxxflags="$CXXFLAGS" |
34 | 34 |
lx_save_ldflags="$LDFLAGS" |
35 | 35 |
lx_save_libs="$LIBS" |
36 | 36 |
CXXFLAGS="$CLP_CXXFLAGS" |
37 | 37 |
LDFLAGS="$CLP_LDFLAGS" |
38 | 38 |
LIBS="$CLP_LIBS" |
39 | 39 |
|
40 | 40 |
lx_clp_test_prog=' |
41 | 41 |
#include <coin/ClpModel.hpp> |
42 | 42 |
|
43 | 43 |
int main(int argc, char** argv) |
44 | 44 |
{ |
45 | 45 |
ClpModel clp; |
46 | 46 |
return 0; |
47 | 47 |
}' |
48 | 48 |
|
49 | 49 |
AC_LANG_PUSH(C++) |
50 | 50 |
AC_LINK_IFELSE([$lx_clp_test_prog], [lx_clp_found=yes], [lx_clp_found=no]) |
51 | 51 |
AC_LANG_POP(C++) |
52 | 52 |
|
53 | 53 |
CXXFLAGS="$lx_save_cxxflags" |
54 | 54 |
LDFLAGS="$lx_save_ldflags" |
55 | 55 |
LIBS="$lx_save_libs" |
56 | 56 |
|
57 | 57 |
if test x"$lx_clp_found" = x"yes"; then |
58 |
AC_DEFINE([ |
|
58 |
AC_DEFINE([LEMON_HAVE_CLP], [1], [Define to 1 if you have CLP.]) |
|
59 | 59 |
lx_lp_found=yes |
60 |
AC_DEFINE([ |
|
60 |
AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) |
|
61 | 61 |
AC_MSG_RESULT([yes]) |
62 | 62 |
else |
63 | 63 |
CLP_CXXFLAGS="" |
64 | 64 |
CLP_LDFLAGS="" |
65 | 65 |
CLP_LIBS="" |
66 | 66 |
AC_MSG_RESULT([no]) |
67 | 67 |
fi |
68 | 68 |
fi |
69 | 69 |
CLP_LIBS="$CLP_LDFLAGS $CLP_LIBS" |
70 | 70 |
AC_SUBST(CLP_CXXFLAGS) |
71 | 71 |
AC_SUBST(CLP_LIBS) |
72 | 72 |
AM_CONDITIONAL([HAVE_CLP], [test x"$lx_clp_found" = x"yes"]) |
73 | 73 |
|
74 | 74 |
|
75 | 75 |
lx_cbc_found=no |
76 | 76 |
if test x"$lx_clp_found" = x"yes"; then |
77 | 77 |
if test x"$with_coin" != x"no"; then |
78 | 78 |
AC_MSG_CHECKING([for CBC]) |
79 | 79 |
|
80 | 80 |
if test x"$with_coin_includedir" != x"no"; then |
81 | 81 |
CBC_CXXFLAGS="-I$with_coin_includedir" |
82 | 82 |
elif test x"$with_coin" != x"yes"; then |
83 | 83 |
CBC_CXXFLAGS="-I$with_coin/include" |
84 | 84 |
fi |
85 | 85 |
|
86 | 86 |
if test x"$with_coin_libdir" != x"no"; then |
87 | 87 |
CBC_LDFLAGS="-L$with_coin_libdir" |
88 | 88 |
elif test x"$with_coin" != x"yes"; then |
89 | 89 |
CBC_LDFLAGS="-L$with_coin/lib" |
90 | 90 |
fi |
91 | 91 |
CBC_LIBS="-lOsi -lCbc -lOsiCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas" |
92 | 92 |
|
93 | 93 |
lx_save_cxxflags="$CXXFLAGS" |
94 | 94 |
lx_save_ldflags="$LDFLAGS" |
95 | 95 |
lx_save_libs="$LIBS" |
96 | 96 |
CXXFLAGS="$CBC_CXXFLAGS" |
97 | 97 |
LDFLAGS="$CBC_LDFLAGS" |
98 | 98 |
LIBS="$CBC_LIBS" |
99 | 99 |
|
100 | 100 |
lx_cbc_test_prog=' |
101 | 101 |
#include <coin/CbcModel.hpp> |
102 | 102 |
|
103 | 103 |
int main(int argc, char** argv) |
104 | 104 |
{ |
105 | 105 |
CbcModel cbc; |
106 | 106 |
return 0; |
107 | 107 |
}' |
108 | 108 |
|
109 | 109 |
AC_LANG_PUSH(C++) |
110 | 110 |
AC_LINK_IFELSE([$lx_cbc_test_prog], [lx_cbc_found=yes], [lx_cbc_found=no]) |
111 | 111 |
AC_LANG_POP(C++) |
112 | 112 |
|
113 | 113 |
CXXFLAGS="$lx_save_cxxflags" |
114 | 114 |
LDFLAGS="$lx_save_ldflags" |
115 | 115 |
LIBS="$lx_save_libs" |
116 | 116 |
|
117 | 117 |
if test x"$lx_cbc_found" = x"yes"; then |
118 |
AC_DEFINE([ |
|
118 |
AC_DEFINE([LEMON_HAVE_CBC], [1], [Define to 1 if you have CBC.]) |
|
119 | 119 |
lx_lp_found=yes |
120 |
AC_DEFINE([ |
|
120 |
AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) |
|
121 | 121 |
lx_mip_found=yes |
122 |
AC_DEFINE([ |
|
122 |
AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.]) |
|
123 | 123 |
AC_MSG_RESULT([yes]) |
124 | 124 |
else |
125 | 125 |
CBC_CXXFLAGS="" |
126 | 126 |
CBC_LDFLAGS="" |
127 | 127 |
CBC_LIBS="" |
128 | 128 |
AC_MSG_RESULT([no]) |
129 | 129 |
fi |
130 | 130 |
fi |
131 | 131 |
fi |
132 | 132 |
CBC_LIBS="$CBC_LDFLAGS $CBC_LIBS" |
133 | 133 |
AC_SUBST(CBC_CXXFLAGS) |
134 | 134 |
AC_SUBST(CBC_LIBS) |
135 | 135 |
AM_CONDITIONAL([HAVE_CBC], [test x"$lx_cbc_found" = x"yes"]) |
136 | 136 |
]) |
1 | 1 |
AC_DEFUN([LX_CHECK_CPLEX], |
2 | 2 |
[ |
3 | 3 |
AC_ARG_WITH([cplex], |
4 | 4 |
AS_HELP_STRING([--with-cplex@<:@=PREFIX@:>@], [search for CPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@]) |
5 | 5 |
AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]), |
6 | 6 |
[], [with_cplex=yes]) |
7 | 7 |
|
8 | 8 |
AC_ARG_WITH([cplex-includedir], |
9 | 9 |
AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]), |
10 | 10 |
[], [with_cplex_includedir=no]) |
11 | 11 |
|
12 | 12 |
AC_ARG_WITH([cplex-libdir], |
13 | 13 |
AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]), |
14 | 14 |
[], [with_cplex_libdir=no]) |
15 | 15 |
|
16 | 16 |
lx_cplex_found=no |
17 | 17 |
if test x"$with_cplex" != x"no"; then |
18 | 18 |
AC_MSG_CHECKING([for CPLEX]) |
19 | 19 |
|
20 | 20 |
if test x"$with_cplex_includedir" != x"no"; then |
21 | 21 |
CPLEX_CFLAGS="-I$with_cplex_includedir" |
22 | 22 |
elif test x"$with_cplex" != x"yes"; then |
23 | 23 |
CPLEX_CFLAGS="-I$with_cplex/include" |
24 | 24 |
elif test x"$CPLEX_INCLUDEDIR" != x; then |
25 | 25 |
CPLEX_CFLAGS="-I$CPLEX_INCLUDEDIR" |
26 | 26 |
fi |
27 | 27 |
|
28 | 28 |
if test x"$with_cplex_libdir" != x"no"; then |
29 | 29 |
CPLEX_LDFLAGS="-L$with_cplex_libdir" |
30 | 30 |
elif test x"$with_cplex" != x"yes"; then |
31 | 31 |
CPLEX_LDFLAGS="-L$with_cplex/lib" |
32 | 32 |
elif test x"$CPLEX_LIBDIR" != x; then |
33 | 33 |
CPLEX_LDFLAGS="-L$CPLEX_LIBDIR" |
34 | 34 |
fi |
35 | 35 |
CPLEX_LIBS="-lcplex -lm -lpthread" |
36 | 36 |
|
37 | 37 |
lx_save_cxxflags="$CXXFLAGS" |
38 | 38 |
lx_save_ldflags="$LDFLAGS" |
39 | 39 |
lx_save_libs="$LIBS" |
40 | 40 |
CXXFLAGS="$CPLEX_CFLAGS" |
41 | 41 |
LDFLAGS="$CPLEX_LDFLAGS" |
42 | 42 |
LIBS="$CPLEX_LIBS" |
43 | 43 |
|
44 | 44 |
lx_cplex_test_prog=' |
45 | 45 |
extern "C" { |
46 | 46 |
#include <ilcplex/cplex.h> |
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
int main(int argc, char** argv) |
50 | 50 |
{ |
51 | 51 |
CPXENVptr env = NULL; |
52 | 52 |
return 0; |
53 | 53 |
}' |
54 | 54 |
|
55 | 55 |
AC_LANG_PUSH(C++) |
56 | 56 |
AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no]) |
57 | 57 |
AC_LANG_POP(C++) |
58 | 58 |
|
59 | 59 |
CXXFLAGS="$lx_save_cxxflags" |
60 | 60 |
LDFLAGS="$lx_save_ldflags" |
61 | 61 |
LIBS="$lx_save_libs" |
62 | 62 |
|
63 | 63 |
if test x"$lx_cplex_found" = x"yes"; then |
64 |
AC_DEFINE([ |
|
64 |
AC_DEFINE([LEMON_HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.]) |
|
65 | 65 |
lx_lp_found=yes |
66 |
AC_DEFINE([ |
|
66 |
AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) |
|
67 | 67 |
lx_mip_found=yes |
68 |
AC_DEFINE([ |
|
68 |
AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.]) |
|
69 | 69 |
AC_MSG_RESULT([yes]) |
70 | 70 |
else |
71 | 71 |
CPLEX_CFLAGS="" |
72 | 72 |
CPLEX_LDFLAGS="" |
73 | 73 |
CPLEX_LIBS="" |
74 | 74 |
AC_MSG_RESULT([no]) |
75 | 75 |
fi |
76 | 76 |
fi |
77 | 77 |
CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS" |
78 | 78 |
AC_SUBST(CPLEX_CFLAGS) |
79 | 79 |
AC_SUBST(CPLEX_LIBS) |
80 | 80 |
AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"]) |
81 | 81 |
]) |
1 | 1 |
AC_DEFUN([LX_CHECK_GLPK], |
2 | 2 |
[ |
3 | 3 |
AC_ARG_WITH([glpk], |
4 | 4 |
AS_HELP_STRING([--with-glpk@<:@=PREFIX@:>@], [search for GLPK under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@]) |
5 | 5 |
AS_HELP_STRING([--without-glpk], [disable checking for GLPK]), |
6 | 6 |
[], [with_glpk=yes]) |
7 | 7 |
|
8 | 8 |
AC_ARG_WITH([glpk-includedir], |
9 | 9 |
AS_HELP_STRING([--with-glpk-includedir=DIR], [search for GLPK headers in DIR]), |
10 | 10 |
[], [with_glpk_includedir=no]) |
11 | 11 |
|
12 | 12 |
AC_ARG_WITH([glpk-libdir], |
13 | 13 |
AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]), |
14 | 14 |
[], [with_glpk_libdir=no]) |
15 | 15 |
|
16 | 16 |
lx_glpk_found=no |
17 | 17 |
if test x"$with_glpk" != x"no"; then |
18 | 18 |
AC_MSG_CHECKING([for GLPK]) |
19 | 19 |
|
20 | 20 |
if test x"$with_glpk_includedir" != x"no"; then |
21 | 21 |
GLPK_CFLAGS="-I$with_glpk_includedir" |
22 | 22 |
elif test x"$with_glpk" != x"yes"; then |
23 | 23 |
GLPK_CFLAGS="-I$with_glpk/include" |
24 | 24 |
fi |
25 | 25 |
|
26 | 26 |
if test x"$with_glpk_libdir" != x"no"; then |
27 | 27 |
GLPK_LDFLAGS="-L$with_glpk_libdir" |
28 | 28 |
elif test x"$with_glpk" != x"yes"; then |
29 | 29 |
GLPK_LDFLAGS="-L$with_glpk/lib" |
30 | 30 |
fi |
31 | 31 |
GLPK_LIBS="-lglpk" |
32 | 32 |
|
33 | 33 |
lx_save_cxxflags="$CXXFLAGS" |
34 | 34 |
lx_save_ldflags="$LDFLAGS" |
35 | 35 |
lx_save_libs="$LIBS" |
36 | 36 |
CXXFLAGS="$GLPK_CFLAGS" |
37 | 37 |
LDFLAGS="$GLPK_LDFLAGS" |
38 | 38 |
LIBS="$GLPK_LIBS" |
39 | 39 |
|
40 | 40 |
lx_glpk_test_prog=' |
41 | 41 |
extern "C" { |
42 | 42 |
#include <glpk.h> |
43 | 43 |
} |
44 | 44 |
|
45 | 45 |
#if (GLP_MAJOR_VERSION < 4) \ |
46 | 46 |
|| (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION < 33) |
47 | 47 |
#error Supported GLPK versions: 4.33 or above |
48 | 48 |
#endif |
49 | 49 |
|
50 | 50 |
int main(int argc, char** argv) |
51 | 51 |
{ |
52 | 52 |
LPX *lp; |
53 | 53 |
lp = lpx_create_prob(); |
54 | 54 |
lpx_delete_prob(lp); |
55 | 55 |
return 0; |
56 | 56 |
}' |
57 | 57 |
|
58 | 58 |
AC_LANG_PUSH(C++) |
59 | 59 |
AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no]) |
60 | 60 |
AC_LANG_POP(C++) |
61 | 61 |
|
62 | 62 |
CXXFLAGS="$lx_save_cxxflags" |
63 | 63 |
LDFLAGS="$lx_save_ldflags" |
64 | 64 |
LIBS="$lx_save_libs" |
65 | 65 |
|
66 | 66 |
if test x"$lx_glpk_found" = x"yes"; then |
67 |
AC_DEFINE([ |
|
67 |
AC_DEFINE([LEMON_HAVE_GLPK], [1], [Define to 1 if you have GLPK.]) |
|
68 | 68 |
lx_lp_found=yes |
69 |
AC_DEFINE([ |
|
69 |
AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) |
|
70 | 70 |
lx_mip_found=yes |
71 |
AC_DEFINE([ |
|
71 |
AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.]) |
|
72 | 72 |
AC_MSG_RESULT([yes]) |
73 | 73 |
else |
74 | 74 |
GLPK_CFLAGS="" |
75 | 75 |
GLPK_LDFLAGS="" |
76 | 76 |
GLPK_LIBS="" |
77 | 77 |
AC_MSG_RESULT([no]) |
78 | 78 |
fi |
79 | 79 |
fi |
80 | 80 |
GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS" |
81 | 81 |
AC_SUBST(GLPK_CFLAGS) |
82 | 82 |
AC_SUBST(GLPK_LIBS) |
83 | 83 |
AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"]) |
84 | 84 |
]) |
1 | 1 |
AC_DEFUN([LX_CHECK_SOPLEX], |
2 | 2 |
[ |
3 | 3 |
AC_ARG_WITH([soplex], |
4 | 4 |
AS_HELP_STRING([--with-soplex@<:@=PREFIX@:>@], [search for SOPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@]) |
5 | 5 |
AS_HELP_STRING([--without-soplex], [disable checking for SOPLEX]), |
6 | 6 |
[], [with_soplex=yes]) |
7 | 7 |
|
8 | 8 |
AC_ARG_WITH([soplex-includedir], |
9 | 9 |
AS_HELP_STRING([--with-soplex-includedir=DIR], [search for SOPLEX headers in DIR]), |
10 | 10 |
[], [with_soplex_includedir=no]) |
11 | 11 |
|
12 | 12 |
AC_ARG_WITH([soplex-libdir], |
13 | 13 |
AS_HELP_STRING([--with-soplex-libdir=DIR], [search for SOPLEX libraries in DIR]), |
14 | 14 |
[], [with_soplex_libdir=no]) |
15 | 15 |
|
16 | 16 |
lx_soplex_found=no |
17 | 17 |
if test x"$with_soplex" != x"no"; then |
18 | 18 |
AC_MSG_CHECKING([for SOPLEX]) |
19 | 19 |
|
20 | 20 |
if test x"$with_soplex_includedir" != x"no"; then |
21 | 21 |
SOPLEX_CXXFLAGS="-I$with_soplex_includedir" |
22 | 22 |
elif test x"$with_soplex" != x"yes"; then |
23 | 23 |
SOPLEX_CXXFLAGS="-I$with_soplex/src" |
24 | 24 |
fi |
25 | 25 |
|
26 | 26 |
if test x"$with_soplex_libdir" != x"no"; then |
27 | 27 |
SOPLEX_LDFLAGS="-L$with_soplex_libdir" |
28 | 28 |
elif test x"$with_soplex" != x"yes"; then |
29 | 29 |
SOPLEX_LDFLAGS="-L$with_soplex/lib" |
30 | 30 |
fi |
31 | 31 |
SOPLEX_LIBS="-lsoplex -lz" |
32 | 32 |
|
33 | 33 |
lx_save_cxxflags="$CXXFLAGS" |
34 | 34 |
lx_save_ldflags="$LDFLAGS" |
35 | 35 |
lx_save_libs="$LIBS" |
36 | 36 |
CXXFLAGS="$SOPLEX_CXXFLAGS" |
37 | 37 |
LDFLAGS="$SOPLEX_LDFLAGS" |
38 | 38 |
LIBS="$SOPLEX_LIBS" |
39 | 39 |
|
40 | 40 |
lx_soplex_test_prog=' |
41 | 41 |
#include <soplex.h> |
42 | 42 |
|
43 | 43 |
int main(int argc, char** argv) |
44 | 44 |
{ |
45 | 45 |
soplex::SoPlex soplex; |
46 | 46 |
return 0; |
47 | 47 |
}' |
48 | 48 |
|
49 | 49 |
AC_LANG_PUSH(C++) |
50 | 50 |
AC_LINK_IFELSE([$lx_soplex_test_prog], [lx_soplex_found=yes], [lx_soplex_found=no]) |
51 | 51 |
AC_LANG_POP(C++) |
52 | 52 |
|
53 | 53 |
CXXFLAGS="$lx_save_cxxflags" |
54 | 54 |
LDFLAGS="$lx_save_ldflags" |
55 | 55 |
LIBS="$lx_save_libs" |
56 | 56 |
|
57 | 57 |
if test x"$lx_soplex_found" = x"yes"; then |
58 |
AC_DEFINE([ |
|
58 |
AC_DEFINE([LEMON_HAVE_SOPLEX], [1], [Define to 1 if you have SOPLEX.]) |
|
59 | 59 |
lx_lp_found=yes |
60 |
AC_DEFINE([ |
|
60 |
AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.]) |
|
61 | 61 |
AC_MSG_RESULT([yes]) |
62 | 62 |
else |
63 | 63 |
SOPLEX_CXXFLAGS="" |
64 | 64 |
SOPLEX_LDFLAGS="" |
65 | 65 |
SOPLEX_LIBS="" |
66 | 66 |
AC_MSG_RESULT([no]) |
67 | 67 |
fi |
68 | 68 |
fi |
69 | 69 |
SOPLEX_LIBS="$SOPLEX_LDFLAGS $SOPLEX_LIBS" |
70 | 70 |
AC_SUBST(SOPLEX_CXXFLAGS) |
71 | 71 |
AC_SUBST(SOPLEX_LIBS) |
72 | 72 |
AM_CONDITIONAL([HAVE_SOPLEX], [test x"$lx_soplex_found" = x"yes"]) |
73 | 73 |
]) |
1 | 1 |
INCLUDE_DIRECTORIES( |
2 | 2 |
${PROJECT_SOURCE_DIR} |
3 | 3 |
${PROJECT_BINARY_DIR} |
4 | 4 |
) |
5 | 5 |
|
6 | 6 |
LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon) |
7 | 7 |
|
8 | 8 |
SET(TESTS |
9 | 9 |
adaptors_test |
10 | 10 |
bfs_test |
11 | 11 |
circulation_test |
12 | 12 |
counter_test |
13 | 13 |
dfs_test |
14 | 14 |
digraph_test |
15 | 15 |
dijkstra_test |
16 | 16 |
dim_test |
17 | 17 |
edge_set_test |
18 | 18 |
error_test |
19 | 19 |
euler_test |
20 | 20 |
gomory_hu_test |
21 | 21 |
graph_copy_test |
22 | 22 |
graph_test |
23 | 23 |
graph_utils_test |
24 | 24 |
hao_orlin_test |
25 | 25 |
heap_test |
26 | 26 |
kruskal_test |
27 | 27 |
maps_test |
28 | 28 |
matching_test |
29 | 29 |
min_cost_arborescence_test |
30 | 30 |
min_cost_flow_test |
31 | 31 |
path_test |
32 | 32 |
preflow_test |
33 | 33 |
radix_sort_test |
34 | 34 |
random_test |
35 | 35 |
suurballe_test |
36 | 36 |
time_measure_test |
37 | 37 |
unionfind_test) |
38 | 38 |
|
39 |
IF( |
|
39 |
IF(LEMON_HAVE_LP) |
|
40 | 40 |
ADD_EXECUTABLE(lp_test lp_test.cc) |
41 | 41 |
SET(LP_TEST_LIBS lemon) |
42 |
IF( |
|
42 |
IF(LEMON_HAVE_GLPK) |
|
43 | 43 |
SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES}) |
44 |
ENDIF(HAVE_GLPK) |
|
45 |
IF(HAVE_CPLEX) |
|
44 |
ENDIF(LEMON_HAVE_GLPK) |
|
45 |
IF(LEMON_HAVE_CPLEX) |
|
46 | 46 |
SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES}) |
47 |
ENDIF(HAVE_CPLEX) |
|
48 |
IF(HAVE_CLP) |
|
47 |
ENDIF(LEMON_HAVE_CPLEX) |
|
48 |
IF(LEMON_HAVE_CLP) |
|
49 | 49 |
SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES}) |
50 |
ENDIF( |
|
50 |
ENDIF(LEMON_HAVE_CLP) |
|
51 | 51 |
TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS}) |
52 | 52 |
ADD_TEST(lp_test lp_test) |
53 | 53 |
|
54 |
IF(WIN32 AND |
|
54 |
IF(WIN32 AND LEMON_HAVE_GLPK) |
|
55 | 55 |
GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) |
56 | 56 |
GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) |
57 | 57 |
ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD |
58 | 58 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} |
59 | 59 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} |
60 | 60 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} |
61 | 61 |
) |
62 |
ENDIF(WIN32 AND HAVE_GLPK) |
|
63 |
IF(WIN32 AND HAVE_CPLEX) |
|
62 |
ENDIF(WIN32 AND LEMON_HAVE_GLPK) |
|
63 |
IF(WIN32 AND LEMON_HAVE_CPLEX) |
|
64 | 64 |
GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) |
65 | 65 |
GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) |
66 | 66 |
ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD |
67 | 67 |
COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} |
68 | 68 |
) |
69 |
ENDIF(WIN32 AND HAVE_CPLEX) |
|
70 |
ENDIF(HAVE_LP) |
|
69 |
ENDIF(WIN32 AND LEMON_HAVE_CPLEX) |
|
70 |
ENDIF(LEMON_HAVE_LP) |
|
71 | 71 |
|
72 |
IF( |
|
72 |
IF(LEMON_HAVE_MIP) |
|
73 | 73 |
ADD_EXECUTABLE(mip_test mip_test.cc) |
74 | 74 |
SET(MIP_TEST_LIBS lemon) |
75 |
IF( |
|
75 |
IF(LEMON_HAVE_GLPK) |
|
76 | 76 |
SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES}) |
77 |
ENDIF(HAVE_GLPK) |
|
78 |
IF(HAVE_CPLEX) |
|
77 |
ENDIF(LEMON_HAVE_GLPK) |
|
78 |
IF(LEMON_HAVE_CPLEX) |
|
79 | 79 |
SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES}) |
80 |
ENDIF(HAVE_CPLEX) |
|
81 |
IF(HAVE_CBC) |
|
80 |
ENDIF(LEMON_HAVE_CPLEX) |
|
81 |
IF(LEMON_HAVE_CBC) |
|
82 | 82 |
SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES}) |
83 |
ENDIF( |
|
83 |
ENDIF(LEMON_HAVE_CBC) |
|
84 | 84 |
TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS}) |
85 | 85 |
ADD_TEST(mip_test mip_test) |
86 | 86 |
|
87 |
IF(WIN32 AND |
|
87 |
IF(WIN32 AND LEMON_HAVE_GLPK) |
|
88 | 88 |
GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) |
89 | 89 |
GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) |
90 | 90 |
ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD |
91 | 91 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} |
92 | 92 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} |
93 | 93 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} |
94 | 94 |
) |
95 |
ENDIF(WIN32 AND HAVE_GLPK) |
|
96 |
IF(WIN32 AND HAVE_CPLEX) |
|
95 |
ENDIF(WIN32 AND LEMON_HAVE_GLPK) |
|
96 |
IF(WIN32 AND LEMON_HAVE_CPLEX) |
|
97 | 97 |
GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) |
98 | 98 |
GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) |
99 | 99 |
ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD |
100 | 100 |
COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} |
101 | 101 |
) |
102 |
ENDIF(WIN32 AND HAVE_CPLEX) |
|
103 |
ENDIF(HAVE_MIP) |
|
102 |
ENDIF(WIN32 AND LEMON_HAVE_CPLEX) |
|
103 |
ENDIF(LEMON_HAVE_MIP) |
|
104 | 104 |
|
105 | 105 |
FOREACH(TEST_NAME ${TESTS}) |
106 | 106 |
ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc) |
107 | 107 |
TARGET_LINK_LIBRARIES(${TEST_NAME} lemon) |
108 | 108 |
ADD_TEST(${TEST_NAME} ${TEST_NAME}) |
109 | 109 |
ENDFOREACH(TEST_NAME) |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <sstream> |
20 | 20 |
#include <lemon/lp_skeleton.h> |
21 | 21 |
#include "test_tools.h" |
22 | 22 |
#include <lemon/tolerance.h> |
23 | 23 |
|
24 | 24 |
#ifdef HAVE_CONFIG_H |
25 | 25 |
#include <lemon/config.h> |
26 | 26 |
#endif |
27 | 27 |
|
28 |
#ifdef |
|
28 |
#ifdef LEMON_HAVE_GLPK |
|
29 | 29 |
#include <lemon/glpk.h> |
30 | 30 |
#endif |
31 | 31 |
|
32 |
#ifdef |
|
32 |
#ifdef LEMON_HAVE_CPLEX |
|
33 | 33 |
#include <lemon/cplex.h> |
34 | 34 |
#endif |
35 | 35 |
|
36 |
#ifdef |
|
36 |
#ifdef LEMON_HAVE_SOPLEX |
|
37 | 37 |
#include <lemon/soplex.h> |
38 | 38 |
#endif |
39 | 39 |
|
40 |
#ifdef |
|
40 |
#ifdef LEMON_HAVE_CLP |
|
41 | 41 |
#include <lemon/clp.h> |
42 | 42 |
#endif |
43 | 43 |
|
44 | 44 |
using namespace lemon; |
45 | 45 |
|
46 | 46 |
void lpTest(LpSolver& lp) |
47 | 47 |
{ |
48 | 48 |
|
49 | 49 |
typedef LpSolver LP; |
50 | 50 |
|
51 | 51 |
std::vector<LP::Col> x(10); |
52 | 52 |
// for(int i=0;i<10;i++) x.push_back(lp.addCol()); |
53 | 53 |
lp.addColSet(x); |
54 | 54 |
lp.colLowerBound(x,1); |
55 | 55 |
lp.colUpperBound(x,1); |
56 | 56 |
lp.colBounds(x,1,2); |
57 | 57 |
|
58 | 58 |
std::vector<LP::Col> y(10); |
59 | 59 |
lp.addColSet(y); |
60 | 60 |
|
61 | 61 |
lp.colLowerBound(y,1); |
62 | 62 |
lp.colUpperBound(y,1); |
63 | 63 |
lp.colBounds(y,1,2); |
64 | 64 |
|
65 | 65 |
std::map<int,LP::Col> z; |
66 | 66 |
|
67 | 67 |
z.insert(std::make_pair(12,INVALID)); |
68 | 68 |
z.insert(std::make_pair(2,INVALID)); |
69 | 69 |
z.insert(std::make_pair(7,INVALID)); |
70 | 70 |
z.insert(std::make_pair(5,INVALID)); |
71 | 71 |
|
72 | 72 |
lp.addColSet(z); |
73 | 73 |
|
74 | 74 |
lp.colLowerBound(z,1); |
75 | 75 |
lp.colUpperBound(z,1); |
76 | 76 |
lp.colBounds(z,1,2); |
77 | 77 |
|
78 | 78 |
{ |
79 | 79 |
LP::Expr e,f,g; |
80 | 80 |
LP::Col p1,p2,p3,p4,p5; |
81 | 81 |
LP::Constr c; |
82 | 82 |
|
83 | 83 |
p1=lp.addCol(); |
84 | 84 |
p2=lp.addCol(); |
85 | 85 |
p3=lp.addCol(); |
86 | 86 |
p4=lp.addCol(); |
87 | 87 |
p5=lp.addCol(); |
88 | 88 |
|
89 | 89 |
e[p1]=2; |
90 | 90 |
*e=12; |
91 | 91 |
e[p1]+=2; |
92 | 92 |
*e+=12; |
93 | 93 |
e[p1]-=2; |
94 | 94 |
*e-=12; |
95 | 95 |
|
96 | 96 |
e=2; |
97 | 97 |
e=2.2; |
98 | 98 |
e=p1; |
99 | 99 |
e=f; |
100 | 100 |
|
101 | 101 |
e+=2; |
102 | 102 |
e+=2.2; |
103 | 103 |
e+=p1; |
104 | 104 |
e+=f; |
105 | 105 |
|
106 | 106 |
e-=2; |
107 | 107 |
e-=2.2; |
108 | 108 |
e-=p1; |
109 | 109 |
e-=f; |
110 | 110 |
|
111 | 111 |
e*=2; |
112 | 112 |
e*=2.2; |
113 | 113 |
e/=2; |
114 | 114 |
e/=2.2; |
115 | 115 |
|
116 | 116 |
e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+ |
117 | 117 |
(f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+ |
118 | 118 |
(f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+ |
119 | 119 |
2.2*f+f*2.2+f/2.2+ |
120 | 120 |
2*f+f*2+f/2+ |
121 | 121 |
2.2*p1+p1*2.2+p1/2.2+ |
122 | 122 |
2*p1+p1*2+p1/2 |
123 | 123 |
); |
124 | 124 |
|
125 | 125 |
|
126 | 126 |
c = (e <= f ); |
127 | 127 |
c = (e <= 2.2); |
128 | 128 |
c = (e <= 2 ); |
129 | 129 |
c = (e <= p1 ); |
130 | 130 |
c = (2.2<= f ); |
131 | 131 |
c = (2 <= f ); |
132 | 132 |
c = (p1 <= f ); |
133 | 133 |
c = (p1 <= p2 ); |
134 | 134 |
c = (p1 <= 2.2); |
135 | 135 |
c = (p1 <= 2 ); |
136 | 136 |
c = (2.2<= p2 ); |
... | ... |
@@ -286,136 +286,136 @@ |
286 | 286 |
lp.sense(lp.MAX); |
287 | 287 |
|
288 | 288 |
//Testing the problem retrieving routines |
289 | 289 |
check(lp.objCoeff(x1)==1,"First term should be 1 in the obj function!"); |
290 | 290 |
check(lp.sense() == lp.MAX,"This is a maximization!"); |
291 | 291 |
check(lp.coeff(upright,x1)==1,"The coefficient in question is 1!"); |
292 | 292 |
check(lp.colLowerBound(x1)==0, |
293 | 293 |
"The lower bound for variable x1 should be 0."); |
294 | 294 |
check(lp.colUpperBound(x1)==LpSolver::INF, |
295 | 295 |
"The upper bound for variable x1 should be infty."); |
296 | 296 |
check(lp.rowLowerBound(upright) == -LpSolver::INF, |
297 | 297 |
"The lower bound for the first row should be -infty."); |
298 | 298 |
check(lp.rowUpperBound(upright)==1, |
299 | 299 |
"The upper bound for the first row should be 1."); |
300 | 300 |
LpSolver::Expr e = lp.row(upright); |
301 | 301 |
check(e[x1] == 1, "The first coefficient should 1."); |
302 | 302 |
check(e[x2] == 2, "The second coefficient should 1."); |
303 | 303 |
|
304 | 304 |
lp.row(upright, x1+x2 <=1); |
305 | 305 |
e = lp.row(upright); |
306 | 306 |
check(e[x1] == 1, "The first coefficient should 1."); |
307 | 307 |
check(e[x2] == 1, "The second coefficient should 1."); |
308 | 308 |
|
309 | 309 |
LpSolver::DualExpr de = lp.col(x1); |
310 | 310 |
check( de[upright] == 1, "The first coefficient should 1."); |
311 | 311 |
|
312 | 312 |
LpSolver* clp = lp.cloneSolver(); |
313 | 313 |
|
314 | 314 |
//Testing the problem retrieving routines |
315 | 315 |
check(clp->objCoeff(x1)==1,"First term should be 1 in the obj function!"); |
316 | 316 |
check(clp->sense() == clp->MAX,"This is a maximization!"); |
317 | 317 |
check(clp->coeff(upright,x1)==1,"The coefficient in question is 1!"); |
318 | 318 |
// std::cout<<lp.colLowerBound(x1)<<std::endl; |
319 | 319 |
check(clp->colLowerBound(x1)==0, |
320 | 320 |
"The lower bound for variable x1 should be 0."); |
321 | 321 |
check(clp->colUpperBound(x1)==LpSolver::INF, |
322 | 322 |
"The upper bound for variable x1 should be infty."); |
323 | 323 |
|
324 | 324 |
check(lp.rowLowerBound(upright)==-LpSolver::INF, |
325 | 325 |
"The lower bound for the first row should be -infty."); |
326 | 326 |
check(lp.rowUpperBound(upright)==1, |
327 | 327 |
"The upper bound for the first row should be 1."); |
328 | 328 |
e = clp->row(upright); |
329 | 329 |
check(e[x1] == 1, "The first coefficient should 1."); |
330 | 330 |
check(e[x2] == 1, "The second coefficient should 1."); |
331 | 331 |
|
332 | 332 |
de = clp->col(x1); |
333 | 333 |
check(de[upright] == 1, "The first coefficient should 1."); |
334 | 334 |
|
335 | 335 |
delete clp; |
336 | 336 |
|
337 | 337 |
//Maximization of x1+x2 |
338 | 338 |
//over the triangle with vertices (0,0) (0,1) (1,0) |
339 | 339 |
double expected_opt=1; |
340 | 340 |
solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt); |
341 | 341 |
|
342 | 342 |
//Minimization |
343 | 343 |
lp.sense(lp.MIN); |
344 | 344 |
expected_opt=0; |
345 | 345 |
solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt); |
346 | 346 |
|
347 | 347 |
//Vertex (-1,0) instead of (0,0) |
348 | 348 |
lp.colLowerBound(x1, -LpSolver::INF); |
349 | 349 |
expected_opt=-1; |
350 | 350 |
solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt); |
351 | 351 |
|
352 | 352 |
//Erase one constraint and return to maximization |
353 | 353 |
lp.erase(upright); |
354 | 354 |
lp.sense(lp.MAX); |
355 | 355 |
expected_opt=LpSolver::INF; |
356 | 356 |
solveAndCheck(lp, LpSolver::UNBOUNDED, expected_opt); |
357 | 357 |
|
358 | 358 |
//Infeasibilty |
359 | 359 |
lp.addRow(x1+x2 <=-2); |
360 | 360 |
solveAndCheck(lp, LpSolver::INFEASIBLE, expected_opt); |
361 | 361 |
|
362 | 362 |
} |
363 | 363 |
|
364 | 364 |
template<class LP> |
365 | 365 |
void cloneTest() |
366 | 366 |
{ |
367 | 367 |
//Test for clone/new |
368 | 368 |
|
369 | 369 |
LP* lp = new LP(); |
370 | 370 |
LP* lpnew = lp->newSolver(); |
371 | 371 |
LP* lpclone = lp->cloneSolver(); |
372 | 372 |
delete lp; |
373 | 373 |
delete lpnew; |
374 | 374 |
delete lpclone; |
375 | 375 |
} |
376 | 376 |
|
377 | 377 |
int main() |
378 | 378 |
{ |
379 | 379 |
LpSkeleton lp_skel; |
380 | 380 |
lpTest(lp_skel); |
381 | 381 |
|
382 |
#ifdef |
|
382 |
#ifdef LEMON_HAVE_GLPK |
|
383 | 383 |
{ |
384 | 384 |
GlpkLp lp_glpk1,lp_glpk2; |
385 | 385 |
lpTest(lp_glpk1); |
386 | 386 |
aTest(lp_glpk2); |
387 | 387 |
cloneTest<GlpkLp>(); |
388 | 388 |
} |
389 | 389 |
#endif |
390 | 390 |
|
391 |
#ifdef |
|
391 |
#ifdef LEMON_HAVE_CPLEX |
|
392 | 392 |
try { |
393 | 393 |
CplexLp lp_cplex1,lp_cplex2; |
394 | 394 |
lpTest(lp_cplex1); |
395 | 395 |
aTest(lp_cplex2); |
396 | 396 |
cloneTest<CplexLp>(); |
397 | 397 |
} catch (CplexEnv::LicenseError& error) { |
398 | 398 |
check(false, error.what()); |
399 | 399 |
} |
400 | 400 |
#endif |
401 | 401 |
|
402 |
#ifdef |
|
402 |
#ifdef LEMON_HAVE_SOPLEX |
|
403 | 403 |
{ |
404 | 404 |
SoplexLp lp_soplex1,lp_soplex2; |
405 | 405 |
lpTest(lp_soplex1); |
406 | 406 |
aTest(lp_soplex2); |
407 | 407 |
cloneTest<SoplexLp>(); |
408 | 408 |
} |
409 | 409 |
#endif |
410 | 410 |
|
411 |
#ifdef |
|
411 |
#ifdef LEMON_HAVE_CLP |
|
412 | 412 |
{ |
413 | 413 |
ClpLp lp_clp1,lp_clp2; |
414 | 414 |
lpTest(lp_clp1); |
415 | 415 |
aTest(lp_clp2); |
416 | 416 |
cloneTest<ClpLp>(); |
417 | 417 |
} |
418 | 418 |
#endif |
419 | 419 |
|
420 | 420 |
return 0; |
421 | 421 |
} |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include "test_tools.h" |
20 | 20 |
|
21 | 21 |
#ifdef HAVE_CONFIG_H |
22 | 22 |
#include <lemon/config.h> |
23 | 23 |
#endif |
24 | 24 |
|
25 |
#ifdef |
|
25 |
#ifdef LEMON_HAVE_CPLEX |
|
26 | 26 |
#include <lemon/cplex.h> |
27 | 27 |
#endif |
28 | 28 |
|
29 |
#ifdef |
|
29 |
#ifdef LEMON_HAVE_GLPK |
|
30 | 30 |
#include <lemon/glpk.h> |
31 | 31 |
#endif |
32 | 32 |
|
33 |
#ifdef |
|
33 |
#ifdef LEMON_HAVE_CBC |
|
34 | 34 |
#include <lemon/cbc.h> |
35 | 35 |
#endif |
36 | 36 |
|
37 | 37 |
|
38 | 38 |
using namespace lemon; |
39 | 39 |
|
40 | 40 |
void solveAndCheck(MipSolver& mip, MipSolver::ProblemType stat, |
41 | 41 |
double exp_opt) { |
42 | 42 |
using std::string; |
43 | 43 |
|
44 | 44 |
mip.solve(); |
45 | 45 |
//int decimal,sign; |
46 | 46 |
std::ostringstream buf; |
47 | 47 |
buf << "Type should be: " << int(stat)<<" and it is "<<int(mip.type()); |
48 | 48 |
|
49 | 49 |
|
50 | 50 |
// itoa(stat,buf1, 10); |
51 | 51 |
check(mip.type()==stat, buf.str()); |
52 | 52 |
|
53 | 53 |
if (stat == MipSolver::OPTIMAL) { |
54 | 54 |
std::ostringstream sbuf; |
55 | 55 |
buf << "Wrong optimal value: the right optimum is " << exp_opt; |
56 | 56 |
check(std::abs(mip.solValue()-exp_opt) < 1e-3, sbuf.str()); |
57 | 57 |
//+ecvt(exp_opt,2) |
58 | 58 |
} |
59 | 59 |
} |
60 | 60 |
|
61 | 61 |
void aTest(MipSolver& mip) |
62 | 62 |
{ |
63 | 63 |
//The following example is very simple |
64 | 64 |
|
65 | 65 |
|
66 | 66 |
typedef MipSolver::Row Row; |
67 | 67 |
typedef MipSolver::Col Col; |
68 | 68 |
|
69 | 69 |
|
70 | 70 |
Col x1 = mip.addCol(); |
71 | 71 |
Col x2 = mip.addCol(); |
72 | 72 |
|
73 | 73 |
|
74 | 74 |
//Objective function |
75 | 75 |
mip.obj(x1); |
76 | 76 |
|
77 | 77 |
mip.max(); |
78 | 78 |
|
79 | 79 |
//Unconstrained optimization |
80 | 80 |
mip.solve(); |
81 | 81 |
//Check it out! |
82 | 82 |
|
83 | 83 |
//Constraints |
84 | 84 |
mip.addRow(2 * x1 + x2 <= 2); |
85 | 85 |
Row y2 = mip.addRow(x1 - 2 * x2 <= 0); |
86 | 86 |
|
87 | 87 |
//Nonnegativity of the variable x1 |
88 | 88 |
mip.colLowerBound(x1, 0); |
89 | 89 |
|
90 | 90 |
|
91 | 91 |
//Maximization of x1 |
92 | 92 |
//over the triangle with vertices (0,0),(4/5,2/5),(0,2) |
93 | 93 |
double expected_opt=4.0/5.0; |
94 | 94 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
95 | 95 |
|
96 | 96 |
|
97 | 97 |
//Restrict x2 to integer |
98 | 98 |
mip.colType(x2,MipSolver::INTEGER); |
99 | 99 |
expected_opt=1.0/2.0; |
100 | 100 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
101 | 101 |
|
102 | 102 |
|
103 | 103 |
//Restrict both to integer |
104 | 104 |
mip.colType(x1,MipSolver::INTEGER); |
105 | 105 |
expected_opt=0; |
106 | 106 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
107 | 107 |
|
108 | 108 |
//Erase a variable |
109 | 109 |
mip.erase(x2); |
110 | 110 |
mip.rowUpperBound(y2, 8); |
111 | 111 |
expected_opt=1; |
112 | 112 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
113 | 113 |
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
|
117 | 117 |
template<class MIP> |
118 | 118 |
void cloneTest() |
119 | 119 |
{ |
120 | 120 |
|
121 | 121 |
MIP* mip = new MIP(); |
122 | 122 |
MIP* mipnew = mip->newSolver(); |
123 | 123 |
MIP* mipclone = mip->cloneSolver(); |
124 | 124 |
delete mip; |
125 | 125 |
delete mipnew; |
126 | 126 |
delete mipclone; |
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
int main() |
130 | 130 |
{ |
131 | 131 |
|
132 |
#ifdef |
|
132 |
#ifdef LEMON_HAVE_GLPK |
|
133 | 133 |
{ |
134 | 134 |
GlpkMip mip1; |
135 | 135 |
aTest(mip1); |
136 | 136 |
cloneTest<GlpkMip>(); |
137 | 137 |
} |
138 | 138 |
#endif |
139 | 139 |
|
140 |
#ifdef |
|
140 |
#ifdef LEMON_HAVE_CPLEX |
|
141 | 141 |
try { |
142 | 142 |
CplexMip mip2; |
143 | 143 |
aTest(mip2); |
144 | 144 |
cloneTest<CplexMip>(); |
145 | 145 |
} catch (CplexEnv::LicenseError& error) { |
146 | 146 |
check(false, error.what()); |
147 | 147 |
} |
148 | 148 |
#endif |
149 | 149 |
|
150 |
#ifdef |
|
150 |
#ifdef LEMON_HAVE_CBC |
|
151 | 151 |
{ |
152 | 152 |
CbcMip mip1; |
153 | 153 |
aTest(mip1); |
154 | 154 |
cloneTest<CbcMip>(); |
155 | 155 |
} |
156 | 156 |
#endif |
157 | 157 |
|
158 | 158 |
return 0; |
159 | 159 |
|
160 | 160 |
} |
... | ... |
@@ -107,171 +107,171 @@ |
107 | 107 |
Value sum_sup = 0; |
108 | 108 |
for (Digraph::NodeIt n(g); n != INVALID; ++n) { |
109 | 109 |
sum_sup += sup[n]; |
110 | 110 |
} |
111 | 111 |
if (report) { |
112 | 112 |
std::cerr << "Sum of supply values: " << sum_sup << "\n"; |
113 | 113 |
if (sum_sup <= 0) |
114 | 114 |
std::cerr << "GEQ supply contraints are used for NetworkSimplex\n\n"; |
115 | 115 |
else |
116 | 116 |
std::cerr << "LEQ supply contraints are used for NetworkSimplex\n\n"; |
117 | 117 |
} |
118 | 118 |
if (report) std::cerr << "Read the file: " << ti << '\n'; |
119 | 119 |
|
120 | 120 |
ti.restart(); |
121 | 121 |
NetworkSimplex<Digraph, Value> ns(g); |
122 | 122 |
ns.lowerMap(lower).capacityMap(cap).costMap(cost).supplyMap(sup); |
123 | 123 |
if (sum_sup > 0) ns.problemType(ns.LEQ); |
124 | 124 |
if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n'; |
125 | 125 |
ti.restart(); |
126 | 126 |
bool res = ns.run(); |
127 | 127 |
if (report) { |
128 | 128 |
std::cerr << "Run NetworkSimplex: " << ti << "\n\n"; |
129 | 129 |
std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n'; |
130 | 130 |
if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n'; |
131 | 131 |
} |
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
void solve_mat(ArgParser &ap, std::istream &is, std::ostream &, |
135 | 135 |
DimacsDescriptor &desc) |
136 | 136 |
{ |
137 | 137 |
bool report = !ap.given("q"); |
138 | 138 |
Graph g; |
139 | 139 |
Timer ti; |
140 | 140 |
ti.restart(); |
141 | 141 |
readDimacsMat(is, g, desc); |
142 | 142 |
if(report) std::cerr << "Read the file: " << ti << '\n'; |
143 | 143 |
ti.restart(); |
144 | 144 |
MaxMatching<Graph> mat(g); |
145 | 145 |
if(report) std::cerr << "Setup MaxMatching class: " << ti << '\n'; |
146 | 146 |
ti.restart(); |
147 | 147 |
mat.run(); |
148 | 148 |
if(report) std::cerr << "Run MaxMatching: " << ti << '\n'; |
149 | 149 |
if(report) std::cerr << "\nCardinality of max matching: " |
150 | 150 |
<< mat.matchingSize() << '\n'; |
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
|
154 | 154 |
template<class Value> |
155 | 155 |
void solve(ArgParser &ap, std::istream &is, std::ostream &os, |
156 | 156 |
DimacsDescriptor &desc) |
157 | 157 |
{ |
158 | 158 |
std::stringstream iss(static_cast<std::string>(ap["infcap"])); |
159 | 159 |
Value infty; |
160 | 160 |
iss >> infty; |
161 | 161 |
if(iss.fail()) |
162 | 162 |
{ |
163 | 163 |
std::cerr << "Cannot interpret '" |
164 | 164 |
<< static_cast<std::string>(ap["infcap"]) << "' as infinite" |
165 | 165 |
<< std::endl; |
166 | 166 |
exit(1); |
167 | 167 |
} |
168 | 168 |
|
169 | 169 |
switch(desc.type) |
170 | 170 |
{ |
171 | 171 |
case DimacsDescriptor::MIN: |
172 | 172 |
solve_min<Value>(ap,is,os,infty,desc); |
173 | 173 |
break; |
174 | 174 |
case DimacsDescriptor::MAX: |
175 | 175 |
solve_max<Value>(ap,is,os,infty,desc); |
176 | 176 |
break; |
177 | 177 |
case DimacsDescriptor::SP: |
178 | 178 |
solve_sp<Value>(ap,is,os,desc); |
179 | 179 |
break; |
180 | 180 |
case DimacsDescriptor::MAT: |
181 | 181 |
solve_mat(ap,is,os,desc); |
182 | 182 |
break; |
183 | 183 |
default: |
184 | 184 |
break; |
185 | 185 |
} |
186 | 186 |
} |
187 | 187 |
|
188 | 188 |
int main(int argc, const char *argv[]) { |
189 | 189 |
typedef SmartDigraph Digraph; |
190 | 190 |
|
191 | 191 |
typedef Digraph::Arc Arc; |
192 | 192 |
|
193 | 193 |
std::string inputName; |
194 | 194 |
std::string outputName; |
195 | 195 |
|
196 | 196 |
ArgParser ap(argc, argv); |
197 | 197 |
ap.other("[INFILE [OUTFILE]]", |
198 | 198 |
"If either the INFILE or OUTFILE file is missing the standard\n" |
199 | 199 |
" input/output will be used instead.") |
200 | 200 |
.boolOption("q", "Do not print any report") |
201 | 201 |
.boolOption("int","Use 'int' for capacities, costs etc. (default)") |
202 | 202 |
.optionGroup("datatype","int") |
203 |
#ifdef |
|
203 |
#ifdef LEMON_HAVE_LONG_LONG |
|
204 | 204 |
.boolOption("long","Use 'long long' for capacities, costs etc.") |
205 | 205 |
.optionGroup("datatype","long") |
206 | 206 |
#endif |
207 | 207 |
.boolOption("double","Use 'double' for capacities, costs etc.") |
208 | 208 |
.optionGroup("datatype","double") |
209 | 209 |
.boolOption("ldouble","Use 'long double' for capacities, costs etc.") |
210 | 210 |
.optionGroup("datatype","ldouble") |
211 | 211 |
.onlyOneGroup("datatype") |
212 | 212 |
.stringOption("infcap","Value used for 'very high' capacities","0") |
213 | 213 |
.run(); |
214 | 214 |
|
215 | 215 |
std::ifstream input; |
216 | 216 |
std::ofstream output; |
217 | 217 |
|
218 | 218 |
switch(ap.files().size()) |
219 | 219 |
{ |
220 | 220 |
case 2: |
221 | 221 |
output.open(ap.files()[1].c_str()); |
222 | 222 |
if (!output) { |
223 | 223 |
throw IoError("Cannot open the file for writing", ap.files()[1]); |
224 | 224 |
} |
225 | 225 |
case 1: |
226 | 226 |
input.open(ap.files()[0].c_str()); |
227 | 227 |
if (!input) { |
228 | 228 |
throw IoError("File cannot be found", ap.files()[0]); |
229 | 229 |
} |
230 | 230 |
case 0: |
231 | 231 |
break; |
232 | 232 |
default: |
233 | 233 |
std::cerr << ap.commandName() << ": too many arguments\n"; |
234 | 234 |
return 1; |
235 | 235 |
} |
236 | 236 |
std::istream& is = (ap.files().size()<1 ? std::cin : input); |
237 | 237 |
std::ostream& os = (ap.files().size()<2 ? std::cout : output); |
238 | 238 |
|
239 | 239 |
DimacsDescriptor desc = dimacsType(is); |
240 | 240 |
|
241 | 241 |
if(!ap.given("q")) |
242 | 242 |
{ |
243 | 243 |
std::cout << "Problem type: "; |
244 | 244 |
switch(desc.type) |
245 | 245 |
{ |
246 | 246 |
case DimacsDescriptor::MIN: |
247 | 247 |
std::cout << "min"; |
248 | 248 |
break; |
249 | 249 |
case DimacsDescriptor::MAX: |
250 | 250 |
std::cout << "max"; |
251 | 251 |
break; |
252 | 252 |
case DimacsDescriptor::SP: |
253 | 253 |
std::cout << "sp"; |
254 | 254 |
case DimacsDescriptor::MAT: |
255 | 255 |
std::cout << "mat"; |
256 | 256 |
break; |
257 | 257 |
default: |
258 | 258 |
exit(1); |
259 | 259 |
break; |
260 | 260 |
} |
261 | 261 |
std::cout << "\nNum of nodes: " << desc.nodeNum; |
262 | 262 |
std::cout << "\nNum of arcs: " << desc.edgeNum; |
263 | 263 |
std::cout << "\n\n"; |
264 | 264 |
} |
265 | 265 |
|
266 | 266 |
if(ap.given("double")) |
267 | 267 |
solve<double>(ap,is,os,desc); |
268 | 268 |
else if(ap.given("ldouble")) |
269 | 269 |
solve<long double>(ap,is,os,desc); |
270 |
#ifdef |
|
270 |
#ifdef LEMON_HAVE_LONG_LONG |
|
271 | 271 |
else if(ap.given("long")) |
272 | 272 |
solve<long long>(ap,is,os,desc); |
273 | 273 |
#endif |
274 | 274 |
else solve<int>(ap,is,os,desc); |
275 | 275 |
|
276 | 276 |
return 0; |
277 | 277 |
} |
0 comments (0 inline)