↑ Collapse diff ↑
Ignore white space 6 line context
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
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
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

	
18 18
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
19 19

	
20 20
IF(MSVC)
21 21
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4800 /wd4996")
22 22
# Suppressed warnings:
23 23
# C4250: 'class1' : inherits 'class2::member' via dominance
24 24
# C4355: 'this' : used in base member initializer list
25 25
# C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
26 26
# C4996: 'function': was declared deprecated
27 27
ENDIF(MSVC)
28 28

	
29 29
IF(GLPK_FOUND)
30 30
  SET(HAVE_LP TRUE)
31 31
  SET(HAVE_MIP TRUE)
32 32
  SET(HAVE_GLPK TRUE)
33 33
ENDIF(GLPK_FOUND)
34 34

	
35 35
INCLUDE(CheckTypeSize)
36 36
CHECK_TYPE_SIZE("long long" LONG_LONG)
37 37

	
38 38
ENABLE_TESTING()
39 39

	
40 40
ADD_SUBDIRECTORY(lemon)
41
ADD_SUBDIRECTORY(demo)
42
ADD_SUBDIRECTORY(tools)
43
ADD_SUBDIRECTORY(doc)
44
ADD_SUBDIRECTORY(test)
41
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
42
  ADD_SUBDIRECTORY(demo)
43
  ADD_SUBDIRECTORY(tools)
44
  ADD_SUBDIRECTORY(doc)
45
  ADD_SUBDIRECTORY(test)
46
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
45 47

	
46
IF(WIN32)
47
  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
48
  SET(CPACK_PACKAGE_VENDOR "EGRES")
49
  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
50
    "LEMON - Library of Efficient Models and Optimization in Networks")
51
  SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
48
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
49
  IF(WIN32)
50
    SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
51
    SET(CPACK_PACKAGE_VENDOR "EGRES")
52
    SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
53
      "LEMON - Library of Efficient Models and Optimization in Networks")
54
    SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
52 55

	
53
  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
56
    SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
54 57

	
55
  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
56
    "${PROJECT_NAME} ${PROJECT_VERSION}")
57
  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
58
    "${PROJECT_NAME} ${PROJECT_VERSION}")
58
    SET(CPACK_PACKAGE_INSTALL_DIRECTORY
59
      "${PROJECT_NAME} ${PROJECT_VERSION}")
60
    SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
61
      "${PROJECT_NAME} ${PROJECT_VERSION}")
59 62

	
60
  SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
63
    SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
61 64

	
62
  SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
63
  SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
64
  SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
65
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
65
    SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
66
    SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
67
    SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
68
    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
66 69

	
67
  SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
68
    "C++ header files")
69
  SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
70
    "DLL and import library")
71
  SET(CPACK_COMPONENT_BIN_DESCRIPTION
72
    "Command line utilities")
73
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
74
    "Doxygen generated documentation")
70
    SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
71
      "C++ header files")
72
    SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
73
      "DLL and import library")
74
    SET(CPACK_COMPONENT_BIN_DESCRIPTION
75
      "Command line utilities")
76
    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
77
      "Doxygen generated documentation")
75 78

	
76
  SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
79
    SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
77 80

	
78
  SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
79
  SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
80
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
81
    SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
82
    SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
83
    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
81 84

	
82
  SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
83
    "Components needed to develop software using LEMON")
84
  SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
85
    "Documentation of LEMON")
85
    SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
86
      "Components needed to develop software using LEMON")
87
    SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
88
      "Documentation of LEMON")
86 89

	
87
  SET(CPACK_ALL_INSTALL_TYPES Full Developer)
90
    SET(CPACK_ALL_INSTALL_TYPES Full Developer)
88 91

	
89
  SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
90
  SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
91
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
92
    SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
93
    SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
94
    SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
92 95

	
93
  SET(CPACK_GENERATOR "NSIS")
94
  SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico")
