0
23
0
3
2
46
26
1
1
1
1
8
8
24
24
8
10
| 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 |
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
|
| 21 |
|
|
| 22 | 20 |
IF(MSVC) |
| 23 | 21 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4800 /wd4996")
|
| 24 | 22 |
# Suppressed warnings: |
| 25 | 23 |
# C4250: 'class1' : inherits 'class2::member' via dominance |
| 26 | 24 |
# C4355: 'this' : used in base member initializer list |
| 27 | 25 |
# C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning) |
| 28 | 26 |
# C4996: 'function': was declared deprecated |
| 29 | 27 |
ENDIF(MSVC) |
| 30 | 28 |
|
| 31 | 29 |
INCLUDE(CheckTypeSize) |
| 32 |
CHECK_TYPE_SIZE("long long"
|
|
| 30 |
CHECK_TYPE_SIZE("long long" LEMON_LONG_LONG)
|
|
| 33 | 31 |
|
| 34 | 32 |
ENABLE_TESTING() |
| 35 | 33 |
|
| 36 | 34 |
ADD_SUBDIRECTORY(lemon) |
| 37 | 35 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
|
| 38 | 36 |
ADD_SUBDIRECTORY(demo) |
| 39 | 37 |
ADD_SUBDIRECTORY(tools) |
| 40 | 38 |
ADD_SUBDIRECTORY(doc) |
| 41 | 39 |
ADD_SUBDIRECTORY(test) |
| 42 | 40 |
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
|
| 43 | 41 |
|
| 44 | 42 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
|
| 45 | 43 |
IF(WIN32) |
| 46 | 44 |
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
| 47 | 45 |
SET(CPACK_PACKAGE_VENDOR "EGRES") |
| 48 | 46 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
| 49 | 47 |
"LEMON - Library of Efficient Models and Optimization in Networks") |
| 50 | 48 |
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
| 51 | 49 |
|
| 52 | 50 |
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
| 53 | 51 |
|
| 54 | 52 |
SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
| 55 | 53 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
| 56 | 54 |
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
| 57 | 55 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
| 58 | 56 |
|
| 59 | 57 |
SET(CPACK_COMPONENTS_ALL headers library html_documentation bin) |
| 60 | 58 |
|
| 61 | 59 |
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") |
| 62 | 60 |
SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") |
| 63 | 61 |
SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities") |
| 64 | 62 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") |
| 65 | 63 |
|
| 66 | 64 |
SET(CPACK_COMPONENT_HEADERS_DESCRIPTION |
| 67 | 65 |
"C++ header files") |
| 68 | 66 |
SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION |
| 69 | 67 |
"DLL and import library") |
| 70 | 68 |
SET(CPACK_COMPONENT_BIN_DESCRIPTION |
| 71 | 69 |
"Command line utilities") |
| 72 | 70 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION |
| 73 | 71 |
"Doxygen generated documentation") |
| 74 | 72 |
|
| 75 | 73 |
SET(CPACK_COMPONENT_HEADERS_DEPENDS library) |
| 76 | 74 |
|
| 77 | 75 |
SET(CPACK_COMPONENT_HEADERS_GROUP "Development") |
| 78 | 76 |
SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") |
| 79 | 77 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation") |
| 80 | 78 |
|
| 81 | 79 |
SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION |
| 82 | 80 |
"Components needed to develop software using LEMON") |
| 83 | 81 |
SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION |
| 84 | 82 |
"Documentation of LEMON") |
| 85 | 83 |
|
| 86 | 84 |
SET(CPACK_ALL_INSTALL_TYPES Full Developer) |
| 87 | 85 |
|
| 88 | 86 |
SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) |
| 89 | 87 |
SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full) |
| 90 | 88 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full) |
| 91 | 89 |
|
| 92 | 90 |
SET(CPACK_GENERATOR "NSIS") |
| 93 | 91 |
SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
|
| 94 | 92 |
SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
|
| 95 | 93 |
#SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
|
| 96 | 94 |
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico") |
| 97 | 95 |
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
|
| 98 | 96 |
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu") |
| 99 | 97 |
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu") |
| 100 | 98 |
SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu") |
| 101 | 99 |
SET(CPACK_NSIS_CREATE_ICONS_EXTRA " |
| 102 | 100 |
CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\" |
| 103 | 101 |
") |
| 104 | 102 |
SET(CPACK_NSIS_DELETE_ICONS_EXTRA " |
| 105 | 103 |
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP |
| 106 | 104 |
Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\" |
| 107 | 105 |
") |
| 108 | 106 |
|
| 109 | 107 |
INCLUDE(CPack) |
| 110 | 108 |
ENDIF(WIN32) |
| 111 | 109 |
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
|
| 1 | 1 |
ACLOCAL_AMFLAGS = -I m4 |
| 2 | 2 |
|
| 3 | 3 |
AM_CXXFLAGS = $(WARNINGCXXFLAGS) |
| 4 | 4 |
|
| 5 | 5 |
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) |
| 6 | 6 |
LDADD = $(top_builddir)/lemon/libemon.la |
| 7 | 7 |
|
| 8 | 8 |
EXTRA_DIST = \ |
| 9 | 9 |
AUTHORS \ |
| 10 | 10 |
LICENSE \ |
| 11 | 11 |
m4/lx_check_cplex.m4 \ |
| 12 | 12 |
m4/lx_check_glpk.m4 \ |
| 13 | 13 |
m4/lx_check_soplex.m4 \ |
| 14 |
m4/lx_check_clp.m4 \ |
|
| 15 |
m4/lx_check_cbc.m4 \ |
|
| 14 |
m4/lx_check_coin.m4 \ |
|
| 16 | 15 |
CMakeLists.txt \ |
| 17 | 16 |
cmake/FindGhostscript.cmake \ |
| 17 |
cmake/FindCPLEX.cmake \ |
|
| 18 | 18 |
cmake/FindGLPK.cmake \ |
| 19 |
cmake/FindCOIN.cmake \ |
|
| 19 | 20 |
cmake/version.cmake.in \ |
| 20 | 21 |
cmake/version.cmake \ |
| 21 | 22 |
cmake/nsis/lemon.ico \ |
| 22 | 23 |
cmake/nsis/uninstall.ico |
| 23 | 24 |
|
| 24 | 25 |
pkgconfigdir = $(libdir)/pkgconfig |
| 25 | 26 |
lemondir = $(pkgincludedir) |
| 26 | 27 |
bitsdir = $(lemondir)/bits |
| 27 | 28 |
conceptdir = $(lemondir)/concepts |
| 28 | 29 |
pkgconfig_DATA = |
| 29 | 30 |
lib_LTLIBRARIES = |
| 30 | 31 |
lemon_HEADERS = |
| 31 | 32 |
bits_HEADERS = |
| 32 | 33 |
concept_HEADERS = |
| 33 | 34 |
noinst_HEADERS = |
| 34 | 35 |
noinst_PROGRAMS = |
| 35 | 36 |
bin_PROGRAMS = |
| 36 | 37 |
check_PROGRAMS = |
| 37 | 38 |
dist_bin_SCRIPTS = |
| 38 | 39 |
TESTS = |
| 39 | 40 |
XFAIL_TESTS = |
| 40 | 41 |
|
| 41 | 42 |
include lemon/Makefile.am |
| 42 | 43 |
include test/Makefile.am |
| 43 | 44 |
include doc/Makefile.am |
| 44 | 45 |
include tools/Makefile.am |
| 45 | 46 |
|
| 46 | 47 |
DIST_SUBDIRS = demo |
| 47 | 48 |
|
| 48 | 49 |
demo: |
| 49 | 50 |
$(MAKE) $(AM_MAKEFLAGS) -C demo |
| 50 | 51 |
|
| 51 | 52 |
MRPROPERFILES = \ |
| 52 | 53 |
aclocal.m4 \ |
| 53 | 54 |
config.h.in \ |
| 54 | 55 |
config.h.in~ \ |
| 55 | 56 |
configure \ |
| 56 | 57 |
Makefile.in \ |
| 57 | 58 |
build-aux/config.guess \ |
| 58 | 59 |
build-aux/config.sub \ |
| 59 | 60 |
build-aux/depcomp \ |
| 60 | 61 |
build-aux/install-sh \ |
| 61 | 62 |
build-aux/ltmain.sh \ |
| 62 | 63 |
build-aux/missing \ |
| 63 | 64 |
doc/doxygen.log |
| 64 | 65 |
|
| 65 | 66 |
mrproper: |
| 66 | 67 |
$(MAKE) $(AM_MAKEFLAGS) maintainer-clean |
| 67 | 68 |
-rm -f $(MRPROPERFILES) |
| 68 | 69 |
|
| 69 | 70 |
dist-bz2: dist |
| 70 | 71 |
zcat $(PACKAGE)-$(VERSION).tar.gz | \ |
| 71 | 72 |
bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2 |
| 72 | 73 |
|
| 73 | 74 |
distcheck-bz2: distcheck |
| 74 | 75 |
zcat $(PACKAGE)-$(VERSION).tar.gz | \ |
| 75 | 76 |
bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2 |
| 76 | 77 |
|
| 77 | 78 |
.PHONY: demo mrproper dist-bz2 distcheck-bz2 |
| 1 | 1 |
SET(COIN_ROOT_DIR "" CACHE PATH "COIN root directory") |
| 2 | 2 |
|
| 3 | 3 |
FIND_PATH(COIN_INCLUDE_DIR coin/CoinUtilsConfig.h |
| 4 |
PATHS ${COIN_ROOT_DIR}/include)
|
|
| 5 |
|
|
| 6 |
FIND_LIBRARY(COIN_CBC_LIBRARY libCbc |
|
| 7 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 8 |
FIND_LIBRARY(COIN_CBC_SOLVER_LIBRARY libCbcSolver |
|
| 9 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 10 |
FIND_LIBRARY(COIN_CGL_LIBRARY libCgl |
|
| 11 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 12 |
FIND_LIBRARY(COIN_CLP_LIBRARY libClp |
|
| 13 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 14 |
FIND_LIBRARY(COIN_COIN_UTILS_LIBRARY libCoinUtils |
|
| 15 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 16 |
FIND_LIBRARY(COIN_OSI_LIBRARY libOsi |
|
| 17 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 18 |
FIND_LIBRARY(COIN_OSI_CBC_LIBRARY libOsiCbc |
|
| 19 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 20 |
FIND_LIBRARY(COIN_OSI_CLP_LIBRARY libOsiClp |
|
| 21 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 22 |
FIND_LIBRARY(COIN_OSI_VOL_LIBRARY libOsiVol |
|
| 23 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 24 |
FIND_LIBRARY(COIN_VOL_LIBRARY libVol |
|
| 25 |
PATHS ${COIN_ROOT_DIR}/lib)
|
|
| 4 |
HINTS ${COIN_ROOT_DIR}/include
|
|
| 5 |
) |
|
| 6 |
FIND_LIBRARY(COIN_CBC_LIBRARY |
|
| 7 |
NAMES Cbc libCbc |
|
| 8 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 9 |
) |
|
| 10 |
FIND_LIBRARY(COIN_CBC_SOLVER_LIBRARY |
|
| 11 |
NAMES CbcSolver libCbcSolver |
|
| 12 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 13 |
) |
|
| 14 |
FIND_LIBRARY(COIN_CGL_LIBRARY |
|
| 15 |
NAMES Cgl libCgl |
|
| 16 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 17 |
) |
|
| 18 |
FIND_LIBRARY(COIN_CLP_LIBRARY |
|
| 19 |
NAMES Clp libClp |
|
| 20 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 21 |
) |
|
| 22 |
FIND_LIBRARY(COIN_COIN_UTILS_LIBRARY |
|
| 23 |
NAMES CoinUtils libCoinUtils |
|
| 24 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 25 |
) |
|
| 26 |
FIND_LIBRARY(COIN_OSI_LIBRARY |
|
| 27 |
NAMES Osi libOsi |
|
| 28 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 29 |
) |
|
| 30 |
FIND_LIBRARY(COIN_OSI_CBC_LIBRARY |
|
| 31 |
NAMES OsiCbc libOsiCbc |
|
| 32 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 33 |
) |
|
| 34 |
FIND_LIBRARY(COIN_OSI_CLP_LIBRARY |
|
| 35 |
NAMES OsiClp libOsiClp |
|
| 36 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 37 |
) |
|
| 38 |
FIND_LIBRARY(COIN_OSI_VOL_LIBRARY |
|
| 39 |
NAMES OsiVol libOsiVol |
|
| 40 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 41 |
) |
|
| 42 |
FIND_LIBRARY(COIN_VOL_LIBRARY |
|
| 43 |
NAMES Vol libVol |
|
| 44 |
HINTS ${COIN_ROOT_DIR}/lib
|
|
| 45 |
) |
|
| 26 | 46 |
|
| 27 | 47 |
INCLUDE(FindPackageHandleStandardArgs) |
| 28 | 48 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG |
| 29 | 49 |
COIN_INCLUDE_DIR |
| 30 | 50 |
COIN_CBC_LIBRARY |
| 31 | 51 |
COIN_CBC_SOLVER_LIBRARY |
| 32 | 52 |
COIN_CGL_LIBRARY |
| 33 | 53 |
COIN_CLP_LIBRARY |
| 34 | 54 |
COIN_COIN_UTILS_LIBRARY |
| 35 | 55 |
COIN_OSI_LIBRARY |
| 36 | 56 |
COIN_OSI_CBC_LIBRARY |
| 37 | 57 |
COIN_OSI_CLP_LIBRARY |
| 38 | 58 |
COIN_OSI_VOL_LIBRARY |
| 39 | 59 |
COIN_VOL_LIBRARY |
| 40 | 60 |
) |
| 41 | 61 |
|
| 42 | 62 |
IF(COIN_FOUND) |
| 43 | 63 |
SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR})
|
| 44 | 64 |
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 | 65 |
SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY}")
|
| 46 | 66 |
SET(COIN_CBC_LIBRARIES ${COIN_LIBRARIES})
|
| 47 | 67 |
ENDIF(COIN_FOUND) |
| 48 | 68 |
|
| 49 | 69 |
MARK_AS_ADVANCED( |
| 50 | 70 |
COIN_INCLUDE_DIR |
| 51 | 71 |
COIN_CBC_LIBRARY |
| 52 | 72 |
COIN_CBC_SOLVER_LIBRARY |
| 53 | 73 |
COIN_CGL_LIBRARY |
| 54 | 74 |
COIN_CLP_LIBRARY |
| 55 | 75 |
COIN_COIN_UTILS_LIBRARY |
| 56 | 76 |
COIN_OSI_LIBRARY |
| 57 | 77 |
COIN_OSI_CBC_LIBRARY |
| 58 | 78 |
COIN_OSI_CLP_LIBRARY |
| 59 | 79 |
COIN_OSI_VOL_LIBRARY |
| 60 | 80 |
COIN_VOL_LIBRARY |
| 61 | 81 |
) |
| 62 | 82 |
|
| 63 | 83 |
IF(COIN_FOUND) |
| 64 |
SET(HAVE_LP TRUE) |
|
| 65 |
SET(HAVE_MIP TRUE) |
|
| 66 |
SET(HAVE_CLP TRUE) |
|
| 67 |
SET(HAVE_CBC TRUE) |
|
| 84 |
SET(LEMON_HAVE_LP TRUE) |
|
| 85 |
SET(LEMON_HAVE_MIP TRUE) |
|
| 86 |
SET(LEMON_HAVE_CLP TRUE) |
|
| 87 |
SET(LEMON_HAVE_CBC TRUE) |
|
| 68 | 88 |
ENDIF(COIN_FOUND) |
| 1 |
SET(CPLEX_ROOT_DIR "" CACHE PATH "CPLEX root directory") |
|
| 2 |
|
|
| 1 | 3 |
FIND_PATH(CPLEX_INCLUDE_DIR |
| 2 | 4 |
ilcplex/cplex.h |
| 3 |
PATHS "C:/ILOG/CPLEX91/include") |
|
| 4 |
|
|
| 5 |
PATHS "C:/ILOG/CPLEX91/include" |
|
| 6 |
PATHS "/opt/ilog/cplex91/include" |
|
| 7 |
HINTS ${CPLEX_ROOT_DIR}/include
|
|
| 8 |
) |
|
| 5 | 9 |
FIND_LIBRARY(CPLEX_LIBRARY |
| 6 |
NAMES cplex91 |
|
| 7 |
PATHS "C:/ILOG/CPLEX91/lib/msvc7/stat_mda") |
|
| 10 |
cplex91 |
|
| 11 |
PATHS "C:/ILOG/CPLEX91/lib/msvc7/stat_mda" |
|
| 12 |
PATHS "/opt/ilog/cplex91/bin" |
|
| 13 |
HINTS ${CPLEX_ROOT_DIR}/bin
|
|
| 14 |
) |
|
| 8 | 15 |
|
| 9 | 16 |
INCLUDE(FindPackageHandleStandardArgs) |
| 10 | 17 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPLEX DEFAULT_MSG CPLEX_LIBRARY CPLEX_INCLUDE_DIR) |
| 11 | 18 |
|
| 12 | 19 |
FIND_PATH(CPLEX_BIN_DIR |
| 13 | 20 |
cplex91.dll |
| 14 |
PATHS "C:/ILOG/CPLEX91/bin/x86_win32" |
|
| 21 |
PATHS "C:/ILOG/CPLEX91/bin/x86_win32" |
|
| 22 |
) |
|
| 15 | 23 |
|
| 16 | 24 |
IF(CPLEX_FOUND) |
| 17 | 25 |
SET(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE_DIR})
|
| 18 | 26 |
SET(CPLEX_LIBRARIES ${CPLEX_LIBRARY})
|
| 27 |
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
|
| 28 |
SET(CPLEX_LIBRARIES "${CPLEX_LIBRARIES};m;pthread")
|
|
| 29 |
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
|
| 19 | 30 |
ENDIF(CPLEX_FOUND) |
| 20 | 31 |
|
| 21 | 32 |
MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_BIN_DIR) |
| 22 | 33 |
|
| 23 | 34 |
IF(CPLEX_FOUND) |
| 24 |
SET(HAVE_LP TRUE) |
|
| 25 |
SET(HAVE_MIP TRUE) |
|
| 26 |
SET( |
|
| 35 |
SET(LEMON_HAVE_LP TRUE) |
|
| 36 |
SET(LEMON_HAVE_MIP TRUE) |
|
| 37 |
SET(LEMON_HAVE_CPLEX TRUE) |
|
| 27 | 38 |
ENDIF(CPLEX_FOUND) |
| 1 |
SET(GLPK_ROOT_DIR "" CACHE PATH "GLPK root directory") |
|
| 2 |
|
|
| 1 | 3 |
SET(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]") |
| 2 | 4 |
GET_FILENAME_COMPONENT(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE)
|
| 3 | 5 |
|
| 4 | 6 |
FIND_PATH(GLPK_INCLUDE_DIR |
| 5 | 7 |
glpk.h |
| 6 |
PATHS ${GLPK_REGKEY}/include
|
|
| 8 |
PATHS ${GLPK_REGKEY}/include
|
|
| 9 |
HINTS ${GLPK_ROOT_DIR}/include
|
|
| 10 |
) |
|
| 11 |
FIND_LIBRARY(GLPK_LIBRARY |
|
| 12 |
glpk |
|
| 13 |
PATHS ${GLPK_REGKEY}/lib
|
|
| 14 |
HINTS ${GLPK_ROOT_DIR}/lib
|
|
| 15 |
) |
|
| 7 | 16 |
|
| 8 |
FIND_LIBRARY(GLPK_LIBRARY |
|
| 9 |
NAMES glpk |
|
| 10 |
|
|
| 17 |
IF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY) |
|
| 18 |
FILE(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H)
|
|
| 19 |
|
|
| 20 |
STRING(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
|
|
| 21 |
STRING(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
|
|
| 22 |
|
|
| 23 |
STRING(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
|
|
| 24 |
STRING(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
|
|
| 25 |
|
|
| 26 |
SET(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}")
|
|
| 27 |
|
|
| 28 |
IF(GLPK_FIND_VERSION) |
|
| 29 |
IF(GLPK_FIND_VERSION_COUNT GREATER 2) |
|
| 30 |
MESSAGE(SEND_ERROR "unexpected version string") |
|
| 31 |
ENDIF(GLPK_FIND_VERSION_COUNT GREATER 2) |
|
| 32 |
|
|
| 33 |
MATH(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
|
|
| 34 |
MATH(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
|
|
| 35 |
|
|
| 36 |
IF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION) |
|
| 37 |
SET(GLPK_PROPER_VERSION_FOUND FALSE) |
|
| 38 |
ELSE(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION) |
|
| 39 |
SET(GLPK_PROPER_VERSION_FOUND TRUE) |
|
| 40 |
ENDIF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION) |
|
| 41 |
ELSE(GLPK_FIND_VERSION) |
|
| 42 |
SET(GLPK_PROPER_VERSION_FOUND TRUE) |
|
| 43 |
ENDIF(GLPK_FIND_VERSION) |
|
| 44 |
ENDIF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY) |
|
| 11 | 45 |
|
| 12 | 46 |
INCLUDE(FindPackageHandleStandardArgs) |
| 13 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR) |
|
| 47 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND) |
|
| 14 | 48 |
|
| 15 | 49 |
IF(GLPK_FOUND) |
| 16 | 50 |
SET(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR})
|
| 17 | 51 |
SET(GLPK_LIBRARIES ${GLPK_LIBRARY})
|
| 18 | 52 |
SET(GLPK_BIN_DIR ${GLPK_ROOT_PATH}/bin)
|
| 19 | 53 |
ENDIF(GLPK_FOUND) |
| 20 | 54 |
|
| 21 | 55 |
MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR) |
| 22 | 56 |
|
| 23 | 57 |
IF(GLPK_FOUND) |
| 24 |
SET(HAVE_LP TRUE) |
|
| 25 |
SET(HAVE_MIP TRUE) |
|
| 26 |
SET( |
|
| 58 |
SET(LEMON_HAVE_LP TRUE) |
|
| 59 |
SET(LEMON_HAVE_MIP TRUE) |
|
| 60 |
SET(LEMON_HAVE_GLPK TRUE) |
|
| 27 | 61 |
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 |
| 125 | 125 |
echo |
| 126 | 126 |
echo The packace will be installed in |
| 127 | 127 |
echo -n ' ' |
| 128 | 128 |
echo $prefix. |
| 129 | 129 |
echo |
| 130 | 130 |
echo '*********************************************************************' |
| 131 | 131 |
|
| 132 | 132 |
echo |
| 133 | 133 |
echo Configure complete, now type \'make\' and then \'make install\'. |
| 134 | 134 |
echo |
| 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 |
nodist_lemon_HEADERS = lemon/config.h |
|
| 19 |
|
|
| 19 | 20 |
lemon_libemon_la_CXXFLAGS = \ |
| 20 | 21 |
$(AM_CXXFLAGS) \ |
| 21 | 22 |
$(GLPK_CFLAGS) \ |
| 22 | 23 |
$(CPLEX_CFLAGS) \ |
| 23 | 24 |
$(SOPLEX_CXXFLAGS) \ |
| 24 | 25 |
$(CLP_CXXFLAGS) \ |
| 25 | 26 |
$(CBC_CXXFLAGS) |
| 26 | 27 |
|
| 27 | 28 |
lemon_libemon_la_LDFLAGS = \ |
| 28 | 29 |
$(GLPK_LIBS) \ |
| 29 | 30 |
$(CPLEX_LIBS) \ |
| 30 | 31 |
$(SOPLEX_LIBS) \ |
| 31 | 32 |
$(CLP_LIBS) \ |
| 32 | 33 |
$(CBC_LIBS) |
| 33 | 34 |
|
| 34 | 35 |
if HAVE_GLPK |
| 35 | 36 |
lemon_libemon_la_SOURCES += lemon/glpk.cc |
| 36 | 37 |
endif |
| 37 | 38 |
|
| 38 | 39 |
if HAVE_CPLEX |
| 39 | 40 |
lemon_libemon_la_SOURCES += lemon/cplex.cc |
| 40 | 41 |
endif |
| 41 | 42 |
|
| 42 | 43 |
if HAVE_SOPLEX |
| 43 | 44 |
lemon_libemon_la_SOURCES += lemon/soplex.cc |
| 44 | 45 |
endif |
| 45 | 46 |
|
| 46 | 47 |
if HAVE_CLP |
| 47 | 48 |
lemon_libemon_la_SOURCES += lemon/clp.cc |
| 48 | 49 |
endif |
| 49 | 50 |
|
| 50 | 51 |
if HAVE_CBC |
| 51 | 52 |
lemon_libemon_la_SOURCES += lemon/cbc.cc |
| 52 | 53 |
endif |
| 53 | 54 |
|
| 54 | 55 |
lemon_HEADERS += \ |
| 55 | 56 |
lemon/adaptors.h \ |
| 56 | 57 |
lemon/arg_parser.h \ |
| 57 | 58 |
lemon/assert.h \ |
| 58 | 59 |
lemon/bfs.h \ |
| 59 | 60 |
lemon/bin_heap.h \ |
| 61 |
lemon/cbc.h \ |
|
| 60 | 62 |
lemon/circulation.h \ |
| 61 | 63 |
lemon/clp.h \ |
| 62 | 64 |
lemon/color.h \ |
| 63 | 65 |
lemon/concept_check.h \ |
| 64 | 66 |
lemon/connectivity.h \ |
| 65 | 67 |
lemon/counter.h \ |
| 66 | 68 |
lemon/core.h \ |
| 67 | 69 |
lemon/cplex.h \ |
| 68 | 70 |
lemon/dfs.h \ |
| 69 | 71 |
lemon/dijkstra.h \ |
| 70 | 72 |
lemon/dim2.h \ |
| 71 | 73 |
lemon/dimacs.h \ |
| 72 | 74 |
lemon/edge_set.h \ |
| 73 | 75 |
lemon/elevator.h \ |
| 74 | 76 |
lemon/error.h \ |
| 75 | 77 |
lemon/euler.h \ |
| 76 | 78 |
lemon/full_graph.h \ |
| 77 | 79 |
lemon/glpk.h \ |
| 78 | 80 |
lemon/gomory_hu.h \ |
| 79 | 81 |
lemon/graph_to_eps.h \ |
| 80 | 82 |
lemon/grid_graph.h \ |
| 81 | 83 |
lemon/hypercube_graph.h \ |
| 82 | 84 |
lemon/kruskal.h \ |
| 83 | 85 |
lemon/hao_orlin.h \ |
| 84 | 86 |
lemon/lgf_reader.h \ |
| 85 | 87 |
lemon/lgf_writer.h \ |
| 86 | 88 |
lemon/list_graph.h \ |
| 87 | 89 |
lemon/lp.h \ |
| 88 | 90 |
lemon/lp_base.h \ |
| 89 | 91 |
lemon/lp_skeleton.h \ |
| 90 | 92 |
lemon/list_graph.h \ |
| 91 | 93 |
lemon/maps.h \ |
| 92 | 94 |
lemon/matching.h \ |
| 93 | 95 |
lemon/math.h \ |
| 94 | 96 |
lemon/min_cost_arborescence.h \ |
| 95 | 97 |
lemon/nauty_reader.h \ |
| 96 | 98 |
lemon/network_simplex.h \ |
| 97 | 99 |
lemon/path.h \ |
| 98 | 100 |
lemon/preflow.h \ |
| 99 | 101 |
lemon/radix_sort.h \ |
| 100 | 102 |
lemon/random.h \ |
| 101 | 103 |
lemon/smart_graph.h \ |
| 102 | 104 |
lemon/soplex.h \ |
| 103 | 105 |
lemon/suurballe.h \ |
| 104 | 106 |
lemon/time_measure.h \ |
| 105 | 107 |
lemon/tolerance.h \ |
| 106 | 108 |
lemon/unionfind.h \ |
| 107 | 109 |
lemon/bits/windows.h |
| 108 | 110 |
|
| 109 | 111 |
bits_HEADERS += \ |
| 110 | 112 |
lemon/bits/alteration_notifier.h \ |
| 111 | 113 |
lemon/bits/array_map.h \ |
| 112 | 114 |
lemon/bits/base_extender.h \ |
| 113 | 115 |
lemon/bits/bezier.h \ |
| 114 | 116 |
lemon/bits/default_map.h \ |
| 115 | 117 |
lemon/bits/edge_set_extender.h \ |
| 116 | 118 |
lemon/bits/enable_if.h \ |
| 117 | 119 |
lemon/bits/graph_adaptor_extender.h \ |
| 118 | 120 |
lemon/bits/graph_extender.h \ |
| 119 | 121 |
lemon/bits/map_extender.h \ |
| 120 | 122 |
lemon/bits/path_dump.h \ |
| 121 | 123 |
lemon/bits/solver_bits.h \ |
| 122 | 124 |
lemon/bits/traits.h \ |
| 123 | 125 |
lemon/bits/variant.h \ |
| 124 | 126 |
lemon/bits/vector_map.h |
| 125 | 127 |
|
| 126 | 128 |
concept_HEADERS += \ |
| 127 | 129 |
lemon/concepts/digraph.h \ |
| 128 | 130 |
lemon/concepts/graph.h \ |
| 129 | 131 |
lemon/concepts/graph_components.h \ |
| 130 | 132 |
lemon/concepts/heap.h \ |
| 131 | 133 |
lemon/concepts/maps.h \ |
| 132 | 134 |
lemon/concepts/path.h |
| 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 |
#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-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_CORE_H |
| 20 | 20 |
#define LEMON_CORE_H |
| 21 | 21 |
|
| 22 | 22 |
#include <vector> |
| 23 | 23 |
#include <algorithm> |
| 24 | 24 |
|
| 25 |
#include <lemon/ |
|
| 25 |
#include <lemon/config.h> |
|
| 26 | 26 |
#include <lemon/bits/enable_if.h> |
| 27 | 27 |
#include <lemon/bits/traits.h> |
| 28 | 28 |
#include <lemon/assert.h> |
| 29 | 29 |
|
| 30 | 30 |
///\file |
| 31 | 31 |
///\brief LEMON core utilities. |
| 32 | 32 |
/// |
| 33 | 33 |
///This header file contains core utilities for LEMON. |
| 34 | 34 |
///It is automatically included by all graph types, therefore it usually |
| 35 | 35 |
///do not have to be included directly. |
| 36 | 36 |
|
| 37 | 37 |
namespace lemon {
|
| 38 | 38 |
|
| 39 | 39 |
/// \brief Dummy type to make it easier to create invalid iterators. |
| 40 | 40 |
/// |
| 41 | 41 |
/// Dummy type to make it easier to create invalid iterators. |
| 42 | 42 |
/// See \ref INVALID for the usage. |
| 43 | 43 |
struct Invalid {
|
| 44 | 44 |
public: |
| 45 | 45 |
bool operator==(Invalid) { return true; }
|
| 46 | 46 |
bool operator!=(Invalid) { return false; }
|
| 47 | 47 |
bool operator< (Invalid) { return false; }
|
| 48 | 48 |
}; |
| 49 | 49 |
|
| 50 | 50 |
/// \brief Invalid iterators. |
| 51 | 51 |
/// |
| 52 | 52 |
/// \ref Invalid is a global type that converts to each iterator |
| 53 | 53 |
/// in such a way that the value of the target iterator will be invalid. |
| 54 | 54 |
#ifdef LEMON_ONLY_TEMPLATES |
| 55 | 55 |
const Invalid INVALID = Invalid(); |
| 56 | 56 |
#else |
| 57 | 57 |
extern const Invalid INVALID; |
| 58 | 58 |
#endif |
| 59 | 59 |
|
| 60 | 60 |
/// \addtogroup gutils |
| 61 | 61 |
/// @{
|
| 62 | 62 |
|
| 63 | 63 |
///Create convenience typedefs for the digraph types and iterators |
| 64 | 64 |
|
| 65 | 65 |
///This \c \#define creates convenient type definitions for the following |
| 66 | 66 |
///types of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt, |
| 67 | 67 |
///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, |
| 68 | 68 |
///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap. |
| 69 | 69 |
/// |
| 70 | 70 |
///\note If the graph type is a dependent type, ie. the graph type depend |
| 71 | 71 |
///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS() |
| 72 | 72 |
///macro. |
| 73 | 73 |
#define DIGRAPH_TYPEDEFS(Digraph) \ |
| 74 | 74 |
typedef Digraph::Node Node; \ |
| 75 | 75 |
typedef Digraph::NodeIt NodeIt; \ |
| 76 | 76 |
typedef Digraph::Arc Arc; \ |
| 77 | 77 |
typedef Digraph::ArcIt ArcIt; \ |
| 78 | 78 |
typedef Digraph::InArcIt InArcIt; \ |
| 79 | 79 |
typedef Digraph::OutArcIt OutArcIt; \ |
| 80 | 80 |
typedef Digraph::NodeMap<bool> BoolNodeMap; \ |
| 81 | 81 |
typedef Digraph::NodeMap<int> IntNodeMap; \ |
| 82 | 82 |
typedef Digraph::NodeMap<double> DoubleNodeMap; \ |
| 83 | 83 |
typedef Digraph::ArcMap<bool> BoolArcMap; \ |
| 84 | 84 |
typedef Digraph::ArcMap<int> IntArcMap; \ |
| 85 | 85 |
typedef Digraph::ArcMap<double> DoubleArcMap |
| 86 | 86 |
|
| 87 | 87 |
///Create convenience typedefs for the digraph types and iterators |
| 88 | 88 |
|
| 89 | 89 |
///\see DIGRAPH_TYPEDEFS |
| 90 | 90 |
/// |
| 91 | 91 |
///\note Use this macro, if the graph type is a dependent type, |
| 92 | 92 |
///ie. the graph type depend on a template parameter. |
| 93 | 93 |
#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph) \ |
| 94 | 94 |
typedef typename Digraph::Node Node; \ |
| 95 | 95 |
typedef typename Digraph::NodeIt NodeIt; \ |
| 96 | 96 |
typedef typename Digraph::Arc Arc; \ |
| 97 | 97 |
typedef typename Digraph::ArcIt ArcIt; \ |
| 98 | 98 |
typedef typename Digraph::InArcIt InArcIt; \ |
| 99 | 99 |
typedef typename Digraph::OutArcIt OutArcIt; \ |
| 100 | 100 |
typedef typename Digraph::template NodeMap<bool> BoolNodeMap; \ |
| 101 | 101 |
typedef typename Digraph::template NodeMap<int> IntNodeMap; \ |
| 102 | 102 |
typedef typename Digraph::template NodeMap<double> DoubleNodeMap; \ |
| 103 | 103 |
typedef typename Digraph::template ArcMap<bool> BoolArcMap; \ |
| 104 | 104 |
typedef typename Digraph::template ArcMap<int> IntArcMap; \ |
| 105 | 105 |
typedef typename Digraph::template ArcMap<double> DoubleArcMap |
| 106 | 106 |
|
| 107 | 107 |
///Create convenience typedefs for the graph types and iterators |
| 108 | 108 |
|
| 109 | 109 |
///This \c \#define creates the same convenient type definitions as defined |
| 110 | 110 |
///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates |
| 111 | 111 |
///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap, |
| 112 | 112 |
///\c DoubleEdgeMap. |
| 113 | 113 |
/// |
| 114 | 114 |
///\note If the graph type is a dependent type, ie. the graph type depend |
| 115 | 115 |
///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS() |
| 116 | 116 |
///macro. |
| 117 | 117 |
#define GRAPH_TYPEDEFS(Graph) \ |
| 118 | 118 |
DIGRAPH_TYPEDEFS(Graph); \ |
| 119 | 119 |
typedef Graph::Edge Edge; \ |
| 120 | 120 |
typedef Graph::EdgeIt EdgeIt; \ |
| 121 | 121 |
typedef Graph::IncEdgeIt IncEdgeIt; \ |
| 122 | 122 |
typedef Graph::EdgeMap<bool> BoolEdgeMap; \ |
| 123 | 123 |
typedef Graph::EdgeMap<int> IntEdgeMap; \ |
| 124 | 124 |
typedef Graph::EdgeMap<double> DoubleEdgeMap |
| 125 | 125 |
|
| 126 | 126 |
///Create convenience typedefs for the graph types and iterators |
| 127 | 127 |
|
| 128 | 128 |
///\see GRAPH_TYPEDEFS |
| 129 | 129 |
/// |
| 130 | 130 |
///\note Use this macro, if the graph type is a dependent type, |
| 131 | 131 |
///ie. the graph type depend on a template parameter. |
| 132 | 132 |
#define TEMPLATE_GRAPH_TYPEDEFS(Graph) \ |
| 133 | 133 |
TEMPLATE_DIGRAPH_TYPEDEFS(Graph); \ |
| 134 | 134 |
typedef typename Graph::Edge Edge; \ |
| 135 | 135 |
typedef typename Graph::EdgeIt EdgeIt; \ |
| 136 | 136 |
typedef typename Graph::IncEdgeIt IncEdgeIt; \ |
| 137 | 137 |
typedef typename Graph::template EdgeMap<bool> BoolEdgeMap; \ |
| 138 | 138 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap; \ |
| 139 | 139 |
typedef typename Graph::template EdgeMap<double> DoubleEdgeMap |
| 140 | 140 |
|
| 141 | 141 |
/// \brief Function to count the items in a graph. |
| 142 | 142 |
/// |
| 143 | 143 |
/// This function counts the items (nodes, arcs etc.) in a graph. |
| 144 | 144 |
/// The complexity of the function is linear because |
| 145 | 145 |
/// it iterates on all of the items. |
| 146 | 146 |
template <typename Graph, typename Item> |
| 147 | 147 |
inline int countItems(const Graph& g) {
|
| 148 | 148 |
typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt; |
| 149 | 149 |
int num = 0; |
| 150 | 150 |
for (ItemIt it(g); it != INVALID; ++it) {
|
| 151 | 151 |
++num; |
| 152 | 152 |
} |
| 153 | 153 |
return num; |
| 154 | 154 |
} |
| 155 | 155 |
|
| 156 | 156 |
// Node counting: |
| 157 | 157 |
|
| 158 | 158 |
namespace _core_bits {
|
| 159 | 159 |
|
| 160 | 160 |
template <typename Graph, typename Enable = void> |
| 161 | 161 |
struct CountNodesSelector {
|
| 162 | 162 |
static int count(const Graph &g) {
|
| 163 | 163 |
return countItems<Graph, typename Graph::Node>(g); |
| 164 | 164 |
} |
| 165 | 165 |
}; |
| 166 | 166 |
|
| 167 | 167 |
template <typename Graph> |
| 168 | 168 |
struct CountNodesSelector< |
| 169 | 169 |
Graph, typename |
| 170 | 170 |
enable_if<typename Graph::NodeNumTag, void>::type> |
| 171 | 171 |
{
|
| 172 | 172 |
static int count(const Graph &g) {
|
| 173 | 173 |
return g.nodeNum(); |
| 174 | 174 |
} |
| 175 | 175 |
}; |
| 176 | 176 |
} |
| 177 | 177 |
|
| 178 | 178 |
/// \brief Function to count the nodes in the graph. |
| 179 | 179 |
/// |
| 180 | 180 |
/// This function counts the nodes in the graph. |
| 181 | 181 |
/// The complexity of the function is <em>O</em>(<em>n</em>), but for some |
| 182 | 182 |
/// graph structures it is specialized to run in <em>O</em>(1). |
| 183 | 183 |
/// |
| 184 | 184 |
/// \note If the graph contains a \c nodeNum() member function and a |
| 185 | 185 |
/// \c NodeNumTag tag then this function calls directly the member |
| 186 | 186 |
/// function to query the cardinality of the node set. |
| 187 | 187 |
template <typename Graph> |
| 188 | 188 |
inline int countNodes(const Graph& g) {
|
| 189 | 189 |
return _core_bits::CountNodesSelector<Graph>::count(g); |
| 190 | 190 |
} |
| 191 | 191 |
|
| 192 | 192 |
// Arc counting: |
| 193 | 193 |
|
| 194 | 194 |
namespace _core_bits {
|
| 195 | 195 |
|
| 196 | 196 |
template <typename Graph, typename Enable = void> |
| 197 | 197 |
struct CountArcsSelector {
|
| 198 | 198 |
static int count(const Graph &g) {
|
| 199 | 199 |
return countItems<Graph, typename Graph::Arc>(g); |
| 200 | 200 |
} |
| 201 | 201 |
}; |
| 202 | 202 |
|
| 203 | 203 |
template <typename Graph> |
| 204 | 204 |
struct CountArcsSelector< |
| 205 | 205 |
Graph, |
| 206 | 206 |
typename enable_if<typename Graph::ArcNumTag, void>::type> |
| 207 | 207 |
{
|
| 208 | 208 |
static int count(const Graph &g) {
|
| 209 | 209 |
return g.arcNum(); |
| 210 | 210 |
} |
| 211 | 211 |
}; |
| 212 | 212 |
} |
| 213 | 213 |
|
| 214 | 214 |
/// \brief Function to count the arcs in the graph. |
| 215 | 215 |
/// |
| 216 | 216 |
/// This function counts the arcs in the graph. |
| 217 | 217 |
/// The complexity of the function is <em>O</em>(<em>m</em>), but for some |
| 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 |
#!/bin/bash |
| 2 | 2 |
|
| 3 |
YEAR=`date + |
|
| 3 |
YEAR=`date +%Y` |
|
| 4 | 4 |
HGROOT=`hg root` |
| 5 | 5 |
|
| 6 |
function hg_year() {
|
|
| 7 |
if [ -n "$(hg st $1)" ]; then |
|
| 8 |
echo $YEAR |
|
| 9 |
} |
|
| 10 |
|
|
| 6 | 11 |
# file enumaration modes |
| 7 | 12 |
|
| 8 | 13 |
function all_files() {
|
| 9 | 14 |
hg status -a -m -c | |
| 10 | 15 |
cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | |
| 11 | 16 |
while read file; do echo $HGROOT/$file; done |
| 12 | 17 |
} |
| 13 | 18 |
|
| 14 | 19 |
function modified_files() {
|
| 15 | 20 |
hg status -a -m | |
| 16 | 21 |
cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | |
| 17 | 22 |
while read file; do echo $HGROOT/$file; done |
| 18 | 23 |
} |
| 19 | 24 |
|
| 20 | 25 |
function changed_files() {
|
| 21 | 26 |
{
|
| 22 | 27 |
if [ -n "$HG_PARENT1" ] |
| 23 | 28 |
then |
| 24 | 29 |
hg status --rev $HG_PARENT1:$HG_NODE -a -m |
| 25 | 30 |
fi |
| 26 | 31 |
if [ -n "$HG_PARENT2" ] |
| 27 | 32 |
then |
| 28 | 33 |
hg status --rev $HG_PARENT2:$HG_NODE -a -m |
| 29 | 34 |
fi |
| 30 | 35 |
} | cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | |
| 31 | 36 |
sort | uniq | |
| 32 | 37 |
while read file; do echo $HGROOT/$file; done |
| 33 | 38 |
} |
| 34 | 39 |
|
| 35 | 40 |
function given_files() {
|
| 36 | 41 |
for file in $GIVEN_FILES |
| 37 | 42 |
do |
| 38 | 43 |
echo $file |
| 39 | 44 |
done |
| 40 | 45 |
} |
| 41 | 46 |
|
| 42 | 47 |
# actions |
| 43 | 48 |
|
| 44 | 49 |
function update_action() {
|
| 45 | 50 |
if ! diff -q $1 $2 >/dev/null |
| 46 | 51 |
then |
| 47 | 52 |
echo -n " [$3 updated]" |
| 48 | 53 |
rm $2 |
| 49 | 54 |
mv $1 $2 |
| 50 | 55 |
CHANGED=YES |
| 51 | 56 |
fi |
| 52 | 57 |
} |
| 53 | 58 |
|
| 54 | 59 |
function update_warning() {
|
| 55 | 60 |
echo -n " [$2 warning]" |
| 56 | 61 |
WARNED=YES |
| 57 | 62 |
} |
| 58 | 63 |
|
| 59 | 64 |
function update_init() {
|
| 60 | 65 |
echo Update source files... |
| 61 | 66 |
TOTAL_FILES=0 |
| 62 | 67 |
CHANGED_FILES=0 |
| 63 | 68 |
WARNED_FILES=0 |
| 64 | 69 |
} |
| 65 | 70 |
|
| 66 | 71 |
function update_done() {
|
| 67 | 72 |
echo $CHANGED_FILES out of $TOTAL_FILES files has been changed. |
| 68 | 73 |
echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings. |
| 69 | 74 |
} |
| 70 | 75 |
|
| 71 | 76 |
function update_begin() {
|
| 72 | 77 |
((TOTAL_FILES++)) |
| 73 | 78 |
CHANGED=NO |
| 74 | 79 |
WARNED=NO |
| 75 | 80 |
} |
| 76 | 81 |
|
| 77 | 82 |
function update_end() {
|
| 78 | 83 |
if [ $CHANGED == YES ] |
| 79 | 84 |
then |
| 80 | 85 |
((++CHANGED_FILES)) |
| 81 | 86 |
fi |
| 82 | 87 |
if [ $WARNED == YES ] |
| 83 | 88 |
then |
| 84 | 89 |
((++WARNED_FILES)) |
| 85 | 90 |
fi |
| 86 | 91 |
} |
| 87 | 92 |
|
| 88 | 93 |
function check_action() {
|
| 89 | 94 |
if [ "$3" == 'tabs' ] |
| 90 | 95 |
then |
| 91 | 96 |
if echo $2 | grep -q -v -E 'Makefile\.am$' |
| 92 | 97 |
then |
| 93 | 98 |
PATTERN=$(echo -e '\t') |
| 94 | 99 |
else |
| 95 | 100 |
PATTERN=' ' |
| 96 | 101 |
fi |
| 97 | 102 |
elif [ "$3" == 'trailing spaces' ] |
| 98 | 103 |
then |
| 99 | 104 |
PATTERN='\ +$' |
| 100 | 105 |
else |
| 101 | 106 |
PATTERN='*' |
| 102 | 107 |
fi |
| 103 | 108 |
|
| 104 | 109 |
if ! diff -q $1 $2 >/dev/null |
| 105 | 110 |
then |
| 106 | 111 |
if [ "$PATTERN" == '*' ] |
| 107 | 112 |
then |
| 108 | 113 |
diff $1 $2 | grep '^[0-9]' | sed "s|^\(.*\)c.*$|$2:\1: check failed: $3|g" | |
| 109 | 114 |
sed "s/:\([0-9]*\),\([0-9]*\):\(.*\)$/:\1:\3 (until line \2)/g" |
| 110 | 115 |
else |
| 111 | 116 |
grep -n -E "$PATTERN" $2 | sed "s|^\([0-9]*\):.*$|$2:\1: check failed: $3|g" |
| 112 | 117 |
fi |
| 113 | 118 |
FAILED=YES |
| 114 | 119 |
fi |
| 115 | 120 |
} |
| 116 | 121 |
|
| 117 | 122 |
function check_warning() {
|
| 118 | 123 |
if [ "$2" == 'long lines' ] |
| 119 | 124 |
then |
| 120 | 125 |
grep -n -E '.{81,}' $1 | sed "s|^\([0-9]*\):.*$|$1:\1: warning: $2|g"
|
| 121 | 126 |
else |
| 122 | 127 |
echo "$1: warning: $2" |
| 123 | 128 |
fi |
| 124 | 129 |
WARNED=YES |
| 125 | 130 |
} |
| 126 | 131 |
|
| 127 | 132 |
function check_init() {
|
| 128 | 133 |
echo Check source files... |
| 129 | 134 |
FAILED_FILES=0 |
| 130 | 135 |
WARNED_FILES=0 |
| 131 | 136 |
TOTAL_FILES=0 |
| 132 | 137 |
} |
| 133 | 138 |
|
| 134 | 139 |
function check_done() {
|
| 135 | 140 |
echo $FAILED_FILES out of $TOTAL_FILES files has been failed. |
| 136 | 141 |
echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings. |
| 137 | 142 |
|
| 138 | 143 |
if [ $WARNED_FILES -gt 0 -o $FAILED_FILES -gt 0 ] |
| 139 | 144 |
then |
| 140 | 145 |
if [ "$WARNING" == 'INTERACTIVE' ] |
| 141 | 146 |
then |
| 142 | 147 |
echo -n "Are the files with errors/warnings acceptable? (yes/no) " |
| 143 | 148 |
while read answer |
| 144 | 149 |
do |
| 145 | 150 |
if [ "$answer" == 'yes' ] |
| 146 | 151 |
then |
| 147 | 152 |
return 0 |
| 148 | 153 |
elif [ "$answer" == 'no' ] |
| 149 | 154 |
then |
| 150 | 155 |
return 1 |
| 151 | 156 |
fi |
| 152 | 157 |
echo -n "Are the files with errors/warnings acceptable? (yes/no) " |
| 153 | 158 |
done |
| 154 | 159 |
elif [ "$WARNING" == 'WERROR' ] |
| 155 | 160 |
then |
| 156 | 161 |
return 1 |
| 157 | 162 |
fi |
| 158 | 163 |
fi |
| 159 | 164 |
} |
| 160 | 165 |
|
| 161 | 166 |
function check_begin() {
|
| 162 | 167 |
((TOTAL_FILES++)) |
| 163 | 168 |
FAILED=NO |
| 164 | 169 |
WARNED=NO |
| 165 | 170 |
} |
| 166 | 171 |
|
| 167 | 172 |
function check_end() {
|
| 168 | 173 |
if [ $FAILED == YES ] |
| 169 | 174 |
then |
| 170 | 175 |
((++FAILED_FILES)) |
| 171 | 176 |
fi |
| 172 | 177 |
if [ $WARNED == YES ] |
| 173 | 178 |
then |
| 174 | 179 |
((++WARNED_FILES)) |
| 175 | 180 |
fi |
| 176 | 181 |
} |
| 177 | 182 |
|
| 178 | 183 |
|
| 179 | 184 |
|
| 180 | 185 |
# checks |
| 181 | 186 |
|
| 182 | 187 |
function header_check() {
|
| 183 | 188 |
if echo $1 | grep -q -E 'Makefile\.am$' |
| 184 | 189 |
then |
| 185 | 190 |
return |
| 186 | 191 |
fi |
| 187 | 192 |
|
| 188 | 193 |
TMP_FILE=`mktemp` |
| 189 | 194 |
|
| 190 | 195 |
(echo "/* -*- mode: C++; indent-tabs-mode: nil; -*- |
| 191 | 196 |
* |
| 192 | 197 |
* This file is a part of LEMON, a generic C++ optimization library. |
| 193 | 198 |
* |
| 194 |
* Copyright (C) "$ |
|
| 199 |
* Copyright (C) 2003-"$(hg_year $1)" |
|
| 195 | 200 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
| 196 | 201 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
| 197 | 202 |
* |
| 198 | 203 |
* Permission to use, modify and distribute this software is granted |
| 199 | 204 |
* provided that this copyright notice appears in all copies. For |
| 200 | 205 |
* precise terms see the accompanying LICENSE file. |
| 201 | 206 |
* |
| 202 | 207 |
* This software is provided \"AS IS\" with no warranty of any kind, |
| 203 | 208 |
* express or implied, and with no claim as to its suitability for any |
| 204 | 209 |
* purpose. |
| 205 | 210 |
* |
| 206 | 211 |
*/ |
| 207 | 212 |
" |
| 208 | 213 |
awk 'BEGIN { pm=0; }
|
| 209 | 214 |
pm==3 { print }
|
| 210 | 215 |
/\/\* / && pm==0 { pm=1;}
|
| 211 | 216 |
/[^:blank:]/ && (pm==0 || pm==2) { pm=3; print;}
|
| 212 | 217 |
/\*\// && pm==1 { pm=2;}
|
| 213 | 218 |
' $1 |
| 214 | 219 |
) >$TMP_FILE |
| 215 | 220 |
|
| 216 | 221 |
"$ACTION"_action "$TMP_FILE" "$1" header |
| 217 | 222 |
} |
| 218 | 223 |
|
| 219 | 224 |
function tabs_check() {
|
| 220 | 225 |
if echo $1 | grep -q -v -E 'Makefile\.am$' |
| 221 | 226 |
then |
| 222 | 227 |
OLD_PATTERN=$(echo -e '\t') |
| 223 | 228 |
NEW_PATTERN=' ' |
| 224 | 229 |
else |
| 225 | 230 |
OLD_PATTERN=' ' |
| 226 | 231 |
NEW_PATTERN=$(echo -e '\t') |
| 227 | 232 |
fi |
| 228 | 233 |
TMP_FILE=`mktemp` |
| 229 | 234 |
cat $1 | sed -e "s/$OLD_PATTERN/$NEW_PATTERN/g" >$TMP_FILE |
| 230 | 235 |
|
| 231 | 236 |
"$ACTION"_action "$TMP_FILE" "$1" 'tabs' |
| 232 | 237 |
} |
| 233 | 238 |
|
| 234 | 239 |
function spaces_check() {
|
| 235 | 240 |
TMP_FILE=`mktemp` |
| 236 | 241 |
cat $1 | sed -e 's/ \+$//g' >$TMP_FILE |
| 237 | 242 |
|
| 238 | 243 |
"$ACTION"_action "$TMP_FILE" "$1" 'trailing spaces' |
| 239 | 244 |
} |
| 240 | 245 |
|
| 241 | 246 |
function long_lines_check() {
|
| 242 | 247 |
if cat $1 | grep -q -E '.{81,}'
|
| 243 | 248 |
then |
| 244 | 249 |
"$ACTION"_warning $1 'long lines' |
| 245 | 250 |
fi |
| 246 | 251 |
} |
| 247 | 252 |
|
| 248 | 253 |
# process the file |
| 249 | 254 |
|
| 250 | 255 |
function process_file() {
|
| 251 | 256 |
if [ "$ACTION" == 'update' ] |
| 252 | 257 |
then |
| 253 | 258 |
echo -n " $ACTION $1..." |
| 254 | 259 |
else |
| 255 | 260 |
echo " $ACTION $1..." |
| 256 | 261 |
fi |
| 257 | 262 |
|
| 258 | 263 |
CHECKING="header tabs spaces long_lines" |
| 259 | 264 |
|
| 260 | 265 |
"$ACTION"_begin $1 |
| 261 | 266 |
for check in $CHECKING |
| 262 | 267 |
do |
| 263 | 268 |
"$check"_check $1 |
| 264 | 269 |
done |
| 265 | 270 |
"$ACTION"_end $1 |
| 266 | 271 |
if [ "$ACTION" == 'update' ] |
| 267 | 272 |
then |
| 268 | 273 |
echo |
| 269 | 274 |
fi |
| 270 | 275 |
} |
| 271 | 276 |
|
| 272 | 277 |
function process_all {
|
| 273 | 278 |
"$ACTION"_init |
| 274 | 279 |
while read file |
| 275 | 280 |
do |
| 276 | 281 |
process_file $file |
| 277 | 282 |
done < <($FILES) |
| 278 | 283 |
"$ACTION"_done |
| 279 | 284 |
} |
| 280 | 285 |
|
| 281 | 286 |
while [ $# -gt 0 ] |
| 282 | 287 |
do |
| 283 | 288 |
|
| 284 | 289 |
if [ "$1" == '--help' ] || [ "$1" == '-h' ] |
| 285 | 290 |
then |
| 286 | 291 |
echo -n \ |
| 287 | 292 |
"Usage: |
| 288 | 293 |
$0 [OPTIONS] [files] |
| 289 | 294 |
Options: |
| 290 | 295 |
--dry-run|-n |
| 291 | 296 |
Check the files, but do not modify them. |
| 292 | 297 |
--interactive|-i |
| 293 | 298 |
If --dry-run is specified and the checker emits warnings, |
| 294 | 299 |
then the user is asked if the warnings should be considered |
| 295 | 300 |
errors. |
| 296 | 301 |
--werror|-w |
| 297 | 302 |
Make all warnings into errors. |
| 298 | 303 |
--all|-a |
| 299 | 304 |
Check all source files in the repository. |
| 300 | 305 |
--modified|-m |
| 301 | 306 |
Check only the modified (and new) source files. This option is |
| 302 | 307 |
useful to check the modification before making a commit. |
| 303 | 308 |
--changed|-c |
| 304 | 309 |
Check only the changed source files compared to the parent(s) of |
| 305 | 310 |
the current hg node. This option is useful as hg hook script. |
| 306 | 311 |
To automatically check all your changes before making a commit, |
| 307 | 312 |
add the following section to the appropriate .hg/hgrc file. |
| 308 | 313 |
|
| 309 | 314 |
[hooks] |
| 310 | 315 |
pretxncommit.checksources = scripts/unify-sources.sh -c -n -i |
| 311 | 316 |
|
| 312 | 317 |
--help|-h |
| 313 | 318 |
Print this help message. |
| 314 | 319 |
files |
| 315 | 320 |
The files to check/unify. If no file names are given, the modified |
| 316 | 321 |
source files will be checked/unified (just like using the |
| 317 | 322 |
--modified|-m option). |
| 318 | 323 |
" |
| 319 | 324 |
exit 0 |
| 320 | 325 |
elif [ "$1" == '--dry-run' ] || [ "$1" == '-n' ] |
| 321 | 326 |
then |
| 322 | 327 |
[ -n "$ACTION" ] && echo "Conflicting action options" >&2 && exit 1 |
| 323 | 328 |
ACTION=check |
| 324 | 329 |
elif [ "$1" == "--all" ] || [ "$1" == '-a' ] |
| 325 | 330 |
then |
| 326 | 331 |
[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 |
| 327 | 332 |
FILES=all_files |
| 328 | 333 |
elif [ "$1" == "--changed" ] || [ "$1" == '-c' ] |
| 329 | 334 |
then |
| 330 | 335 |
[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 |
| 331 | 336 |
FILES=changed_files |
| 332 | 337 |
elif [ "$1" == "--modified" ] || [ "$1" == '-m' ] |
| 333 | 338 |
then |
| 334 | 339 |
[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1 |
| 335 | 340 |
FILES=modified_files |
| 336 | 341 |
elif [ "$1" == "--interactive" ] || [ "$1" == "-i" ] |
| 337 | 342 |
then |
| 338 | 343 |
[ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1 |
| 339 | 344 |
WARNING='INTERACTIVE' |
| 340 | 345 |
elif [ "$1" == "--werror" ] || [ "$1" == "-w" ] |
| 341 | 346 |
then |
| 342 | 347 |
[ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1 |
| 343 | 348 |
WARNING='WERROR' |
| 344 | 349 |
elif [ $(echo x$1 | cut -c 2) == '-' ] |
| 345 | 350 |
then |
| 346 | 351 |
echo "Invalid option $1" >&2 && exit 1 |
| 347 | 352 |
else |
| 348 | 353 |
[ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1 |
| 349 | 354 |
GIVEN_FILES=$@ |
| 350 | 355 |
FILES=given_files |
| 351 | 356 |
break |
| 352 | 357 |
fi |
| 353 | 358 |
|
| 354 | 359 |
shift |
| 355 | 360 |
done |
| 356 | 361 |
|
| 357 | 362 |
if [ -z $FILES ] |
| 358 | 363 |
then |
| 359 | 364 |
FILES=modified_files |
| 360 | 365 |
fi |
| 361 | 366 |
|
| 362 | 367 |
if [ -z $ACTION ] |
| 363 | 368 |
then |
| 364 | 369 |
ACTION=update |
| 365 | 370 |
fi |
| 366 | 371 |
|
| 367 | 372 |
process_all |
| 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 |
#ifdef HAVE_CONFIG_H |
|
| 25 | 24 |
#include <lemon/config.h> |
| 26 |
#endif |
|
| 27 | 25 |
|
| 28 |
#ifdef |
|
| 26 |
#ifdef LEMON_HAVE_GLPK |
|
| 29 | 27 |
#include <lemon/glpk.h> |
| 30 | 28 |
#endif |
| 31 | 29 |
|
| 32 |
#ifdef |
|
| 30 |
#ifdef LEMON_HAVE_CPLEX |
|
| 33 | 31 |
#include <lemon/cplex.h> |
| 34 | 32 |
#endif |
| 35 | 33 |
|
| 36 |
#ifdef |
|
| 34 |
#ifdef LEMON_HAVE_SOPLEX |
|
| 37 | 35 |
#include <lemon/soplex.h> |
| 38 | 36 |
#endif |
| 39 | 37 |
|
| 40 |
#ifdef |
|
| 38 |
#ifdef LEMON_HAVE_CLP |
|
| 41 | 39 |
#include <lemon/clp.h> |
| 42 | 40 |
#endif |
| 43 | 41 |
|
| 44 | 42 |
using namespace lemon; |
| 45 | 43 |
|
| 46 | 44 |
void lpTest(LpSolver& lp) |
| 47 | 45 |
{
|
| 48 | 46 |
|
| 49 | 47 |
typedef LpSolver LP; |
| 50 | 48 |
|
| 51 | 49 |
std::vector<LP::Col> x(10); |
| 52 | 50 |
// for(int i=0;i<10;i++) x.push_back(lp.addCol()); |
| 53 | 51 |
lp.addColSet(x); |
| 54 | 52 |
lp.colLowerBound(x,1); |
| 55 | 53 |
lp.colUpperBound(x,1); |
| 56 | 54 |
lp.colBounds(x,1,2); |
| 57 | 55 |
|
| 58 | 56 |
std::vector<LP::Col> y(10); |
| 59 | 57 |
lp.addColSet(y); |
| 60 | 58 |
|
| 61 | 59 |
lp.colLowerBound(y,1); |
| 62 | 60 |
lp.colUpperBound(y,1); |
| 63 | 61 |
lp.colBounds(y,1,2); |
| 64 | 62 |
|
| 65 | 63 |
std::map<int,LP::Col> z; |
| 66 | 64 |
|
| 67 | 65 |
z.insert(std::make_pair(12,INVALID)); |
| 68 | 66 |
z.insert(std::make_pair(2,INVALID)); |
| 69 | 67 |
z.insert(std::make_pair(7,INVALID)); |
| 70 | 68 |
z.insert(std::make_pair(5,INVALID)); |
| 71 | 69 |
|
| 72 | 70 |
lp.addColSet(z); |
| 73 | 71 |
|
| 74 | 72 |
lp.colLowerBound(z,1); |
| 75 | 73 |
lp.colUpperBound(z,1); |
| 76 | 74 |
lp.colBounds(z,1,2); |
| 77 | 75 |
|
| 78 | 76 |
{
|
| 79 | 77 |
LP::Expr e,f,g; |
| 80 | 78 |
LP::Col p1,p2,p3,p4,p5; |
| 81 | 79 |
LP::Constr c; |
| 82 | 80 |
|
| 83 | 81 |
p1=lp.addCol(); |
| 84 | 82 |
p2=lp.addCol(); |
| 85 | 83 |
p3=lp.addCol(); |
| 86 | 84 |
p4=lp.addCol(); |
| 87 | 85 |
p5=lp.addCol(); |
| 88 | 86 |
|
| 89 | 87 |
e[p1]=2; |
| 90 | 88 |
*e=12; |
| 91 | 89 |
e[p1]+=2; |
| 92 | 90 |
*e+=12; |
| 93 | 91 |
e[p1]-=2; |
| 94 | 92 |
*e-=12; |
| 95 | 93 |
|
| 96 | 94 |
e=2; |
| 97 | 95 |
e=2.2; |
| 98 | 96 |
e=p1; |
| 99 | 97 |
e=f; |
| 100 | 98 |
|
| 101 | 99 |
e+=2; |
| 102 | 100 |
e+=2.2; |
| 103 | 101 |
e+=p1; |
| 104 | 102 |
e+=f; |
| 105 | 103 |
|
| 106 | 104 |
e-=2; |
| 107 | 105 |
e-=2.2; |
| 108 | 106 |
e-=p1; |
| 109 | 107 |
e-=f; |
| 110 | 108 |
|
| 111 | 109 |
e*=2; |
| 112 | 110 |
e*=2.2; |
| 113 | 111 |
e/=2; |
| 114 | 112 |
e/=2.2; |
| 115 | 113 |
|
| 116 | 114 |
e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+ |
| 117 | 115 |
(f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+ |
| 118 | 116 |
(f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+ |
| 119 | 117 |
2.2*f+f*2.2+f/2.2+ |
| 120 | 118 |
2*f+f*2+f/2+ |
| 121 | 119 |
2.2*p1+p1*2.2+p1/2.2+ |
| 122 | 120 |
2*p1+p1*2+p1/2 |
| 123 | 121 |
); |
| 124 | 122 |
|
| 125 | 123 |
|
| 126 | 124 |
c = (e <= f ); |
| 127 | 125 |
c = (e <= 2.2); |
| 128 | 126 |
c = (e <= 2 ); |
| 129 | 127 |
c = (e <= p1 ); |
| 130 | 128 |
c = (2.2<= f ); |
| 131 | 129 |
c = (2 <= f ); |
| 132 | 130 |
c = (p1 <= f ); |
| 133 | 131 |
c = (p1 <= p2 ); |
| 134 | 132 |
c = (p1 <= 2.2); |
| 135 | 133 |
c = (p1 <= 2 ); |
| 136 | 134 |
c = (2.2<= p2 ); |
| 137 | 135 |
c = (2 <= p2 ); |
| 138 | 136 |
|
| 139 | 137 |
c = (e >= f ); |
| 140 | 138 |
c = (e >= 2.2); |
| 141 | 139 |
c = (e >= 2 ); |
| 142 | 140 |
c = (e >= p1 ); |
| 143 | 141 |
c = (2.2>= f ); |
| 144 | 142 |
c = (2 >= f ); |
| 145 | 143 |
c = (p1 >= f ); |
| 146 | 144 |
c = (p1 >= p2 ); |
| 147 | 145 |
c = (p1 >= 2.2); |
| 148 | 146 |
c = (p1 >= 2 ); |
| 149 | 147 |
c = (2.2>= p2 ); |
| 150 | 148 |
c = (2 >= p2 ); |
| 151 | 149 |
|
| 152 | 150 |
c = (e == f ); |
| 153 | 151 |
c = (e == 2.2); |
| 154 | 152 |
c = (e == 2 ); |
| 155 | 153 |
c = (e == p1 ); |
| 156 | 154 |
c = (2.2== f ); |
| 157 | 155 |
c = (2 == f ); |
| 158 | 156 |
c = (p1 == f ); |
| 159 | 157 |
//c = (p1 == p2 ); |
| 160 | 158 |
c = (p1 == 2.2); |
| 161 | 159 |
c = (p1 == 2 ); |
| 162 | 160 |
c = (2.2== p2 ); |
| 163 | 161 |
c = (2 == p2 ); |
| 164 | 162 |
|
| 165 | 163 |
c = ((2 <= e) <= 3); |
| 166 | 164 |
c = ((2 <= p1) <= 3); |
| 167 | 165 |
|
| 168 | 166 |
c = ((2 >= e) >= 3); |
| 169 | 167 |
c = ((2 >= p1) >= 3); |
| 170 | 168 |
|
| 171 | 169 |
e[x[3]]=2; |
| 172 | 170 |
e[x[3]]=4; |
| 173 | 171 |
e[x[3]]=1; |
| 174 | 172 |
*e=12; |
| 175 | 173 |
|
| 176 | 174 |
lp.addRow(-LP::INF,e,23); |
| 177 | 175 |
lp.addRow(-LP::INF,3.0*(x[1]+x[2]/2)-x[3],23); |
| 178 | 176 |
lp.addRow(-LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23); |
| 179 | 177 |
|
| 180 | 178 |
lp.addRow(x[1]+x[3]<=x[5]-3); |
| 181 | 179 |
lp.addRow((-7<=x[1]+x[3]-12)<=3); |
| 182 | 180 |
lp.addRow(x[1]<=x[5]); |
| 183 | 181 |
|
| 184 | 182 |
std::ostringstream buf; |
| 185 | 183 |
|
| 186 | 184 |
|
| 187 | 185 |
e=((p1+p2)+(p1-0.99*p2)); |
| 188 | 186 |
//e.prettyPrint(std::cout); |
| 189 | 187 |
//(e<=2).prettyPrint(std::cout); |
| 190 | 188 |
double tolerance=0.001; |
| 191 | 189 |
e.simplify(tolerance); |
| 192 | 190 |
buf << "Coeff. of p2 should be 0.01"; |
| 193 | 191 |
check(e[p2]>0, buf.str()); |
| 194 | 192 |
|
| 195 | 193 |
tolerance=0.02; |
| 196 | 194 |
e.simplify(tolerance); |
| 197 | 195 |
buf << "Coeff. of p2 should be 0"; |
| 198 | 196 |
check(const_cast<const LpSolver::Expr&>(e)[p2]==0, buf.str()); |
| 199 | 197 |
|
| 200 | 198 |
//Test for clone/new |
| 201 | 199 |
LP* lpnew = lp.newSolver(); |
| 202 | 200 |
LP* lpclone = lp.cloneSolver(); |
| 203 | 201 |
delete lpnew; |
| 204 | 202 |
delete lpclone; |
| 205 | 203 |
|
| 206 | 204 |
} |
| 207 | 205 |
|
| 208 | 206 |
{
|
| 209 | 207 |
LP::DualExpr e,f,g; |
| 210 | 208 |
LP::Row p1 = INVALID, p2 = INVALID, p3 = INVALID, |
| 211 | 209 |
p4 = INVALID, p5 = INVALID; |
| 212 | 210 |
|
| 213 | 211 |
e[p1]=2; |
| 214 | 212 |
e[p1]+=2; |
| 215 | 213 |
e[p1]-=2; |
| 216 | 214 |
|
| 217 | 215 |
e=p1; |
| 218 | 216 |
e=f; |
| 219 | 217 |
|
| 220 | 218 |
e+=p1; |
| 221 | 219 |
e+=f; |
| 222 | 220 |
|
| 223 | 221 |
e-=p1; |
| 224 | 222 |
e-=f; |
| 225 | 223 |
|
| 226 | 224 |
e*=2; |
| 227 | 225 |
e*=2.2; |
| 228 | 226 |
e/=2; |
| 229 | 227 |
e/=2.2; |
| 230 | 228 |
|
| 231 | 229 |
e=((p1+p2)+(p1-p2)+ |
| 232 | 230 |
(p1+f)+(f+p1)+(f+g)+ |
| 233 | 231 |
(p1-f)+(f-p1)+(f-g)+ |
| 234 | 232 |
2.2*f+f*2.2+f/2.2+ |
| 235 | 233 |
2*f+f*2+f/2+ |
| 236 | 234 |
2.2*p1+p1*2.2+p1/2.2+ |
| 237 | 235 |
2*p1+p1*2+p1/2 |
| 238 | 236 |
); |
| 239 | 237 |
} |
| 240 | 238 |
|
| 241 | 239 |
} |
| 242 | 240 |
|
| 243 | 241 |
void solveAndCheck(LpSolver& lp, LpSolver::ProblemType stat, |
| 244 | 242 |
double exp_opt) {
|
| 245 | 243 |
using std::string; |
| 246 | 244 |
lp.solve(); |
| 247 | 245 |
|
| 248 | 246 |
std::ostringstream buf; |
| 249 | 247 |
buf << "PrimalType should be: " << int(stat) << int(lp.primalType()); |
| 250 | 248 |
|
| 251 | 249 |
check(lp.primalType()==stat, buf.str()); |
| 252 | 250 |
|
| 253 | 251 |
if (stat == LpSolver::OPTIMAL) {
|
| 254 | 252 |
std::ostringstream sbuf; |
| 255 | 253 |
sbuf << "Wrong optimal value (" << lp.primal() <<") with "
|
| 256 | 254 |
<< lp.solverName() <<"\n the right optimum is " << exp_opt; |
| 257 | 255 |
check(std::abs(lp.primal()-exp_opt) < 1e-3, sbuf.str()); |
| 258 | 256 |
} |
| 259 | 257 |
} |
| 260 | 258 |
|
| 261 | 259 |
void aTest(LpSolver & lp) |
| 262 | 260 |
{
|
| 263 | 261 |
typedef LpSolver LP; |
| 264 | 262 |
|
| 265 | 263 |
//The following example is very simple |
| 266 | 264 |
|
| 267 | 265 |
typedef LpSolver::Row Row; |
| 268 | 266 |
typedef LpSolver::Col Col; |
| 269 | 267 |
|
| 270 | 268 |
|
| 271 | 269 |
Col x1 = lp.addCol(); |
| 272 | 270 |
Col x2 = lp.addCol(); |
| 273 | 271 |
|
| 274 | 272 |
|
| 275 | 273 |
//Constraints |
| 276 | 274 |
Row upright=lp.addRow(x1+2*x2 <=1); |
| 277 | 275 |
lp.addRow(x1+x2 >=-1); |
| 278 | 276 |
lp.addRow(x1-x2 <=1); |
| 279 | 277 |
lp.addRow(x1-x2 >=-1); |
| 280 | 278 |
//Nonnegativity of the variables |
| 281 | 279 |
lp.colLowerBound(x1, 0); |
| 282 | 280 |
lp.colLowerBound(x2, 0); |
| 283 | 281 |
//Objective function |
| 284 | 282 |
lp.obj(x1+x2); |
| 285 | 283 |
|
| 286 | 284 |
lp.sense(lp.MAX); |
| 287 | 285 |
|
| 288 | 286 |
//Testing the problem retrieving routines |
| 289 | 287 |
check(lp.objCoeff(x1)==1,"First term should be 1 in the obj function!"); |
| 290 | 288 |
check(lp.sense() == lp.MAX,"This is a maximization!"); |
| 291 | 289 |
check(lp.coeff(upright,x1)==1,"The coefficient in question is 1!"); |
| 292 | 290 |
check(lp.colLowerBound(x1)==0, |
| 293 | 291 |
"The lower bound for variable x1 should be 0."); |
| 294 | 292 |
check(lp.colUpperBound(x1)==LpSolver::INF, |
| 295 | 293 |
"The upper bound for variable x1 should be infty."); |
| 296 | 294 |
check(lp.rowLowerBound(upright) == -LpSolver::INF, |
| 297 | 295 |
"The lower bound for the first row should be -infty."); |
| 298 | 296 |
check(lp.rowUpperBound(upright)==1, |
| 299 | 297 |
"The upper bound for the first row should be 1."); |
| 300 | 298 |
LpSolver::Expr e = lp.row(upright); |
| 301 | 299 |
check(e[x1] == 1, "The first coefficient should 1."); |
| 302 | 300 |
check(e[x2] == 2, "The second coefficient should 1."); |
| 303 | 301 |
|
| 304 | 302 |
lp.row(upright, x1+x2 <=1); |
| 305 | 303 |
e = lp.row(upright); |
| 306 | 304 |
check(e[x1] == 1, "The first coefficient should 1."); |
| 307 | 305 |
check(e[x2] == 1, "The second coefficient should 1."); |
| 308 | 306 |
|
| 309 | 307 |
LpSolver::DualExpr de = lp.col(x1); |
| 310 | 308 |
check( de[upright] == 1, "The first coefficient should 1."); |
| 311 | 309 |
|
| 312 | 310 |
LpSolver* clp = lp.cloneSolver(); |
| 313 | 311 |
|
| 314 | 312 |
//Testing the problem retrieving routines |
| 315 | 313 |
check(clp->objCoeff(x1)==1,"First term should be 1 in the obj function!"); |
| 316 | 314 |
check(clp->sense() == clp->MAX,"This is a maximization!"); |
| 317 | 315 |
check(clp->coeff(upright,x1)==1,"The coefficient in question is 1!"); |
| 318 | 316 |
// std::cout<<lp.colLowerBound(x1)<<std::endl; |
| 319 | 317 |
check(clp->colLowerBound(x1)==0, |
| 320 | 318 |
"The lower bound for variable x1 should be 0."); |
| 321 | 319 |
check(clp->colUpperBound(x1)==LpSolver::INF, |
| 322 | 320 |
"The upper bound for variable x1 should be infty."); |
| 323 | 321 |
|
| 324 | 322 |
check(lp.rowLowerBound(upright)==-LpSolver::INF, |
| 325 | 323 |
"The lower bound for the first row should be -infty."); |
| 326 | 324 |
check(lp.rowUpperBound(upright)==1, |
| 327 | 325 |
"The upper bound for the first row should be 1."); |
| 328 | 326 |
e = clp->row(upright); |
| 329 | 327 |
check(e[x1] == 1, "The first coefficient should 1."); |
| 330 | 328 |
check(e[x2] == 1, "The second coefficient should 1."); |
| 331 | 329 |
|
| 332 | 330 |
de = clp->col(x1); |
| 333 | 331 |
check(de[upright] == 1, "The first coefficient should 1."); |
| 334 | 332 |
|
| 335 | 333 |
delete clp; |
| 336 | 334 |
|
| 337 | 335 |
//Maximization of x1+x2 |
| 338 | 336 |
//over the triangle with vertices (0,0) (0,1) (1,0) |
| 339 | 337 |
double expected_opt=1; |
| 340 | 338 |
solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt); |
| 341 | 339 |
|
| 342 | 340 |
//Minimization |
| 343 | 341 |
lp.sense(lp.MIN); |
| 344 | 342 |
expected_opt=0; |
| 345 | 343 |
solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt); |
| 346 | 344 |
|
| 347 | 345 |
//Vertex (-1,0) instead of (0,0) |
| 348 | 346 |
lp.colLowerBound(x1, -LpSolver::INF); |
| 349 | 347 |
expected_opt=-1; |
| 350 | 348 |
solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt); |
| 351 | 349 |
|
| 352 | 350 |
//Erase one constraint and return to maximization |
| 353 | 351 |
lp.erase(upright); |
| 354 | 352 |
lp.sense(lp.MAX); |
| 355 | 353 |
expected_opt=LpSolver::INF; |
| 356 | 354 |
solveAndCheck(lp, LpSolver::UNBOUNDED, expected_opt); |
| 357 | 355 |
|
| 358 | 356 |
//Infeasibilty |
| 359 | 357 |
lp.addRow(x1+x2 <=-2); |
| 360 | 358 |
solveAndCheck(lp, LpSolver::INFEASIBLE, expected_opt); |
| 361 | 359 |
|
| 362 | 360 |
} |
| 363 | 361 |
|
| 364 | 362 |
template<class LP> |
| 365 | 363 |
void cloneTest() |
| 366 | 364 |
{
|
| 367 | 365 |
//Test for clone/new |
| 368 | 366 |
|
| 369 | 367 |
LP* lp = new LP(); |
| 370 | 368 |
LP* lpnew = lp->newSolver(); |
| 371 | 369 |
LP* lpclone = lp->cloneSolver(); |
| 372 | 370 |
delete lp; |
| 373 | 371 |
delete lpnew; |
| 374 | 372 |
delete lpclone; |
| 375 | 373 |
} |
| 376 | 374 |
|
| 377 | 375 |
int main() |
| 378 | 376 |
{
|
| 379 | 377 |
LpSkeleton lp_skel; |
| 380 | 378 |
lpTest(lp_skel); |
| 381 | 379 |
|
| 382 |
#ifdef |
|
| 380 |
#ifdef LEMON_HAVE_GLPK |
|
| 383 | 381 |
{
|
| 384 | 382 |
GlpkLp lp_glpk1,lp_glpk2; |
| 385 | 383 |
lpTest(lp_glpk1); |
| 386 | 384 |
aTest(lp_glpk2); |
| 387 | 385 |
cloneTest<GlpkLp>(); |
| 388 | 386 |
} |
| 389 | 387 |
#endif |
| 390 | 388 |
|
| 391 |
#ifdef |
|
| 389 |
#ifdef LEMON_HAVE_CPLEX |
|
| 392 | 390 |
try {
|
| 393 | 391 |
CplexLp lp_cplex1,lp_cplex2; |
| 394 | 392 |
lpTest(lp_cplex1); |
| 395 | 393 |
aTest(lp_cplex2); |
| 396 | 394 |
cloneTest<CplexLp>(); |
| 397 | 395 |
} catch (CplexEnv::LicenseError& error) {
|
| 398 | 396 |
check(false, error.what()); |
| 399 | 397 |
} |
| 400 | 398 |
#endif |
| 401 | 399 |
|
| 402 |
#ifdef |
|
| 400 |
#ifdef LEMON_HAVE_SOPLEX |
|
| 403 | 401 |
{
|
| 404 | 402 |
SoplexLp lp_soplex1,lp_soplex2; |
| 405 | 403 |
lpTest(lp_soplex1); |
| 406 | 404 |
aTest(lp_soplex2); |
| 407 | 405 |
cloneTest<SoplexLp>(); |
| 408 | 406 |
} |
| 409 | 407 |
#endif |
| 410 | 408 |
|
| 411 |
#ifdef |
|
| 409 |
#ifdef LEMON_HAVE_CLP |
|
| 412 | 410 |
{
|
| 413 | 411 |
ClpLp lp_clp1,lp_clp2; |
| 414 | 412 |
lpTest(lp_clp1); |
| 415 | 413 |
aTest(lp_clp2); |
| 416 | 414 |
cloneTest<ClpLp>(); |
| 417 | 415 |
} |
| 418 | 416 |
#endif |
| 419 | 417 |
|
| 420 | 418 |
return 0; |
| 421 | 419 |
} |
| 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 |
#ifdef HAVE_CONFIG_H |
|
| 22 | 21 |
#include <lemon/config.h> |
| 23 |
#endif |
|
| 24 | 22 |
|
| 25 |
#ifdef |
|
| 23 |
#ifdef LEMON_HAVE_CPLEX |
|
| 26 | 24 |
#include <lemon/cplex.h> |
| 27 | 25 |
#endif |
| 28 | 26 |
|
| 29 |
#ifdef |
|
| 27 |
#ifdef LEMON_HAVE_GLPK |
|
| 30 | 28 |
#include <lemon/glpk.h> |
| 31 | 29 |
#endif |
| 32 | 30 |
|
| 33 |
#ifdef |
|
| 31 |
#ifdef LEMON_HAVE_CBC |
|
| 34 | 32 |
#include <lemon/cbc.h> |
| 35 | 33 |
#endif |
| 36 | 34 |
|
| 37 | 35 |
|
| 38 | 36 |
using namespace lemon; |
| 39 | 37 |
|
| 40 | 38 |
void solveAndCheck(MipSolver& mip, MipSolver::ProblemType stat, |
| 41 | 39 |
double exp_opt) {
|
| 42 | 40 |
using std::string; |
| 43 | 41 |
|
| 44 | 42 |
mip.solve(); |
| 45 | 43 |
//int decimal,sign; |
| 46 | 44 |
std::ostringstream buf; |
| 47 | 45 |
buf << "Type should be: " << int(stat)<<" and it is "<<int(mip.type()); |
| 48 | 46 |
|
| 49 | 47 |
|
| 50 | 48 |
// itoa(stat,buf1, 10); |
| 51 | 49 |
check(mip.type()==stat, buf.str()); |
| 52 | 50 |
|
| 53 | 51 |
if (stat == MipSolver::OPTIMAL) {
|
| 54 | 52 |
std::ostringstream sbuf; |
| 55 | 53 |
buf << "Wrong optimal value: the right optimum is " << exp_opt; |
| 56 | 54 |
check(std::abs(mip.solValue()-exp_opt) < 1e-3, sbuf.str()); |
| 57 | 55 |
//+ecvt(exp_opt,2) |
| 58 | 56 |
} |
| 59 | 57 |
} |
| 60 | 58 |
|
| 61 | 59 |
void aTest(MipSolver& mip) |
| 62 | 60 |
{
|
| 63 | 61 |
//The following example is very simple |
| 64 | 62 |
|
| 65 | 63 |
|
| 66 | 64 |
typedef MipSolver::Row Row; |
| 67 | 65 |
typedef MipSolver::Col Col; |
| 68 | 66 |
|
| 69 | 67 |
|
| 70 | 68 |
Col x1 = mip.addCol(); |
| 71 | 69 |
Col x2 = mip.addCol(); |
| 72 | 70 |
|
| 73 | 71 |
|
| 74 | 72 |
//Objective function |
| 75 | 73 |
mip.obj(x1); |
| 76 | 74 |
|
| 77 | 75 |
mip.max(); |
| 78 | 76 |
|
| 79 | 77 |
//Unconstrained optimization |
| 80 | 78 |
mip.solve(); |
| 81 | 79 |
//Check it out! |
| 82 | 80 |
|
| 83 | 81 |
//Constraints |
| 84 | 82 |
mip.addRow(2 * x1 + x2 <= 2); |
| 85 | 83 |
Row y2 = mip.addRow(x1 - 2 * x2 <= 0); |
| 86 | 84 |
|
| 87 | 85 |
//Nonnegativity of the variable x1 |
| 88 | 86 |
mip.colLowerBound(x1, 0); |
| 89 | 87 |
|
| 90 | 88 |
|
| 91 | 89 |
//Maximization of x1 |
| 92 | 90 |
//over the triangle with vertices (0,0),(4/5,2/5),(0,2) |
| 93 | 91 |
double expected_opt=4.0/5.0; |
| 94 | 92 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
| 95 | 93 |
|
| 96 | 94 |
|
| 97 | 95 |
//Restrict x2 to integer |
| 98 | 96 |
mip.colType(x2,MipSolver::INTEGER); |
| 99 | 97 |
expected_opt=1.0/2.0; |
| 100 | 98 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
| 101 | 99 |
|
| 102 | 100 |
|
| 103 | 101 |
//Restrict both to integer |
| 104 | 102 |
mip.colType(x1,MipSolver::INTEGER); |
| 105 | 103 |
expected_opt=0; |
| 106 | 104 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
| 107 | 105 |
|
| 108 | 106 |
//Erase a variable |
| 109 | 107 |
mip.erase(x2); |
| 110 | 108 |
mip.rowUpperBound(y2, 8); |
| 111 | 109 |
expected_opt=1; |
| 112 | 110 |
solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); |
| 113 | 111 |
|
| 114 | 112 |
} |
| 115 | 113 |
|
| 116 | 114 |
|
| 117 | 115 |
template<class MIP> |
| 118 | 116 |
void cloneTest() |
| 119 | 117 |
{
|
| 120 | 118 |
|
| 121 | 119 |
MIP* mip = new MIP(); |
| 122 | 120 |
MIP* mipnew = mip->newSolver(); |
| 123 | 121 |
MIP* mipclone = mip->cloneSolver(); |
| 124 | 122 |
delete mip; |
| 125 | 123 |
delete mipnew; |
| 126 | 124 |
delete mipclone; |
| 127 | 125 |
} |
| 128 | 126 |
|
| 129 | 127 |
int main() |
| 130 | 128 |
{
|
| 131 | 129 |
|
| 132 |
#ifdef |
|
| 130 |
#ifdef LEMON_HAVE_GLPK |
|
| 133 | 131 |
{
|
| 134 | 132 |
GlpkMip mip1; |
| 135 | 133 |
aTest(mip1); |
| 136 | 134 |
cloneTest<GlpkMip>(); |
| 137 | 135 |
} |
| 138 | 136 |
#endif |
| 139 | 137 |
|
| 140 |
#ifdef |
|
| 138 |
#ifdef LEMON_HAVE_CPLEX |
|
| 141 | 139 |
try {
|
| 142 | 140 |
CplexMip mip2; |
| 143 | 141 |
aTest(mip2); |
| 144 | 142 |
cloneTest<CplexMip>(); |
| 145 | 143 |
} catch (CplexEnv::LicenseError& error) {
|
| 146 | 144 |
check(false, error.what()); |
| 147 | 145 |
} |
| 148 | 146 |
#endif |
| 149 | 147 |
|
| 150 |
#ifdef |
|
| 148 |
#ifdef LEMON_HAVE_CBC |
|
| 151 | 149 |
{
|
| 152 | 150 |
CbcMip mip1; |
| 153 | 151 |
aTest(mip1); |
| 154 | 152 |
cloneTest<CbcMip>(); |
| 155 | 153 |
} |
| 156 | 154 |
#endif |
| 157 | 155 |
|
| 158 | 156 |
return 0; |
| 159 | 157 |
|
| 160 | 158 |
} |
| ... | ... |
@@ -11,267 +11,267 @@ |
| 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 |
///\ingroup tools |
| 20 | 20 |
///\file |
| 21 | 21 |
///\brief DIMACS problem solver. |
| 22 | 22 |
/// |
| 23 | 23 |
/// This program solves various problems given in DIMACS format. |
| 24 | 24 |
/// |
| 25 | 25 |
/// See |
| 26 | 26 |
/// \code |
| 27 | 27 |
/// dimacs-solver --help |
| 28 | 28 |
/// \endcode |
| 29 | 29 |
/// for more info on usage. |
| 30 | 30 |
|
| 31 | 31 |
#include <iostream> |
| 32 | 32 |
#include <fstream> |
| 33 | 33 |
#include <cstring> |
| 34 | 34 |
|
| 35 | 35 |
#include <lemon/smart_graph.h> |
| 36 | 36 |
#include <lemon/dimacs.h> |
| 37 | 37 |
#include <lemon/lgf_writer.h> |
| 38 | 38 |
#include <lemon/time_measure.h> |
| 39 | 39 |
|
| 40 | 40 |
#include <lemon/arg_parser.h> |
| 41 | 41 |
#include <lemon/error.h> |
| 42 | 42 |
|
| 43 | 43 |
#include <lemon/dijkstra.h> |
| 44 | 44 |
#include <lemon/preflow.h> |
| 45 | 45 |
#include <lemon/matching.h> |
| 46 | 46 |
#include <lemon/network_simplex.h> |
| 47 | 47 |
|
| 48 | 48 |
using namespace lemon; |
| 49 | 49 |
typedef SmartDigraph Digraph; |
| 50 | 50 |
DIGRAPH_TYPEDEFS(Digraph); |
| 51 | 51 |
typedef SmartGraph Graph; |
| 52 | 52 |
|
| 53 | 53 |
template<class Value> |
| 54 | 54 |
void solve_sp(ArgParser &ap, std::istream &is, std::ostream &, |
| 55 | 55 |
DimacsDescriptor &desc) |
| 56 | 56 |
{
|
| 57 | 57 |
bool report = !ap.given("q");
|
| 58 | 58 |
Digraph g; |
| 59 | 59 |
Node s; |
| 60 | 60 |
Digraph::ArcMap<Value> len(g); |
| 61 | 61 |
Timer t; |
| 62 | 62 |
t.restart(); |
| 63 | 63 |
readDimacsSp(is, g, len, s, desc); |
| 64 | 64 |
if(report) std::cerr << "Read the file: " << t << '\n'; |
| 65 | 65 |
t.restart(); |
| 66 | 66 |
Dijkstra<Digraph, Digraph::ArcMap<Value> > dij(g,len); |
| 67 | 67 |
if(report) std::cerr << "Setup Dijkstra class: " << t << '\n'; |
| 68 | 68 |
t.restart(); |
| 69 | 69 |
dij.run(s); |
| 70 | 70 |
if(report) std::cerr << "Run Dijkstra: " << t << '\n'; |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 | 73 |
template<class Value> |
| 74 | 74 |
void solve_max(ArgParser &ap, std::istream &is, std::ostream &, |
| 75 | 75 |
Value infty, DimacsDescriptor &desc) |
| 76 | 76 |
{
|
| 77 | 77 |
bool report = !ap.given("q");
|
| 78 | 78 |
Digraph g; |
| 79 | 79 |
Node s,t; |
| 80 | 80 |
Digraph::ArcMap<Value> cap(g); |
| 81 | 81 |
Timer ti; |
| 82 | 82 |
ti.restart(); |
| 83 | 83 |
readDimacsMax(is, g, cap, s, t, infty, desc); |
| 84 | 84 |
if(report) std::cerr << "Read the file: " << ti << '\n'; |
| 85 | 85 |
ti.restart(); |
| 86 | 86 |
Preflow<Digraph, Digraph::ArcMap<Value> > pre(g,cap,s,t); |
| 87 | 87 |
if(report) std::cerr << "Setup Preflow class: " << ti << '\n'; |
| 88 | 88 |
ti.restart(); |
| 89 | 89 |
pre.run(); |
| 90 | 90 |
if(report) std::cerr << "Run Preflow: " << ti << '\n'; |
| 91 | 91 |
if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n'; |
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 | 94 |
template<class Value> |
| 95 | 95 |
void solve_min(ArgParser &ap, std::istream &is, std::ostream &, |
| 96 | 96 |
Value infty, DimacsDescriptor &desc) |
| 97 | 97 |
{
|
| 98 | 98 |
bool report = !ap.given("q");
|
| 99 | 99 |
Digraph g; |
| 100 | 100 |
Digraph::ArcMap<Value> lower(g), cap(g), cost(g); |
| 101 | 101 |
Digraph::NodeMap<Value> sup(g); |
| 102 | 102 |
Timer ti; |
| 103 | 103 |
|
| 104 | 104 |
ti.restart(); |
| 105 | 105 |
readDimacsMin(is, g, lower, cap, cost, sup, infty, desc); |
| 106 | 106 |
ti.stop(); |
| 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).upperMap(cap).costMap(cost).supplyMap(sup); |
| 123 | 123 |
if (sum_sup > 0) ns.supplyType(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)