0
3
0
| 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 |
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
|
| 32 |
|
|
| 33 | 29 |
INCLUDE(CheckTypeSize) |
| 34 | 30 |
CHECK_TYPE_SIZE("long long" LEMON_LONG_LONG)
|
| 35 | 31 |
|
| 36 | 32 |
ENABLE_TESTING() |
| 37 | 33 |
|
| 38 | 34 |
ADD_SUBDIRECTORY(lemon) |
| 39 | 35 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
|
| 40 | 36 |
ADD_SUBDIRECTORY(demo) |
| 41 | 37 |
ADD_SUBDIRECTORY(tools) |
| 42 | 38 |
ADD_SUBDIRECTORY(doc) |
| 43 | 39 |
ADD_SUBDIRECTORY(test) |
| 44 | 40 |
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
|
| 45 | 41 |
|
| 46 | 42 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
|
| 47 | 43 |
IF(WIN32) |
| 48 | 44 |
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
| 49 | 45 |
SET(CPACK_PACKAGE_VENDOR "EGRES") |
| 50 | 46 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
| 51 | 47 |
"LEMON - Library of Efficient Models and Optimization in Networks") |
| 52 | 48 |
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
| 53 | 49 |
|
| 54 | 50 |
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
| 55 | 51 |
|
| 56 | 52 |
SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
| 57 | 53 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
| 58 | 54 |
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
| 59 | 55 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
| 60 | 56 |
|
| 61 | 57 |
SET(CPACK_COMPONENTS_ALL headers library html_documentation bin) |
| 62 | 58 |
|
| 63 | 59 |
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") |
| 64 | 60 |
SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") |
| 65 | 61 |
SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities") |
| 66 | 62 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") |
| 67 | 63 |
|
| 68 | 64 |
SET(CPACK_COMPONENT_HEADERS_DESCRIPTION |
| 69 | 65 |
"C++ header files") |
| 70 | 66 |
SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION |
| 71 | 67 |
"DLL and import library") |
| 72 | 68 |
SET(CPACK_COMPONENT_BIN_DESCRIPTION |
| 73 | 69 |
"Command line utilities") |
| 74 | 70 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION |
| 75 | 71 |
"Doxygen generated documentation") |
| 76 | 72 |
|
| 77 | 73 |
SET(CPACK_COMPONENT_HEADERS_DEPENDS library) |
| 78 | 74 |
|
| 79 | 75 |
SET(CPACK_COMPONENT_HEADERS_GROUP "Development") |
| 80 | 76 |
SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") |
| 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 | 26 |
#ifdef LEMON_HAVE_GLPK |
| 29 | 27 |
#include <lemon/glpk.h> |
| 30 | 28 |
#endif |
| 31 | 29 |
|
| 32 | 30 |
#ifdef LEMON_HAVE_CPLEX |
| 33 | 31 |
#include <lemon/cplex.h> |
| 34 | 32 |
#endif |
| 35 | 33 |
|
| 36 | 34 |
#ifdef LEMON_HAVE_SOPLEX |
| 37 | 35 |
#include <lemon/soplex.h> |
| 38 | 36 |
#endif |
| 39 | 37 |
|
| 40 | 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); |
| 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 | 23 |
#ifdef LEMON_HAVE_CPLEX |
| 26 | 24 |
#include <lemon/cplex.h> |
| 27 | 25 |
#endif |
| 28 | 26 |
|
| 29 | 27 |
#ifdef LEMON_HAVE_GLPK |
| 30 | 28 |
#include <lemon/glpk.h> |
| 31 | 29 |
#endif |
| 32 | 30 |
|
| 33 | 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(); |
0 comments (0 inline)