95
  SET(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/cmake/nsis/uninstall.ico")
96
  #SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
97
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
98
  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
99
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
100
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
101
  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
102
  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
103
    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
104
    ")
105
  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
106
    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
107
    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
108
    ")
96
    SET(CPACK_GENERATOR "NSIS")
97
    SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
98
    SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
99
    #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
100
    SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
101
    SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
102
    SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
103
    SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
104
    SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
105
    SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
106
      CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
107
      ")
108
    SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
109
      !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
110
      Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
111
      ")
109 112

	
110
  INCLUDE(CPack)
111
ENDIF(WIN32)
113
    INCLUDE(CPack)
114
  ENDIF(WIN32)
115
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
Ignore white space 6 line context
1
LEMON code without an explicit copyright is covered by the following
1
LEMON code without an explicit copyright notice is covered by the following
2 2
copyright/license.
3 3

	
4 4
Copyright (C) 2003-2009 Egervary Jeno Kombinatorikus Optimalizalasi
5 5
Kutatocsoport (Egervary Combinatorial Optimization Research Group,
6 6
EGRES).
7 7

	
8
===========================================================================
9
Boost Software License, Version 1.0
10
===========================================================================
11

	
8 12
Permission is hereby granted, free of charge, to any person or organization
9 13
obtaining a copy of the software and accompanying documentation covered by
10 14
this license (the "Software") to use, reproduce, display, distribute,
11 15
execute, and transmit the Software, and to prepare derivative works of the
12 16
Software, and to permit third-parties to whom the Software is furnished to
13 17
do so, all subject to the following:
14 18

	
15 19
The copyright notices in the Software and this entire statement, including
16 20
the above license grant, this restriction and the following disclaimer,
17 21
must be included in all copies of the Software, in whole or in part, and
18 22
all derivative works of the Software, unless such copies or derivative
19 23
works are solely in the form of machine-executable object code generated by
20 24
a source language processor.
21 25

	
22 26
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 27
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 28
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
25 29
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
26 30
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
27 31
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 32
DEALINGS IN THE SOFTWARE.
29

	
30
===========================================================================
31
This license is a verbatim copy of the Boost Software License, Version 1.0.
32

	
33

	
Ignore white space 6 line context
1
2009-03-27 LEMON joins to the COIN-OR initiative
2

	
3
        COIN-OR (Computational Infrastructure for Operations Research,
4
        http://www.coin-or.org) project is an initiative to spur the
5
        development of open-source software for the operations research
6
        community.
7

	
1 8
2008-10-13 Version 1.0 released
2 9

	
3 10
	This is the first stable release of LEMON. Compared to the 0.x
4 11
	release series, it features a considerably smaller but more
5 12
	matured set of tools. The API has also completely revised and
6 13
	changed in several places.
7 14

	
8 15
	* The major name changes compared to the 0.x series (see the
9 16
          Migration Guide in the doc for more details)
10 17
          * Graph -> Digraph, UGraph -> Graph
11 18
          * Edge -> Arc, UEdge -> Edge
12 19
	  * source(UEdge)/target(UEdge) -> u(Edge)/v(Edge)
13 20
	* Other improvements
14 21
	  * Better documentation
15 22
	  * Reviewed and cleaned up codebase
16 23
	  * CMake based build system (along with the autotools based one)
17 24
	* Contents of the library (ported from 0.x)
18 25
	  * Algorithms
19 26
       	    * breadth-first search (bfs.h)
20 27
       	    * depth-first search (dfs.h)
21 28
       	    * Dijkstra's algorithm (dijkstra.h)
22 29
       	    * Kruskal's algorithm (kruskal.h)
23 30
    	  * Data structures
24 31
       	    * graph data structures (list_graph.h, smart_graph.h)
Ignore white space 6 line context
1 1
INCLUDE_DIRECTORIES(
2
  ${CMAKE_SOURCE_DIR}
3
  ${CMAKE_BINARY_DIR}
2
  ${PROJECT_SOURCE_DIR}
3
  ${PROJECT_BINARY_DIR}
4 4
)
5 5

	
6
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
6
LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
7 7

	
8 8
SET(DEMOS
9 9
  arg_parser_demo
10 10
  graph_to_eps_demo
11 11
  lgf_demo)
12 12

	
13 13
FOREACH(DEMO_NAME ${DEMOS})
14 14
  ADD_EXECUTABLE(${DEMO_NAME} ${DEMO_NAME}.cc)
15 15
  TARGET_LINK_LIBRARIES(${DEMO_NAME} lemon)
16 16
ENDFOREACH(DEMO_NAME)
Ignore white space 6 line context
1 1
SET(PACKAGE_NAME ${PROJECT_NAME})
2 2
SET(PACKAGE_VERSION ${PROJECT_VERSION})
3
SET(abs_top_srcdir ${CMAKE_SOURCE_DIR})
4
SET(abs_top_builddir ${CMAKE_BINARY_DIR})
3
SET(abs_top_srcdir ${PROJECT_SOURCE_DIR})
4
SET(abs_top_builddir ${PROJECT_BINARY_DIR})
5 5

	
6 6
CONFIGURE_FILE(
7
  ${CMAKE_SOURCE_DIR}/doc/Doxyfile.in
8
  ${CMAKE_BINARY_DIR}/doc/Doxyfile
7
  ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
8
  ${PROJECT_BINARY_DIR}/doc/Doxyfile
9 9
  @ONLY)
10 10

	
11 11
IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
12 12
  FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
13 13
  IF(UNIX)
14 14
    ADD_CUSTOM_TARGET(html
15 15
      COMMAND rm -rf gen-images
16 16
      COMMAND mkdir gen-images
17 17
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
18 18
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
19 19
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
20 20
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
21 21
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
22 22
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
23 23
      COMMAND rm -rf html
24 24
      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
25 25
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
26 26
  ELSEIF(WIN32)
27 27
    ADD_CUSTOM_TARGET(html
28 28
      COMMAND if exist gen-images rmdir /s /q gen-images
29 29
      COMMAND mkdir gen-images
30 30
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
31 31
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
32 32
      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
Ignore white space 6 line context
1 1
INCLUDE_DIRECTORIES(
2
  ${CMAKE_SOURCE_DIR}
3
  ${CMAKE_BINARY_DIR}
2
  ${PROJECT_SOURCE_DIR}
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 21
IF(HAVE_GLPK)
22 22
  SET(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc)
23 23
  INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIR})
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)
Ignore white space 6 line context
1 1
EXTRA_DIST += \
2 2
	lemon/lemon.pc.in \
3 3
	lemon/CMakeLists.txt
4 4

	
5 5
pkgconfig_DATA += lemon/lemon.pc
6 6

	
7 7
lib_LTLIBRARIES += lemon/libemon.la
8 8

	
9 9
lemon_libemon_la_SOURCES = \
10 10
	lemon/arg_parser.cc \
11 11
	lemon/base.cc \
12 12
	lemon/color.cc \
13 13
	lemon/lp_base.cc \
14 14
	lemon/lp_skeleton.cc \
15 15
        lemon/random.cc \
16 16
	lemon/bits/windows.cc
17 17

	
18 18

	
19 19
lemon_libemon_la_CXXFLAGS = \
20
	$(AM_CXXFLAGS) \
20 21
	$(GLPK_CFLAGS) \
21 22
	$(CPLEX_CFLAGS) \
22 23
	$(SOPLEX_CXXFLAGS) \
23 24
	$(CLP_CXXFLAGS)
24 25

	
25 26
lemon_libemon_la_LDFLAGS = \
26 27
	$(GLPK_LIBS) \
27 28
	$(CPLEX_LIBS) \
28 29
	$(SOPLEX_LIBS) \
29 30
	$(CLP_LIBS)
30 31

	
31 32
if HAVE_GLPK
32 33
lemon_libemon_la_SOURCES += lemon/glpk.cc
33 34
endif
34 35

	
35 36
if HAVE_CPLEX
36 37
lemon_libemon_la_SOURCES += lemon/cplex.cc
37 38
endif
38 39

	
39 40
if HAVE_SOPLEX
40 41
lemon_libemon_la_SOURCES += lemon/soplex.cc
41 42
endif
42 43

	
43 44
if HAVE_CLP
Ignore white space 6 line context
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
 * Copyright (C) 2003-2008
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 <iostream>
20 20
#include <vector>
21 21
#include <cstring>
22 22

	
23 23
#include <lemon/cplex.h>
24 24

	
25 25
extern "C" {
26 26
#include <ilcplex/cplex.h>
27 27
}
28 28

	
29 29

	
... ...
@@ -420,55 +420,55 @@
420 420

	
421 421
  CplexBase::Sense CplexBase::_getSense() const {
422 422
    switch (CPXgetobjsen(cplexEnv(), _prob)) {
423 423
    case CPX_MIN:
424 424
      return MIN;
425 425
    case CPX_MAX:
426 426
      return MAX;
427 427
    default:
428 428
      LEMON_ASSERT(false, "Invalid sense");
429 429
      return CplexBase::Sense();
430 430
    }
431 431
  }
432 432

	
433 433
  void CplexBase::_clear() {
434 434
    CPXfreeprob(cplexEnv(),&_prob);
435 435
    int status;
436 436
    _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
437 437
    rows.clear();
438 438
    cols.clear();
439 439
  }
440 440

	
441 441
  // CplexLp members
442 442

	
443 443
  CplexLp::CplexLp()
444
    : LpBase(), CplexBase(), LpSolver() {}
444
    : LpBase(), LpSolver(), CplexBase() {}
445 445

	
446 446
  CplexLp::CplexLp(const CplexEnv& env)
447
    : LpBase(), CplexBase(env), LpSolver() {}
447
    : LpBase(), LpSolver(), CplexBase(env) {}
448 448

	
449 449
  CplexLp::CplexLp(const CplexLp& other)
450
    : LpBase(), CplexBase(other), LpSolver() {}
450
    : LpBase(), LpSolver(), CplexBase(other) {}
451 451

	
452 452
  CplexLp::~CplexLp() {}
453 453

	
454 454
  CplexLp* CplexLp::newSolver() const { return new CplexLp; }
455 455
  CplexLp* CplexLp::cloneSolver() const {return new CplexLp(*this); }
456 456

	
457 457
  const char* CplexLp::_solverName() const { return "CplexLp"; }
458 458

	
459 459
  void CplexLp::_clear_temporals() {
460 460
    _col_status.clear();
461 461
    _row_status.clear();
462 462
    _primal_ray.clear();
463 463
    _dual_ray.clear();
464 464
  }
465 465

	
466 466
  // The routine returns zero unless an error occurred during the
467 467
  // optimization. Examples of errors include exhausting available
468 468
  // memory (CPXERR_NO_MEMORY) or encountering invalid data in the
469 469
  // CPLEX problem object (CPXERR_NO_PROBLEM). Exceeding a
470 470
  // user-specified CPLEX limit, or proving the model infeasible or
471 471
  // unbounded, are not considered errors. Note that a zero return
472 472
  // value does not necessarily mean that a solution exists. Use query
473 473
  // routines CPXsolninfo, CPXgetstat, and CPXsolution to obtain
474 474
  // further information about the status of the optimization.
... ...
@@ -777,70 +777,70 @@
777 777
    case CPX_STAT_UNBOUNDED:
778 778
      return INFEASIBLE;
779 779
    default:
780 780
      return UNDEFINED;
781 781
    }
782 782
#else
783 783
    statusSwitch(cplexEnv(),stat);
784 784
    switch (stat) {
785 785
    case 0:
786 786
      return UNDEFINED; //Undefined
787 787
    case CPX_OPTIMAL://Optimal
788 788
      return OPTIMAL;
789 789
    case CPX_UNBOUNDED:
790 790
      return INFEASIBLE;
791 791
    default:
792 792
      return UNDEFINED; //Everything else comes here
793 793
      //FIXME error
794 794
    }
795 795
#endif
796 796
  }
797 797

	
798 798
  // CplexMip members
799 799

	
800 800
  CplexMip::CplexMip()
801
    : LpBase(), CplexBase(), MipSolver() {
801
    : LpBase(), MipSolver(), CplexBase() {
802 802

	
803 803
#if CPX_VERSION < 800
804 804
    CPXchgprobtype(cplexEnv(),  _prob, CPXPROB_MIP);
805 805
#else
806 806
    CPXchgprobtype(cplexEnv(),  _prob, CPXPROB_MILP);
807 807
#endif
808 808
  }
809 809

	
810 810
  CplexMip::CplexMip(const CplexEnv& env)
811
    : LpBase(), CplexBase(env), MipSolver() {
811
    : LpBase(), MipSolver(), CplexBase(env) {
812 812

	
813 813
#if CPX_VERSION < 800
814 814
    CPXchgprobtype(cplexEnv(),  _prob, CPXPROB_MIP);
815 815
#else
816 816
    CPXchgprobtype(cplexEnv(),  _prob, CPXPROB_MILP);
817 817
#endif
818 818

	
819 819
  }
820 820

	
821 821
  CplexMip::CplexMip(const CplexMip& other)
822
    : LpBase(), CplexBase(other), MipSolver() {}
822
    : LpBase(), MipSolver(), CplexBase(other) {}
823 823

	
824 824
  CplexMip::~CplexMip() {}
825 825

	
826 826
  CplexMip* CplexMip::newSolver() const { return new CplexMip; }
827 827
  CplexMip* CplexMip::cloneSolver() const {return new CplexMip(*this); }
828 828

	
829 829
  const char* CplexMip::_solverName() const { return "CplexMip"; }
830 830

	
831 831
  void CplexMip::_setColType(int i, CplexMip::ColTypes col_type) {
832 832

	
833 833
    // Note If a variable is to be changed to binary, a call to CPXchgbds
834 834
    // should also be made to change the bounds to 0 and 1.
835 835

	
836 836
    switch (col_type){
837 837
    case INTEGER: {
838 838
      const char t = 'I';
839 839
      CPXchgctype (cplexEnv(), _prob, 1, &i, &t);
840 840
    } break;
841 841
    case REAL: {
842 842
      const char t = 'C';
843 843
      CPXchgctype (cplexEnv(), _prob, 1, &i, &t);
844 844
    } break;
845 845
    default:
846 846
      break;
Ignore white space 6 line context
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
 * Copyright (C) 2003-2008
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_CPLEX_H
20 20
#define LEMON_CPLEX_H
21 21

	
22 22
///\file
23 23
///\brief Header of the LEMON-CPLEX lp solver interface.
24 24

	
25 25
#include <lemon/lp_base.h>
26 26

	
27 27
struct cpxenv;
28 28
struct cpxlp;
29 29

	
... ...
@@ -57,49 +57,49 @@
57 57
      /// The short error message
58 58
      virtual const char* what() const throw() {
59 59
        return _message;
60 60
      }
61 61
    };
62 62

	
63 63
    /// Constructor
64 64
    CplexEnv();
65 65
    /// Shallow copy constructor
66 66
    CplexEnv(const CplexEnv&);
67 67
    /// Shallow assignement
68 68
    CplexEnv& operator=(const CplexEnv&);
69 69
    /// Destructor
70 70
    virtual ~CplexEnv();
71 71

	
72 72
  protected:
73 73

	
74 74
    cpxenv* cplexEnv() { return _env; }
75 75
    const cpxenv* cplexEnv() const { return _env; }
76 76
  };
77 77

	
78 78
  /// \brief Base interface for the CPLEX LP and MIP solver
79 79
  ///
80 80
  /// This class implements the common interface of the CPLEX LP and
81
  /// MIP solvers.  
81
  /// MIP solvers.
82 82
  /// \ingroup lp_group
83 83
  class CplexBase : virtual public LpBase {
84 84
  protected:
85 85

	
86 86
    CplexEnv _env;
87 87
    cpxlp* _prob;
88 88

	
89 89
    CplexBase();
90 90
    CplexBase(const CplexEnv&);
91 91
    CplexBase(const CplexBase &);
92 92
    virtual ~CplexBase();
93 93

	
94 94
    virtual int _addCol();
95 95
    virtual int _addRow();
96 96

	
97 97
    virtual void _eraseCol(int i);
98 98
    virtual void _eraseRow(int i);
99 99

	
100 100
    virtual void _eraseColId(int i);
101 101
    virtual void _eraseRowId(int i);
102 102

	
103 103
    virtual void _getColName(int col, std::string& name) const;
104 104
    virtual void _setColName(int col, const std::string& name);
105 105
    virtual int _colByName(const std::string& name) const;
... ...
@@ -214,45 +214,48 @@
214 214

	
215 215
    /// Solve with dual simplex method
216 216
    SolveExitStatus solveDual();
217 217

	
218 218
    /// Solve with barrier method
219 219
    SolveExitStatus solveBarrier();
220 220

	
221 221
  };
222 222

	
223 223
  /// \brief Interface for the CPLEX MIP solver
224 224
  ///
225 225
  /// This class implements an interface for the CPLEX MIP solver.
226 226
  ///\ingroup lp_group
227 227
  class CplexMip : public MipSolver, public CplexBase {
228 228
  public:
229 229
    /// \e
230 230
    CplexMip();
231 231
    /// \e
232 232
    CplexMip(const CplexEnv&);
233 233
    /// \e
234 234
    CplexMip(const CplexMip&);
235 235
    /// \e
236 236
    virtual ~CplexMip();
237 237

	
238
    /// \e
239
    virtual CplexMip* cloneSolver() const;
240
    /// \e
241
    virtual CplexMip* newSolver() const;
242

	
238 243
  protected:
239 244

	
240
    virtual CplexMip* _cloneSolver() const;
241
    virtual CplexMip* _newSolver() const;
242 245

	
243 246
    virtual const char* _solverName() const;
244 247

	
245 248
    virtual ColTypes _getColType(int col) const;
246 249
    virtual void _setColType(int col, ColTypes col_type);
247 250

	
248 251
    virtual SolveExitStatus _solve();
249 252
    virtual ProblemType _getType() const;
250 253
    virtual Value _getSol(int i) const;
251 254
    virtual Value _getSolValue() const;
252 255

	
253 256
  };
254 257

	
255 258
} //END OF NAMESPACE LEMON
256 259

	
257 260
#endif //LEMON_CPLEX_H
258 261

	
Ignore white space 6 line context
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
 * Copyright (C) 2003-2008
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
///\file
20 20
///\brief Implementation of the LEMON GLPK LP and MIP solver interface.
21 21

	
22 22
#include <lemon/glpk.h>
23 23
#include <glpk.h>
24 24

	
25 25
#include <lemon/assert.h>
26 26

	
27 27
namespace lemon {
28 28

	
29 29
  // GlpkBase members
... ...
@@ -510,54 +510,54 @@
510 510
      return MIN;
511 511
    case GLP_MAX:
512 512
      return MAX;
513 513
    default:
514 514
      LEMON_ASSERT(false, "Wrong sense");
515 515
      return GlpkBase::Sense();
516 516
    }
517 517
  }
518 518

	
519 519
  void GlpkBase::_clear() {
520 520
    glp_erase_prob(lp);
521 521
    rows.clear();
522 522
    cols.clear();
523 523
  }
524 524

	
525 525
  void GlpkBase::freeEnv() {
526 526
    glp_free_env();
527 527
  }
528 528

	
529 529
  GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;
530 530

	
531 531
  // GlpkLp members
532 532

	
533 533
  GlpkLp::GlpkLp()
534
    : LpBase(), GlpkBase(), LpSolver() {
534
    : LpBase(), LpSolver(), GlpkBase() {
535 535
    messageLevel(MESSAGE_NO_OUTPUT);
536 536
  }
537 537

	
538 538
  GlpkLp::GlpkLp(const GlpkLp& other)
539
    : LpBase(other), GlpkBase(other), LpSolver(other) {
539
    : LpBase(other), LpSolver(other), GlpkBase(other) {
540 540
    messageLevel(MESSAGE_NO_OUTPUT);
541 541
  }
542 542

	
543 543
  GlpkLp* GlpkLp::newSolver() const { return new GlpkLp; }
544 544
  GlpkLp* GlpkLp::cloneSolver() const { return new GlpkLp(*this); }
545 545

	
546 546
  const char* GlpkLp::_solverName() const { return "GlpkLp"; }
547 547

	
548 548
  void GlpkLp::_clear_temporals() {
549 549
    _primal_ray.clear();
550 550
    _dual_ray.clear();
551 551
  }
552 552

	
553 553
  GlpkLp::SolveExitStatus GlpkLp::_solve() {
554 554
    return solvePrimal();
555 555
  }
556 556

	
557 557
  GlpkLp::SolveExitStatus GlpkLp::solvePrimal() {
558 558
    _clear_temporals();
559 559

	
560 560
    glp_smcp smcp;
561 561
    glp_init_smcp(&smcp);
562 562

	
563 563
    switch (_message_level) {
... ...
@@ -809,54 +809,54 @@
809 809
      if (glp_get_prim_stat(lp) == GLP_NOFEAS) {
810 810
        return UNBOUNDED;
811 811
      } else {
812 812
        return UNDEFINED;
813 813
      }
814 814
    case GLP_NOFEAS:
815 815
      return INFEASIBLE;
816 816
    default:
817 817
      LEMON_ASSERT(false, "Wrong primal type");
818 818
      return  GlpkLp::ProblemType();
819 819
    }
820 820
  }
821 821

	
822 822
  void GlpkLp::presolver(bool b) {
823 823
    lpx_set_int_parm(lp, LPX_K_PRESOL, b ? 1 : 0);
824 824
  }
825 825

	
826 826
  void GlpkLp::messageLevel(MessageLevel m) {
827 827
    _message_level = m;
828 828
  }
829 829

	
830 830
  // GlpkMip members
831 831

	
832 832
  GlpkMip::GlpkMip()
833
    : LpBase(), GlpkBase(), MipSolver() {
833
    : LpBase(), MipSolver(), GlpkBase() {
834 834
    messageLevel(MESSAGE_NO_OUTPUT);
835 835
  }
836 836

	
837 837
  GlpkMip::GlpkMip(const GlpkMip& other)
838
    : LpBase(), GlpkBase(other), MipSolver() {
838
    : LpBase(), MipSolver(), GlpkBase(other) {
839 839
    messageLevel(MESSAGE_NO_OUTPUT);
840 840
  }
841 841

	
842 842
  void GlpkMip::_setColType(int i, GlpkMip::ColTypes col_type) {
843 843
    switch (col_type) {
844 844
    case INTEGER:
845 845
      glp_set_col_kind(lp, i, GLP_IV);
846 846
      break;
847 847
    case REAL:
848 848
      glp_set_col_kind(lp, i, GLP_CV);
849 849
      break;
850 850
    }
851 851
  }
852 852

	
853 853
  GlpkMip::ColTypes GlpkMip::_getColType(int i) const {
854 854
    switch (glp_get_col_kind(lp, i)) {
855 855
    case GLP_IV:
856 856
    case GLP_BV:
857 857
      return INTEGER;
858 858
    default:
859 859
      return REAL;
860 860
    }
861 861

	
862 862
  }
Ignore white space 6 line context
... ...
@@ -67,49 +67,54 @@
67 67
    echo $CHANGED_FILES out of $TOTAL_FILES files has been changed.
68 68
    echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings.
69 69
}
70 70

	
71 71
function update_begin() {
72 72
    ((TOTAL_FILES++))
73 73
    CHANGED=NO
74 74
    WARNED=NO
75 75
}
76 76

	
77 77
function update_end() {
78 78
    if [ $CHANGED == YES ]
79 79
    then
80 80
	((++CHANGED_FILES))
81 81
    fi
82 82
    if [ $WARNED == YES ]
83 83
    then
84 84
	((++WARNED_FILES))
85 85
    fi
86 86
}
87 87

	
88 88
function check_action() {
89 89
    if [ "$3" == 'tabs' ]
90 90
    then
91
        PATTERN=$(echo -e '\t')
91
        if echo $2 | grep -q -v -E 'Makefile\.am$'
92
        then
93
            PATTERN=$(echo -e '\t')
94
        else
95
            PATTERN='        '
96
        fi
92 97
    elif [ "$3" == 'trailing spaces' ]
93 98
    then
94 99
        PATTERN='\ +$'
95 100
    else
96 101
        PATTERN='*'
97 102
    fi
98 103

	
99 104
    if ! diff -q $1 $2 >/dev/null
100 105
    then
101 106
        if [ "$PATTERN" == '*' ]
102 107
        then
103 108
            diff $1 $2 | grep '^[0-9]' | sed "s|^\(.*\)c.*$|$2:\1: check failed: $3|g" |
104 109
              sed "s/:\([0-9]*\),\([0-9]*\):\(.*\)$/:\1:\3 (until line \2)/g"
105 110
        else
106 111
            grep -n -E "$PATTERN" $2 | sed "s|^\([0-9]*\):.*$|$2:\1: check failed: $3|g"
107 112
        fi
108 113
        FAILED=YES
109 114
    fi
110 115
}
111 116

	
112 117
function check_warning() {
113 118
    if [ "$2" == 'long lines' ]
114 119
    then
115 120
        grep -n -E '.{81,}' $1 | sed "s|^\([0-9]*\):.*$|$1:\1: warning: $2|g"
Ignore white space 6 line context
1 1
INCLUDE_DIRECTORIES(
2
  ${CMAKE_SOURCE_DIR}
3
  ${CMAKE_BINARY_DIR}
2
  ${PROJECT_SOURCE_DIR}
3
  ${PROJECT_BINARY_DIR}
4 4
)
5 5

	
6 6
IF(HAVE_GLPK)
7 7
  INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIR})
8 8
ENDIF(HAVE_GLPK)
9 9

	
10
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
10
LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
11 11

	
12 12
SET(TESTS
13 13
  adaptors_test
14 14
  bfs_test
15 15
  circulation_test
16 16
  counter_test
17 17
  dfs_test
18 18
  digraph_test
19 19
  dijkstra_test
20 20
  dim_test
21 21
  edge_set_test
22 22
  error_test
23 23
  euler_test
24 24
  gomory_hu_test
25 25
  graph_copy_test
26 26
  graph_test
27 27
  graph_utils_test
28 28
  hao_orlin_test
29 29
  heap_test
30 30
  kruskal_test
31 31
  maps_test
32 32
  max_matching_test
33 33
  min_cost_arborescence_test
34 34
  path_test
Ignore white space 6 line context
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 <lemon/counter.h>
20 20
#include <vector>
21
#include <sstream>
22

	
23
#include "test/test_tools.h"
21 24

	
22 25
using namespace lemon;
23 26

	
24 27
template <typename T>
25 28
void bubbleSort(std::vector<T>& v) {
26
  Counter op("Bubble Sort - Operations: ");
27
  Counter::NoSubCounter as(op, "Assignments: ");
28
  Counter::NoSubCounter co(op, "Comparisons: ");
29
  for (int i = v.size()-1; i > 0; --i) {
30
    for (int j = 0; j < i; ++j) {
31
      if (v[j] > v[j+1]) {
32
        T tmp = v[j];
33
        v[j] = v[j+1];
34
        v[j+1] = tmp;
35
        as += 3;
29
  std::stringstream s1, s2, s3;
30
  {
31
    Counter op("Bubble Sort - Operations: ", s1);
32
    Counter::SubCounter as(op, "Assignments: ", s2);
33
    Counter::SubCounter co(op, "Comparisons: ", s3);
34
    for (int i = v.size()-1; i > 0; --i) {
35
      for (int j = 0; j < i; ++j) {
36
        if (v[j] > v[j+1]) {
37
          T tmp = v[j];
38
          v[j] = v[j+1];
39
          v[j+1] = tmp;
40
          as += 3;
41
        }
42
        ++co;
36 43
      }
37
      ++co;
38 44
    }
39 45
  }
46
  check(s1.str() == "Bubble Sort - Operations: 102\n", "Wrong counter");
47
  check(s2.str() == "Assignments: 57\n", "Wrong subcounter");
48
  check(s3.str() == "Comparisons: 45\n", "Wrong subcounter");
40 49
}
41 50

	
42 51
template <typename T>
43 52
void insertionSort(std::vector<T>& v) {
44
  Counter op("Insertion Sort - Operations: ");
45
  Counter::NoSubCounter as(op, "Assignments: ");
46
  Counter::NoSubCounter co(op, "Comparisons: ");
47
  for (int i = 1; i < int(v.size()); ++i) {
48
    T value = v[i];
49
    ++as;
50
    int j = i;
51
    while (j > 0 && v[j-1] > value) {
52
      v[j] = v[j-1];
53
      --j;
54
      ++co; ++as;
53
  std::stringstream s1, s2, s3;
54
  {
55
    Counter op("Insertion Sort - Operations: ", s1);
56
    Counter::SubCounter as(op, "Assignments: ", s2);
57
    Counter::SubCounter co(op, "Comparisons: ", s3);
58
    for (int i = 1; i < int(v.size()); ++i) {
59
      T value = v[i];
60
      ++as;
61
      int j = i;
62
      while (j > 0 && v[j-1] > value) {
63
        v[j] = v[j-1];
64
        --j;
65
        ++co; ++as;
66
      }
67
      v[j] = value;
68
      ++as;
55 69
    }
56
    v[j] = value;
57
    ++as;
58 70
  }
71
  check(s1.str() == "Insertion Sort - Operations: 56\n", "Wrong counter");
72
  check(s2.str() == "Assignments: 37\n", "Wrong subcounter");
73
  check(s3.str() == "Comparisons: 19\n", "Wrong subcounter");
59 74
}
60 75

	
61 76
template <typename MyCounter>
62
void counterTest() {
63
  MyCounter c("Main Counter: ");
64
  c++;
65
  typename MyCounter::SubCounter d(c, "SubCounter: ");
66
  d++;
67
  typename MyCounter::SubCounter::NoSubCounter e(d, "SubSubCounter: ");
68
  e++;
69
  d+=3;
70
  c-=4;
71
  e-=2;
72
  c.reset(2);
73
  c.reset();
77
void counterTest(bool output) {
78
  std::stringstream s1, s2, s3;
79
  {
80
    MyCounter c("Main Counter: ", s1);
81
    c++;
82
    typename MyCounter::SubCounter d(c, "SubCounter: ", s2);
83
    d++;
84
    typename MyCounter::SubCounter::NoSubCounter e(d, "SubSubCounter: ", s3);
85
    e++;
86
    d+=3;
87
    c-=4;
88
    e-=2;
89
    c.reset(2);
90
    c.reset();
91
  }
92
  if (output) {
93
    check(s1.str() == "Main Counter: 3\n", "Wrong Counter");
94
    check(s2.str() == "SubCounter: 3\n", "Wrong SubCounter");
95
    check(s3.str() == "", "Wrong NoSubCounter");
96
  } else {
97
    check(s1.str() == "", "Wrong NoCounter");
98
    check(s2.str() == "", "Wrong SubCounter");
99
    check(s3.str() == "", "Wrong NoSubCounter");
100
  }
74 101
}
75 102

	
76 103
void init(std::vector<int>& v) {
77 104
  v[0] = 10; v[1] = 60; v[2] = 20; v[3] = 90; v[4] = 100;
78 105
  v[5] = 80; v[6] = 40; v[7] = 30; v[8] = 50; v[9] = 70;
79 106
}
80 107

	
81 108
int main()
82 109
{
83
  counterTest<Counter>();
84
  counterTest<NoCounter>();
110
  counterTest<Counter>(true);
111
  counterTest<NoCounter>(false);
85 112

	
86 113
  std::vector<int> x(10);
87 114
  init(x); bubbleSort(x);
88 115
  init(x); insertionSort(x);
89 116

	
90 117
  return 0;
91 118
}
Ignore white space 6 line context
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
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include <sstream>
20 20
#include <lemon/lp_skeleton.h>
21 21
#include "test_tools.h"
22 22
#include <lemon/tolerance.h>
23 23

	
24 24
#ifdef HAVE_CONFIG_H
25 25
#include <lemon/config.h>
26 26
#endif
27 27

	
28 28
#ifdef HAVE_GLPK
29 29
#include <lemon/glpk.h>
... ...
@@ -344,83 +344,83 @@
344 344
  expected_opt=0;
345 345
  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);
346 346

	
347 347
  //Vertex (-1,0) instead of (0,0)
348 348
  lp.colLowerBound(x1, -LpSolver::INF);
349 349
  expected_opt=-1;
350 350
  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);
351 351

	
352 352
  //Erase one constraint and return to maximization
353 353
  lp.erase(upright);
354 354
  lp.sense(lp.MAX);
355 355
  expected_opt=LpSolver::INF;
356 356
  solveAndCheck(lp, LpSolver::UNBOUNDED, expected_opt);
357 357

	
358 358
  //Infeasibilty
359 359
  lp.addRow(x1+x2 <=-2);
360 360
  solveAndCheck(lp, LpSolver::INFEASIBLE, expected_opt);
361 361

	
362 362
}
363 363

	
364 364
template<class LP>
365 365
void cloneTest()
366 366
{
367 367
  //Test for clone/new
368
  
368

	
369 369
  LP* lp = new LP();
370 370
  LP* lpnew = lp->newSolver();
371 371
  LP* lpclone = lp->cloneSolver();
372 372
  delete lp;
373 373
  delete lpnew;
374 374
  delete lpclone;
375 375
}
376 376

	
377 377
int main()
378 378
{
379 379
  LpSkeleton lp_skel;
380 380
  lpTest(lp_skel);
381 381

	
382 382
#ifdef HAVE_GLPK
383 383
  {
384 384
    GlpkLp lp_glpk1,lp_glpk2;
385 385
    lpTest(lp_glpk1);
386 386
    aTest(lp_glpk2);
387 387
    cloneTest<GlpkLp>();
388 388
  }
389 389
#endif
390 390

	
391 391
#ifdef HAVE_CPLEX
392 392
  try {
393 393
    CplexLp lp_cplex1,lp_cplex2;
394 394
    lpTest(lp_cplex1);
395 395
    aTest(lp_cplex2);
396
    cloneTest<CplexLp>();
396 397
  } catch (CplexEnv::LicenseError& error) {
397 398
#ifdef LEMON_FORCE_CPLEX_CHECK
398 399
    check(false, error.what());
399 400
#else
400 401
    std::cerr << error.what() << std::endl;
401 402
    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
402 403
#endif
403 404
  }
404
    cloneTest<CplexLp>();
405 405
#endif
406 406

	
407 407
#ifdef HAVE_SOPLEX
408 408
  {
409 409
    SoplexLp lp_soplex1,lp_soplex2;
410 410
    lpTest(lp_soplex1);
411 411
    aTest(lp_soplex2);
412 412
    cloneTest<SoplexLp>();
413 413
  }
414 414
#endif
415 415

	
416 416
#ifdef HAVE_CLP
417 417
  {
418 418
    ClpLp lp_clp1,lp_clp2;
419 419
    lpTest(lp_clp1);
420 420
    aTest(lp_clp2);
421 421
    cloneTest<ClpLp>();
422 422
  }
423 423
#endif
424 424

	
425 425
  return 0;
426 426
}
Ignore white space 6 line context
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
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include "test_tools.h"
20 20

	
21 21

	
22 22
#ifdef HAVE_CONFIG_H
23 23
#include <lemon/config.h>
24 24
#endif
25 25

	
26 26
#ifdef HAVE_CPLEX
27 27
#include <lemon/cplex.h>
28 28
#endif
29 29

	
... ...
@@ -88,62 +88,62 @@
88 88

	
89 89
  //Maximization of x1
90 90
  //over the triangle with vertices (0,0),(4/5,2/5),(0,2)
91 91
  double expected_opt=4.0/5.0;
92 92
  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
93 93

	
94 94
  //Restrict x2 to integer
95 95
  mip.colType(x2,MipSolver::INTEGER);
96 96
  expected_opt=1.0/2.0;
97 97
  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
98 98

	
99 99

	
100 100
  //Restrict both to integer
101 101
  mip.colType(x1,MipSolver::INTEGER);
102 102
  expected_opt=0;
103 103
  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
104 104

	
105 105

	
106 106

	
107 107
}
108 108

	
109 109
template<class MIP>
110 110
void cloneTest()
111 111
{
112
  
112

	
113 113
  MIP* mip = new MIP();
114 114
  MIP* mipnew = mip->newSolver();
115 115
  MIP* mipclone = mip->cloneSolver();
116 116
  delete mip;
117 117
  delete mipnew;
118 118
  delete mipclone;
119 119
}
120 120

	
121 121
int main()
122 122
{
123 123

	
124 124
#ifdef HAVE_GLPK
125 125
  {
126 126
    GlpkMip mip1;
127 127
    aTest(mip1);
128 128
    cloneTest<GlpkMip>();
129 129
  }
130 130
#endif
131 131

	
132 132
#ifdef HAVE_CPLEX
133 133
  try {
134 134
    CplexMip mip2;
135 135
    aTest(mip2);
136
    cloneTest<CplexMip>();
136 137
  } catch (CplexEnv::LicenseError& error) {
137 138
#ifdef LEMON_FORCE_CPLEX_CHECK
138 139
    check(false, error.what());
139 140
#else
140 141
    std::cerr << error.what() << std::endl;
141 142
    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
142 143
#endif
143 144
  }
144
  cloneTest<CplexMip>();
145 145
#endif
146 146

	
147 147
  return 0;
148 148

	
149 149
}
Ignore white space 6 line context
... ...
@@ -18,41 +18,39 @@
18 18

	
19 19
#include <lemon/time_measure.h>
20 20

	
21 21
using namespace lemon;
22 22

	
23 23
void f()
24 24
{
25 25
  double d=0;
26 26
  for(int i=0;i<1000;i++)
27 27
    d+=0.1;
28 28
}
29 29

	
30 30
void g()
31 31
{
32 32
  static Timer T;
33 33

	
34 34
  for(int i=0;i<1000;i++)
35 35
    TimeStamp x(T);
36 36
}
37 37

	
38 38
int main()
39 39
{
40 40
  Timer T;
41 41
  unsigned int n;
42
  for(n=0;T.realTime()<1.0;n++) ;
42
  for(n=0;T.realTime()<0.1;n++) ;
43 43
  std::cout << T << " (" << n << " time queries)\n";
44
  T.restart();
45
  while(T.realTime()<2.0) ;
46
  std::cout << T << '\n';
44

	
47 45
  TimeStamp full;
48 46
  TimeStamp t;
49
  t=runningTimeTest(f,1,&n,&full);
47
  t=runningTimeTest(f,0.1,&n,&full);
50 48
  std::cout << t << " (" << n << " tests)\n";
51 49
  std::cout << "Total: " << full << "\n";
52 50

	
53
  t=runningTimeTest(g,1,&n,&full);
51
  t=runningTimeTest(g,0.1,&n,&full);
54 52
  std::cout << t << " (" << n << " tests)\n";
55 53
  std::cout << "Total: " << full << "\n";
56 54

	
57 55
  return 0;
58 56
}
Ignore white space 6 line context
1 1
INCLUDE_DIRECTORIES(
2
  ${CMAKE_SOURCE_DIR}
3
  ${CMAKE_BINARY_DIR}
2
  ${PROJECT_SOURCE_DIR}
3
  ${PROJECT_BINARY_DIR}
4 4
)
5 5

	
6
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
6
LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lemon)
7 7

	
8 8
ADD_EXECUTABLE(lgf-gen lgf-gen.cc)
9 9
TARGET_LINK_LIBRARIES(lgf-gen lemon)
10 10

	
11 11
ADD_EXECUTABLE(dimacs-to-lgf dimacs-to-lgf.cc)
12 12
TARGET_LINK_LIBRARIES(dimacs-to-lgf lemon)
13 13

	
14 14
ADD_EXECUTABLE(dimacs-solver dimacs-solver.cc)
15 15
TARGET_LINK_LIBRARIES(dimacs-solver lemon)
16 16

	
17 17
INSTALL(
18 18
  TARGETS lgf-gen dimacs-to-lgf dimacs-solver
19 19
  RUNTIME DESTINATION bin
20 20
  COMPONENT bin
21 21
)
22 22

	
23 23
IF(NOT WIN32)
24 24
  INSTALL(
25
    FILES ${CMAKE_CURRENT_SOURCE_DIR}/lemon-0.x-to-1.x.sh
26
    RUNTIME DESTINATION bin
25
    PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/lemon-0.x-to-1.x.sh
26
    DESTINATION bin
27 27
    COMPONENT bin)
28 28
ENDIF(NOT WIN32)
Ignore white space 48 line context
1 1
#!/bin/bash
2 2

	
3 3
set -e
4 4

	
5 5
if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then
6 6
    echo "Usage:"
7 7
    echo "  $0 source-file(s)"
8 8
    exit
9 9
fi
10 10

	
11 11
for i in $@
12 12
do
13 13
    echo Update $i...
14 14
    TMP=`mktemp`
15 15
    sed -e "s/\<undirected graph\>/_gr_aph_label_/g"\
16 16
        -e "s/\<undirected graphs\>/_gr_aph_label_s/g"\
17 17
        -e "s/\<undirected edge\>/_ed_ge_label_/g"\
18 18
        -e "s/\<undirected edges\>/_ed_ge_label_s/g"\
19 19
        -e "s/\<directed graph\>/_digr_aph_label_/g"\
20 20
        -e "s/\<directed graphs\>/_digr_aph_label_s/g"\
21 21
        -e "s/\<directed edge\>/_ar_c_label_/g"\
22 22
        -e "s/\<directed edges\>/_ar_c_label_s/g"\
23 23
        -e "s/UGraph/_Gr_aph_label_/g"\
24 24
        -e "s/u[Gg]raph/_gr_aph_label_/g"\
25
        -e "s/\<Graph\>/_Digr_aph_label_/g"\
25
        -e "s/Graph\>/_Digr_aph_label_/g"\
26 26
        -e "s/\<graph\>/_digr_aph_label_/g"\
27
        -e "s/\<Graphs\>/_Digr_aph_label_s/g"\
27
        -e "s/Graphs\>/_Digr_aph_label_s/g"\
28 28
        -e "s/\<graphs\>/_digr_aph_label_s/g"\
29
        -e "s/_Graph/__Gr_aph_label_/g"\
30
        -e "s/\([Gg]\)raph\([a-z_]\)/_\1r_aph_label_\2/g"\
29
        -e "s/\([Gg]\)raph\([a-z]\)/_\1r_aph_label_\2/g"\
31 30
        -e "s/\([a-z_]\)graph/\1_gr_aph_label_/g"\
32 31
        -e "s/Graph/_Digr_aph_label_/g"\
33 32
        -e "s/graph/_digr_aph_label_/g"\
34 33
        -e "s/UEdge/_Ed_ge_label_/g"\
35 34
        -e "s/u[Ee]dge/_ed_ge_label_/g"\
36 35
        -e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\
37
        -e "s/\<Edge\>/_Ar_c_label_/g"\
36
        -e "s/Edge\>/_Ar_c_label_/g"\
38 37
        -e "s/\<edge\>/_ar_c_label_/g"\
39
        -e "s/\<Edges\>/_Ar_c_label_s/g"\
38
        -e "s/_edge\>/_ar_c_label_/g"\
39
        -e "s/Edges\>/_Ar_c_label_s/g"\
40 40
        -e "s/\<edges\>/_ar_c_label_s/g"\
41
        -e "s/_Edge/__Ed_ge_label_/g"\
42
        -e "s/Edge\([a-z_]\)/_Ed_ge_label_\1/g"\
43
        -e "s/edge\([a-z_]\)/_ed_ge_label_\1/g"\
44
        -e "s/\([a-z_]\)edge/\1_ed_ge_label_/g"\
41
        -e "s/_edges\>/_ar_c_label_s/g"\
42
        -e "s/\([Ee]\)dge\([a-z]\)/_\1d_ge_label_\2/g"\
43
        -e "s/\([a-z]\)edge/\1_ed_ge_label_/g"\
45 44
        -e "s/Edge/_Ar_c_label_/g"\
46 45
        -e "s/edge/_ar_c_label_/g"\
47 46
        -e "s/A[Nn]ode/_Re_d_label_/g"\
48 47
        -e "s/B[Nn]ode/_Blu_e_label_/g"\
49 48
        -e "s/A-[Nn]ode/_Re_d_label_/g"\
50 49
        -e "s/B-[Nn]ode/_Blu_e_label_/g"\
51 50
        -e "s/a[Nn]ode/_re_d_label_/g"\
52 51
        -e "s/b[Nn]ode/_blu_e_label_/g"\
53 52
        -e "s/\<UGRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__GR_APH_TY_PEDE_FS_label_\1/g"\
54 53
        -e "s/\<GRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__DIGR_APH_TY_PEDE_FS_label_\1/g"\
55 54
        -e "s/\<UGRAPH_TYPEDEFS\>/_GR_APH_TY_PEDE_FS_label_/g"\
56 55
        -e "s/\<GRAPH_TYPEDEFS\>/_DIGR_APH_TY_PEDE_FS_label_/g"\
57 56
        -e "s/_Digr_aph_label_/Digraph/g"\
58 57
        -e "s/_digr_aph_label_/digraph/g"\
59 58
        -e "s/_Gr_aph_label_/Graph/g"\
60 59
        -e "s/_gr_aph_label_/graph/g"\
61 60
        -e "s/_Ar_c_label_/Arc/g"\
62 61
        -e "s/_ar_c_label_/arc/g"\
63 62
        -e "s/_Ed_ge_label_/Edge/g"\
64 63
        -e "s/_ed_ge_label_/edge/g"\
65 64
        -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\
66 65
        -e "s/_Re_d_label_/Red/g"\
67 66
        -e "s/_Blu_e_label_/Blue/g"\
68 67
        -e "s/_re_d_label_/red/g"\
... ...
@@ -95,27 +94,32 @@
95 94
        -e "s/\<RevDigraphAdaptor\>/ReverseDigraph/g"\
96 95
        -e "s/\<revDigraphAdaptor\>/reverseDigraph/g"\
97 96
        -e "s/\<SubDigraphAdaptor\>/SubDigraph/g"\
98 97
        -e "s/\<subDigraphAdaptor\>/subDigraph/g"\
99 98
        -e "s/\<SubGraphAdaptor\>/SubGraph/g"\
100 99
        -e "s/\<subGraphAdaptor\>/subGraph/g"\
101 100
        -e "s/\<NodeSubDigraphAdaptor\>/FilterNodes/g"\
102 101
        -e "s/\<nodeSubDigraphAdaptor\>/filterNodes/g"\
103 102
        -e "s/\<ArcSubDigraphAdaptor\>/FilterArcs/g"\
104 103
        -e "s/\<arcSubDigraphAdaptor\>/filterArcs/g"\
105 104
        -e "s/\<UndirDigraphAdaptor\>/Undirector/g"\
106 105
        -e "s/\<undirDigraphAdaptor\>/undirector/g"\
107 106
        -e "s/\<ResDigraphAdaptor\>/ResidualDigraph/g"\
108 107
        -e "s/\<resDigraphAdaptor\>/residualDigraph/g"\
109 108
        -e "s/\<SplitDigraphAdaptor\>/SplitNodes/g"\
110 109
        -e "s/\<splitDigraphAdaptor\>/splitNodes/g"\
111 110
        -e "s/\<SubGraphAdaptor\>/SubGraph/g"\
112 111
        -e "s/\<subGraphAdaptor\>/subGraph/g"\
113 112
        -e "s/\<NodeSubGraphAdaptor\>/FilterNodes/g"\
114 113
        -e "s/\<nodeSubGraphAdaptor\>/filterNodes/g"\
115 114
        -e "s/\<ArcSubGraphAdaptor\>/FilterEdges/g"\
116 115
        -e "s/\<arcSubGraphAdaptor\>/filterEdges/g"\
117 116
        -e "s/\<DirGraphAdaptor\>/Orienter/g"\
118 117
        -e "s/\<dirGraphAdaptor\>/orienter/g"\
118
        -e "s/\<LpCplex\>/CplexLp/g"\
119
        -e "s/\<MipCplex\>/CplexMip/g"\
120
        -e "s/\<LpGlpk\>/GlpkLp/g"\
121
        -e "s/\<MipGlpk\>/GlpkMip/g"\
122
        -e "s/\<LpSoplex\>/SoplexLp/g"\
119 123
    <$i > $TMP
120 124
    mv $TMP $i
121 125
done
0 comments (0 inline)