COIN-OR::LEMON - Graph Library

Ignore:
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    r1264 r1344  
    1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
     1CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
     2
     3IF(POLICY CMP0048)
     4  CMAKE_POLICY(SET CMP0048 OLD)
     5ENDIF(POLICY CMP0048)
     6
     7IF(POLICY CMP0026)
     8  #This is for copying the dll's needed by glpk (in lp_test and mip_test)
     9  CMAKE_POLICY(SET CMP0026 OLD)
     10ENDIF(POLICY CMP0026)
    211
    312SET(PROJECT_NAME "LEMON")
     
    6271FIND_PACKAGE(Doxygen)
    6372FIND_PACKAGE(Ghostscript)
     73
     74IF(WIN32)
     75  SET(LEMON_WIN32 TRUE)
     76ENDIF(WIN32)
    6477
    6578SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
     
    122135  SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
    123136    "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
     137ELSE()
     138  SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
     139    "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
    124140ENDIF()
    125141IF(NOT LEMON_DEFAULT_MIP OR
     
    129145  SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
    130146    "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
     147ELSE()
     148  SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
     149    "Default MIP solver backend (GLPK, CPLEX or CBC)")
    131150ENDIF()
    132151
     
    141160  ELSEIF(MSVC)
    142161    # This part is unnecessary 'casue the same is set by the lemon/core.h.
    143     # Still keep it as an example.
    144     SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
     162    # Still kept as an example.
     163
     164    # SET(CXX_WARNING "/wd4250 /wd4267 /wd4355 /wd4503 /wd4800 /wd4996")
     165
    145166    # Suppressed warnings:
    146167    # C4250: 'class1' : inherits 'class2::member' via dominance
     168    # C4267: conversion from 'size_t' to 'type', possible loss of data
    147169    # C4355: 'this' : used in base member initializer list
    148170    # C4503: 'function' : decorated name length exceeded, name was truncated
     
    159181
    160182IF(MSVC)
     183  SET(CMAKE_CXX_FLAGS "/bigobj ${CMAKE_CXX_FLAGS}")
    161184  SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
    162185    "Flags used by the C++ compiler during maintainer builds."
     
    181204    )
    182205  SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    183     "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
     206    "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
    184207    "Flags used for linking binaries during maintainer builds."
    185208    )
    186209  SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
    187     "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
     210    "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
    188211    "Flags used by the shared libraries linker during maintainer builds."
    189212    )
  • NEWS

    r962 r1281  
     12013-08-10 Version 1.3 released
     2
     3        This is major feature release
     4
     5        * New data structures
     6
     7          #69 : Bipartite graph concepts and implementations
     8
     9        * New algorithms
     10
     11          #177: Port Edmonds-Karp algorithm
     12          #380, #405: Heuristic algorithm for the max clique problem
     13          #386: Heuristic algorithms for symmetric TSP
     14          ----: Nagamochi-Ibaraki algorithm [5087694945e4]
     15          #397, #56: Max. cardinality search
     16
     17        * Other new features
     18
     19          #223: Thread safe graph and graph map implementations
     20          #442: Different TimeStamp print formats
     21          #457: File export functionality to LpBase
     22          #362: Bidirectional iterator support for radixSort()
     23
     24        * Implementation improvements
     25
     26          ----: Network Simplex
     27                #391: Better update process, pivot rule and arc mixing
     28                #435: Improved Altering List pivot rule
     29          #417: Various fine tunings in CostScaling
     30          #438: Optional iteration limit in HowardMmc
     31          #436: Ensure strongly polynomial running time for CycleCanceling
     32                while keeping the same performance
     33          ----: Make the CBC interface be compatible with latest CBC releases
     34                [ee581a0ecfbf]
     35
     36        * CMAKE has become the default build environment (#434)
     37
     38          ----: Autotool support has been dropped
     39          ----: Improved LP/MIP configuration
     40                #465: Enable/disable options for LP/MIP backends
     41                #446: Better CPLEX discovery
     42                #460: Add cmake config to find SoPlex
     43          ----: Allow CPACK configuration on all platforms
     44          #390: Add 'Maintainer' CMAKE build type
     45          #388: Add 'check' target.
     46          #401: Add contrib dir
     47          #389: Better version string setting in CMAKE
     48          #433: Support shared library build   
     49          #416: Support testing with valgrind
     50 
     51        * Doc improvements
     52
     53          #395: SOURCE_BROWSER Doxygen switch is configurable from CMAKE
     54                update-external-tags CMAKE target
     55          #455: Optionally use MathJax for rendering the math formulae
     56          #402, #437, #459, #456, #463: Various doc improvements
     57
     58        * Bugfixes (compared to release 1.2):
     59
     60          #432: Add missing doc/template.h and doc/references.bib to release
     61                tarball
     62          ----: Intel C++ compatibility fixes
     63          #441: Fix buggy reinitialization in _solver_bits::VarIndex::clear()
     64          #444: Bugfix in path copy constructors and assignment operators
     65          #447: Bugfix in AllArcLookUp<>
     66          #448: Bugfix in adaptor_test.cc
     67          #449: Fix clang compilation warnings and errors
     68          #440: Fix a bug + remove redundant typedefs in dimacs-solver
     69          #453: Avoid GCC 4.7 compiler warnings
     70          #445: Fix missing initialization in CplexEnv::CplexEnv()
     71          #428: Add missing lemon/lemon.pc.cmake to the release tarball
     72          #393: Create and install lemon.pc
     73          #429: Fix VS warnings
     74          #430: Fix LpBase::Constr two-side limit bug
     75          #392: Bug fix in Dfs::start(s,t)
     76          #414: Fix wrong initialization in Preflow
     77          #418: Better Win CodeBlock/MinGW support
     78          #419: Build environment improvements
     79                - Build of mip_test and lp_test precede the running of the tests
     80                - Also search for coin libs under ${COIN_ROOT_DIR}/lib/coin
     81                - Do not look for COIN_VOL libraries
     82          #382: Allow lgf file without Arc maps
     83          #417: Bug fix in CostScaling
     84          #366: Fix Pred[Matrix]MapPath::empty()
     85          #371: Bug fix in (di)graphCopy()
     86                The target graph is cleared before adding nodes and arcs/edges.
     87          #364: Add missing UndirectedTags
     88          #368: Fix the usage of std::numeric_limits<>::min() in Network Simplex
     89          #372: Fix a critical bug in preflow
     90          #461: Bugfix in assert.h
     91          #470: Fix compilation issues related to various gcc versions
     92          #446: Fix #define indicating CPLEX availability
     93          #294: Add explicit namespace to
     94                ignore_unused_variable_warning() usages
     95          #420: Bugfix in IterableValueMap
     96          #439: Bugfix in biNodeConnected()
     97
     98
    1992010-03-19 Version 1.2 released
    2100
  • cmake/FindILOG.cmake

    r1232 r1331  
    6363  ${ILOG_CPLEX_ROOT_DIR}/lib/x86_debian4.0_4.1/static_pic
    6464  ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_debian4.0_4.1/static_pic
     65  ${ILOG_CPLEX_ROOT_DIR}/lib/x86_linux/static_pic
     66  ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_linux/static_pic
    6567  ${ILOG_CPLEX_ROOT_DIR}/lib/${ILOG_WIN_COMPILER}/stat_mda
    6668  NO_DEFAULT_PATH
     
    7375  ${ILOG_CONCERT_ROOT_DIR}/lib/x86_debian4.0_4.1/static_pic
    7476  ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_debian4.0_4.1/static_pic
     77  ${ILOG_CONCERT_ROOT_DIR}/lib/x86_linux/static_pic
     78  ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_linux/static_pic
    7579  ${ILOG_CONCERT_ROOT_DIR}/lib/${ILOG_WIN_COMPILER}/stat_mda
    7680  NO_DEFAULT_PATH
  • lemon/CMakeLists.txt

    r1264 r1315  
    5656
    5757ADD_LIBRARY(lemon ${LEMON_SOURCES})
     58
     59TARGET_LINK_LIBRARIES(lemon
     60  ${GLPK_LIBRARIES} ${COIN_LIBRARIES} ${ILOG_LIBRARIES} ${SOPLEX_LIBRARIES}
     61  )
     62
    5863IF(UNIX)
    59   SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon)
     64  SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon VERSION ${LEMON_VERSION} SOVERSION ${LEMON_VERSION})
    6065ENDIF()
    6166
  • lemon/arg_parser.h

    r959 r1327  
    2727#include <sstream>
    2828#include <algorithm>
     29#include <lemon/core.h>
    2930#include <lemon/assert.h>
    3031
  • lemon/bits/windows.cc

    r1270 r1341  
    2222#include<lemon/bits/windows.h>
    2323
    24 #ifdef WIN32
     24#if defined(LEMON_WIN32) && defined(__GNUC__)
     25#pragma GCC diagnostic ignored "-Wold-style-cast"
     26#endif
     27
     28#ifdef LEMON_WIN32
    2529#ifndef WIN32_LEAN_AND_MEAN
    2630#define WIN32_LEAN_AND_MEAN
     
    4145#include <unistd.h>
    4246#include <ctime>
    43 #ifndef WIN32
     47#ifndef LEMON_WIN32
    4448#include <sys/times.h>
    4549#endif
     
    5660                         double &cutime, double &cstime)
    5761    {
    58 #ifdef WIN32
     62#ifdef LEMON_WIN32
    5963      static const double ch = 4294967296.0e-7;
    6064      static const double cl = 1.0e-7;
     
    9599    {
    96100      std::ostringstream os;
    97 #ifdef WIN32
     101#ifdef LEMON_WIN32
    98102      SYSTEMTIME time;
    99103      GetSystemTime(&time);
    100104      char buf1[11], buf2[9], buf3[5];
    101           if (GetDateFormat(MY_LOCALE, 0, &time,
     105      if (GetDateFormat(MY_LOCALE, 0, &time,
    102106                        ("ddd MMM dd"), buf1, 11) &&
    103107          GetTimeFormat(MY_LOCALE, 0, &time,
     
    121125    int getWinRndSeed()
    122126    {
    123 #ifdef WIN32
     127#ifdef LEMON_WIN32
    124128      FILETIME time;
    125129      GetSystemTimeAsFileTime(&time);
     
    133137
    134138    WinLock::WinLock() {
    135 #ifdef WIN32
     139#ifdef LEMON_WIN32
    136140      CRITICAL_SECTION *lock = new CRITICAL_SECTION;
    137141      InitializeCriticalSection(lock);
     
    143147
    144148    WinLock::~WinLock() {
    145 #ifdef WIN32
     149#ifdef LEMON_WIN32
    146150      CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
    147151      DeleteCriticalSection(lock);
     
    151155
    152156    void WinLock::lock() {
    153 #ifdef WIN32
     157#ifdef LEMON_WIN32
    154158      CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
    155159      EnterCriticalSection(lock);
     
    158162
    159163    void WinLock::unlock() {
    160 #ifdef WIN32
     164#ifdef LEMON_WIN32
    161165      CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
    162166      LeaveCriticalSection(lock);
  • lemon/bits/windows.h

    r1270 r1340  
    2020#define LEMON_BITS_WINDOWS_H
    2121
     22#include <lemon/config.h>
    2223#include <string>
    2324
     
    3536      ~WinLock();
    3637      void lock();
    37       void unlock();
     38      void unlock();\
    3839    private:
    3940      void *_repr;
  • lemon/capacity_scaling.h

    r1270 r1363  
    2828#include <limits>
    2929#include <lemon/core.h>
     30#include <lemon/maps.h>
    3031#include <lemon/bin_heap.h>
    3132
     
    164165
    165166    // Parameters of the problem
    166     bool _have_lower;
     167    bool _has_lower;
    167168    Value _sum_supply;
    168169
     
    357358    template <typename LowerMap>
    358359    CapacityScaling& lowerMap(const LowerMap& map) {
    359       _have_lower = true;
     360      _has_lower = true;
    360361      for (ArcIt a(_graph); a != INVALID; ++a) {
    361362        _lower[_arc_idf[a]] = map[a];
    362         _lower[_arc_idb[a]] = map[a];
    363363      }
    364364      return *this;
     
    544544        _cost[j] = _forward[j] ? 1 : -1;
    545545      }
    546       _have_lower = false;
     546      _has_lower = false;
    547547      return *this;
    548548    }
     
    755755      const Value MAX = std::numeric_limits<Value>::max();
    756756      int last_out;
    757       if (_have_lower) {
     757      if (_has_lower) {
    758758        for (int i = 0; i != _root; ++i) {
    759759          last_out = _first_out[i+1];
     
    840840    }
    841841
    842     // Check if the upper bound is greater or equal to the lower bound
    843     // on each arc.
     842    // Check if the upper bound is greater than or equal to the lower bound
     843    // on each forward arc.
    844844    bool checkBoundMaps() {
    845845      for (int j = 0; j != _res_arc_num; ++j) {
    846         if (_upper[j] < _lower[j]) return false;
     846        if (_forward[j] && _upper[j] < _lower[j]) return false;
    847847      }
    848848      return true;
     
    858858
    859859      // Handle non-zero lower bounds
    860       if (_have_lower) {
     860      if (_has_lower) {
    861861        int limit = _first_out[_root];
    862862        for (int j = 0; j != limit; ++j) {
    863           if (!_forward[j]) _res_cap[j] += _lower[j];
     863          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
    864864        }
    865865      }
  • lemon/config.h.in

    r1264 r1340  
     1#ifndef LEMON_CONFIG_H
     2#define LEMON_CONFIG_H
     3
    14#define LEMON_VERSION "@PROJECT_VERSION@"
    25#cmakedefine LEMON_HAVE_LONG_LONG 1
     6
     7#cmakedefine LEMON_WIN32 1
     8
    39#cmakedefine LEMON_HAVE_LP 1
    410#cmakedefine LEMON_HAVE_MIP 1
     
    814#cmakedefine LEMON_HAVE_CLP 1
    915#cmakedefine LEMON_HAVE_CBC 1
    10 #cmakedefine LEMON_DEFAULT_LP @LEMON_DEFAULT_LP@
    11 #cmakedefine LEMON_DEFAULT_MIP @LEMON_DEFAULT_MIP@
     16
     17#define LEMON_CPLEX_ 1
     18#define LEMON_CLP_ 2
     19#define LEMON_GLPK_ 3
     20#define LEMON_SOPLEX_ 4
     21#define LEMON_CBC_ 5
     22
     23#cmakedefine LEMON_DEFAULT_LP LEMON_@LEMON_DEFAULT_LP@_
     24#cmakedefine LEMON_DEFAULT_MIP LEMON_@LEMON_DEFAULT_MIP@_
     25
    1226#cmakedefine LEMON_USE_PTHREAD 1
    1327#cmakedefine LEMON_USE_WIN32_THREADS 1
     28
     29#endif
  • lemon/core.h

    r1270 r1341  
    2020#define LEMON_CORE_H
    2121
    22 #include <vector>
    23 #include <algorithm>
    24 
    25 #include <lemon/config.h>
    26 #include <lemon/bits/enable_if.h>
    27 #include <lemon/bits/traits.h>
    28 #include <lemon/assert.h>
    29 
    30 // Disable the following warnings when compiling with MSVC:
    31 // C4250: 'class1' : inherits 'class2::member' via dominance
    32 // C4355: 'this' : used in base member initializer list
    33 // C4503: 'function' : decorated name length exceeded, name was truncated
    34 // C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
    35 // C4996: 'function': was declared deprecated
    36 #ifdef _MSC_VER
    37 #pragma warning( disable : 4250 4355 4503 4800 4996 )
    38 #endif
    39 
    40 #ifdef __GNUC__
    41 #define GCC_VERSION (__GNUC__ * 10000                   \
    42                      + __GNUC_MINOR__ * 100             \
    43                      + __GNUC_PATCHLEVEL__)
    44 #endif
    45 
    46 #if GCC_VERSION >= 40800
    47 // Needed by the [DI]GRAPH_TYPEDEFS marcos for gcc 4.8
    48 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
    49 #endif
    50 
    5122///\file
    5223///\brief LEMON core utilities.
     
    5526///It is automatically included by all graph types, therefore it usually
    5627///do not have to be included directly.
     28
     29// Disable the following warnings when compiling with MSVC:
     30// C4250: 'class1' : inherits 'class2::member' via dominance
     31// C4267: conversion from 'size_t' to 'type', possible loss of data
     32// C4355: 'this' : used in base member initializer list
     33// C4503: 'function' : decorated name length exceeded, name was truncated
     34// C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
     35// C4996: 'function': was declared deprecated
     36#ifdef _MSC_VER
     37#pragma warning( disable : 4250 4267 4355 4503 4800 4996 )
     38#endif
     39
     40#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
     41// Needed by the [DI]GRAPH_TYPEDEFS marcos for gcc 4.8
     42#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
     43#endif
     44
     45#include <vector>
     46#include <algorithm>
     47
     48#include <lemon/config.h>
     49#include <lemon/bits/enable_if.h>
     50#include <lemon/bits/traits.h>
     51#include <lemon/assert.h>
     52
     53
    5754
    5855namespace lemon {
  • lemon/cost_scaling.h

    r1271 r1298  
    257257
    258258    // Parameters of the problem
    259     bool _have_lower;
     259    bool _has_lower;
    260260    Value _sum_supply;
    261261    int _sup_node_num;
     
    373373    template <typename LowerMap>
    374374    CostScaling& lowerMap(const LowerMap& map) {
    375       _have_lower = true;
     375      _has_lower = true;
    376376      for (ArcIt a(_graph); a != INVALID; ++a) {
    377377        _lower[_arc_idf[a]] = map[a];
    378         _lower[_arc_idb[a]] = map[a];
    379378      }
    380379      return *this;
     
    569568        _scost[_reverse[j]] = 0;
    570569      }
    571       _have_lower = false;
     570      _has_lower = false;
    572571      return *this;
    573572    }
     
    781780      const Value MAX = std::numeric_limits<Value>::max();
    782781      int last_out;
    783       if (_have_lower) {
     782      if (_has_lower) {
    784783        for (int i = 0; i != _root; ++i) {
    785784          last_out = _first_out[i+1];
     
    838837        sup[n] = _supply[_node_id[n]];
    839838      }
    840       if (_have_lower) {
     839      if (_has_lower) {
    841840        for (ArcIt a(_graph); a != INVALID; ++a) {
    842841          int j = _arc_idf[a];
     
    908907    }
    909908
    910     // Check if the upper bound is greater or equal to the lower bound
    911     // on each arc.
     909    // Check if the upper bound is greater than or equal to the lower bound
     910    // on each forward arc.
    912911    bool checkBoundMaps() {
    913912      for (int j = 0; j != _res_arc_num; ++j) {
    914         if (_upper[j] < _lower[j]) return false;
     913        if (_forward[j] && _upper[j] < _lower[j]) return false;
    915914      }
    916915      return true;
     
    992991
    993992      // Handle non-zero lower bounds
    994       if (_have_lower) {
     993      if (_has_lower) {
    995994        int limit = _first_out[_root];
    996995        for (int j = 0; j != limit; ++j) {
    997           if (!_forward[j]) _res_cap[j] += _lower[j];
     996          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
    998997        }
    999998      }
  • lemon/counter.h

    r833 r1327  
    2222#include <string>
    2323#include <iostream>
     24
     25#include <lemon/core.h>
    2426
    2527///\ingroup timecount
  • lemon/cplex.cc

    r1270 r1347  
    3838  }
    3939
     40  void CplexEnv::incCnt()
     41  {
     42    _cnt_lock->lock();
     43    ++(*_cnt);
     44    _cnt_lock->unlock();
     45  }
     46
     47  void CplexEnv::decCnt()
     48  {
     49    _cnt_lock->lock();
     50    --(*_cnt);
     51    if (*_cnt == 0) {
     52      delete _cnt;
     53      _cnt_lock->unlock();
     54      delete _cnt_lock;
     55      CPXcloseCPLEX(&_env);
     56    }
     57    else _cnt_lock->unlock();
     58  }
     59 
    4060  CplexEnv::CplexEnv() {
    4161    int status;
     62    _env = CPXopenCPLEX(&status);
     63    if (_env == 0)
     64      throw LicenseError(status);
    4265    _cnt = new int;
    4366    (*_cnt) = 1;
    44     _env = CPXopenCPLEX(&status);
    45     if (_env == 0) {
    46       delete _cnt;
    47       _cnt = 0;
    48       throw LicenseError(status);
    49     }
     67    _cnt_lock = new bits::Lock;
    5068  }
    5169
     
    5371    _env = other._env;
    5472    _cnt = other._cnt;
    55     ++(*_cnt);
     73    _cnt_lock = other._cnt_lock;
     74    incCnt();
    5675  }
    5776
    5877  CplexEnv& CplexEnv::operator=(const CplexEnv& other) {
     78    decCnt();
    5979    _env = other._env;
    6080    _cnt = other._cnt;
    61     ++(*_cnt);
     81    _cnt_lock = other._cnt_lock;
     82    incCnt();
    6283    return *this;
    6384  }
    6485
    6586  CplexEnv::~CplexEnv() {
    66     --(*_cnt);
    67     if (*_cnt == 0) {
    68       delete _cnt;
    69       CPXcloseCPLEX(&_env);
    70     }
     87    decCnt();
    7188  }
    7289
  • lemon/cplex.h

    r1270 r1347  
    2424
    2525#include <lemon/lp_base.h>
     26#include <lemon/bits/lock.h>
    2627
    2728struct cpxenv;
     
    4142    cpxenv* _env;
    4243    mutable int* _cnt;
    43 
     44    mutable bits::Lock* _cnt_lock;
     45
     46    void incCnt();
     47    void decCnt();
     48   
    4449  public:
    4550
  • lemon/cycle_canceling.h

    r1270 r1298  
    196196
    197197    // Parameters of the problem
    198     bool _have_lower;
     198    bool _has_lower;
    199199    Value _sum_supply;
    200200
     
    279279    template <typename LowerMap>
    280280    CycleCanceling& lowerMap(const LowerMap& map) {
    281       _have_lower = true;
     281      _has_lower = true;
    282282      for (ArcIt a(_graph); a != INVALID; ++a) {
    283283        _lower[_arc_idf[a]] = map[a];
    284         _lower[_arc_idb[a]] = map[a];
    285284      }
    286285      return *this;
     
    472471        _cost[_reverse[j]] = 0;
    473472      }
    474       _have_lower = false;
     473      _has_lower = false;
    475474      return *this;
    476475    }
     
    685684      const Value MAX = std::numeric_limits<Value>::max();
    686685      int last_out;
    687       if (_have_lower) {
     686      if (_has_lower) {
    688687        for (int i = 0; i != _root; ++i) {
    689688          last_out = _first_out[i+1];
     
    728727        sup[n] = _supply[_node_id[n]];
    729728      }
    730       if (_have_lower) {
     729      if (_has_lower) {
    731730        for (ArcIt a(_graph); a != INVALID; ++a) {
    732731          int j = _arc_idf[a];
     
    785784    }
    786785
    787     // Check if the upper bound is greater or equal to the lower bound
    788     // on each arc.
     786    // Check if the upper bound is greater than or equal to the lower bound
     787    // on each forward arc.
    789788    bool checkBoundMaps() {
    790789      for (int j = 0; j != _res_arc_num; ++j) {
    791         if (_upper[j] < _lower[j]) return false;
     790        if (_forward[j] && _upper[j] < _lower[j]) return false;
    792791      }
    793792      return true;
     
    836835
    837836      // Handle non-zero lower bounds
    838       if (_have_lower) {
     837      if (_has_lower) {
    839838        int limit = _first_out[_root];
    840839        for (int j = 0; j != limit; ++j) {
    841           if (!_forward[j]) _res_cap[j] += _lower[j];
     840          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
    842841        }
    843842      }
  • lemon/dim2.h

    r761 r1311  
    2121
    2222#include <iostream>
     23#include <algorithm>
    2324
    2425///\ingroup geomdat
  • lemon/dimacs.h

    r1270 r1375  
    2626#include <lemon/maps.h>
    2727#include <lemon/error.h>
     28
    2829/// \ingroup dimacs_group
    2930/// \file
     
    123124  ///
    124125  /// If the file type was previously evaluated by dimacsType(), then
    125   /// the descriptor struct should be given by the \c dest parameter.
     126  /// the descriptor struct should be given by the \c desc parameter.
    126127  template <typename Digraph, typename LowerMap,
    127128            typename CapacityMap, typename CostMap,
     
    277278  ///
    278279  /// If the file type was previously evaluated by dimacsType(), then
    279   /// the descriptor struct should be given by the \c dest parameter.
     280  /// the descriptor struct should be given by the \c desc parameter.
    280281  template<typename Digraph, typename CapacityMap>
    281282  void readDimacsMax(std::istream& is,
     
    304305  ///
    305306  /// If the file type was previously evaluated by dimacsType(), then
    306   /// the descriptor struct should be given by the \c dest parameter.
     307  /// the descriptor struct should be given by the \c desc parameter.
    307308  template<typename Digraph, typename LengthMap>
    308309  void readDimacsSp(std::istream& is,
     
    335336  ///
    336337  /// If the file type was previously evaluated by dimacsType(), then
    337   /// the descriptor struct should be given by the \c dest parameter.
     338  /// the descriptor struct should be given by the \c desc parameter.
    338339  template<typename Digraph, typename CapacityMap>
    339340  void readDimacsCap(std::istream& is,
     
    344345    typename Digraph::Node u,v;
    345346    if(desc.type==DimacsDescriptor::NONE) desc=dimacsType(is);
    346     if(desc.type!=DimacsDescriptor::MAX || desc.type!=DimacsDescriptor::SP)
     347    if(desc.type!=DimacsDescriptor::MAX && desc.type!=DimacsDescriptor::SP)
    347348      throw FormatError("Problem type mismatch");
    348349    _readDimacs(is, g, capacity, u, v, infty, desc);
     
    375376  ///
    376377  /// If the file type was previously evaluated by dimacsType(), then
    377   /// the descriptor struct should be given by the \c dest parameter.
     378  /// the descriptor struct should be given by the \c desc parameter.
    378379  template<typename Graph>
    379380  void readDimacsMat(std::istream& is, Graph &g,
  • lemon/elevator.h

    r628 r1328  
    168168    int onLevel(int l) const
    169169    {
    170       return _first[l+1]-_first[l];
     170      return static_cast<int>(_first[l+1]-_first[l]);
    171171    }
    172172    ///Return true if level \c l is empty.
     
    178178    int aboveLevel(int l) const
    179179    {
    180       return _first[_max_level+1]-_first[l+1];
     180      return static_cast<int>(_first[_max_level+1]-_first[l+1]);
    181181    }
    182182    ///Return the number of active items on level \c l.
    183183    int activesOnLevel(int l) const
    184184    {
    185       return _last_active[l]-_first[l]+1;
     185      return static_cast<int>(_last_active[l]-_first[l]+1);
    186186    }
    187187    ///Return true if there is no active item on level \c l.
  • lemon/graph_to_eps.h

    r1270 r1340  
    2626#include<vector>
    2727
    28 #ifndef WIN32
     28#ifndef LEMON_WIN32
    2929#include<sys/time.h>
    3030#include<ctime>
     
    223223  using T::_copyright;
    224224
    225   using T::NodeTextColorType;
    226225  using T::CUST_COL;
    227226  using T::DIST_COL;
     
    676675    {
    677676      os << "%%CreationDate: ";
    678 #ifndef WIN32
     677#ifndef LEMON_WIN32
    679678      timeval tv;
    680679      gettimeofday(&tv, 0);
  • lemon/list_graph.h

    r1270 r1357  
    583583        }
    584584        virtual void add(const std::vector<Node>& nodes) {
    585           for (int i = nodes.size() - 1; i >= 0; ++i) {
     585          for (int i = nodes.size() - 1; i >= 0; --i) {
    586586            snapshot.addNode(nodes[i]);
    587587          }
     
    633633        }
    634634        virtual void add(const std::vector<Arc>& arcs) {
    635           for (int i = arcs.size() - 1; i >= 0; ++i) {
     635          for (int i = arcs.size() - 1; i >= 0; --i) {
    636636            snapshot.addArc(arcs[i]);
    637637          }
     
    13951395        }
    13961396        virtual void add(const std::vector<Node>& nodes) {
    1397           for (int i = nodes.size() - 1; i >= 0; ++i) {
     1397          for (int i = nodes.size() - 1; i >= 0; --i) {
    13981398            snapshot.addNode(nodes[i]);
    13991399          }
     
    14451445        }
    14461446        virtual void add(const std::vector<Edge>& edges) {
    1447           for (int i = edges.size() - 1; i >= 0; ++i) {
     1447          for (int i = edges.size() - 1; i >= 0; --i) {
    14481448            snapshot.addEdge(edges[i]);
    14491449          }
     
    23002300        }
    23012301        virtual void add(const std::vector<Node>& nodes) {
    2302           for (int i = nodes.size() - 1; i >= 0; ++i) {
     2302          for (int i = nodes.size() - 1; i >= 0; --i) {
    23032303            snapshot.addNode(nodes[i]);
    23042304          }
     
    23502350        }
    23512351        virtual void add(const std::vector<Edge>& edges) {
    2352           for (int i = edges.size() - 1; i >= 0; ++i) {
     2352          for (int i = edges.size() - 1; i >= 0; --i) {
    23532353            snapshot.addEdge(edges[i]);
    23542354          }
  • lemon/lp.h

    r1270 r1340  
    2323
    2424
    25 #ifdef LEMON_HAVE_GLPK
     25#if LEMON_DEFAULT_LP == LEMON_GLPK_ || LEMON_DEFAULT_MIP == LEMON_GLPK_
    2626#include <lemon/glpk.h>
    27 #elif LEMON_HAVE_CPLEX
     27#endif
     28#if LEMON_DEFAULT_LP == LEMON_CPLEX_ || LEMON_DEFAULT_MIP == LEMON_CPLEX_
    2829#include <lemon/cplex.h>
    29 #elif LEMON_HAVE_SOPLEX
     30#endif
     31#if LEMON_DEFAULT_LP == LEMON_SOPLEX_
    3032#include <lemon/soplex.h>
    31 #elif LEMON_HAVE_CLP
     33#endif
     34#if LEMON_DEFAULT_LP == LEMON_CLP_
    3235#include <lemon/clp.h>
     36#endif
     37#if LEMON_DEFAULT_MIP == LEMON_CBC_
     38#include <lemon/cbc.h>
    3339#endif
    3440
     
    4450  ///\ingroup lp_group
    4551  ///
    46   ///Currently, the possible values are \c GLPK, \c CPLEX,
    47   ///\c SOPLEX or \c CLP
     52  ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_,
     53  ///\c LEMON_SOPLEX_ or \c LEMON_CLP_
    4854#define LEMON_DEFAULT_LP SOLVER
    4955  ///The default LP solver
     
    6066  ///\ingroup lp_group
    6167  ///
    62   ///Currently, the possible values are \c GLPK, \c CPLEX or \c CBC
     68  ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_
     69  ///or \c LEMON_CBC_
    6370#define LEMON_DEFAULT_MIP SOLVER
    6471  ///The default MIP solver.
     
    7077  typedef GlpkMip Mip;
    7178#else
    72 #if LEMON_DEFAULT_LP == GLPK
     79#if LEMON_DEFAULT_LP == LEMON_GLPK_
    7380  typedef GlpkLp Lp;
    74 #elif LEMON_DEFAULT_LP == CPLEX
     81#elif LEMON_DEFAULT_LP == LEMON_CPLEX_
    7582  typedef CplexLp Lp;
    76 #elif LEMON_DEFAULT_LP == SOPLEX
     83#elif LEMON_DEFAULT_LP == LEMON_SOPLEX_
    7784  typedef SoplexLp Lp;
    78 #elif LEMON_DEFAULT_LP == CLP
     85#elif LEMON_DEFAULT_LP == LEMON_CLP_
    7986  typedef ClpLp Lp;
    8087#endif
    81 #if LEMON_DEFAULT_MIP == GLPK
    82   typedef GlpkLp Mip;
    83 #elif LEMON_DEFAULT_MIP == CPLEX
     88#if LEMON_DEFAULT_MIP == LEMON_GLPK_
     89  typedef GlpkMip Mip;
     90#elif LEMON_DEFAULT_MIP == LEMON_CPLEX_
    8491  typedef CplexMip Mip;
    85 #elif LEMON_DEFAULT_MIP == CBC
     92#elif LEMON_DEFAULT_MIP == LEMON_CBC_
    8693  typedef CbcMip Mip;
    8794#endif
  • lemon/math.h

    r1270 r1311  
    6868  ///Round a value to its closest integer
    6969  inline double round(double r) {
    70     return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
     70    return (r > 0.0) ? std::floor(r + 0.5) : std::ceil(r - 0.5);
    7171  }
    7272
  • lemon/nearest_neighbor_tsp.h

    r1270 r1294  
    116116            for (IncEdgeIt e(_gr, n1); e != INVALID; ++e) {
    117117              if (!used[_gr.runningNode(e)] &&
    118                   (_cost[e] < _cost[min_edge1] || min_edge1 == INVALID)) {
     118                  (min_edge1 == INVALID || _cost[e] < _cost[min_edge1])) {
    119119                min_edge1 = e;
    120120              }
     
    125125            for (IncEdgeIt e(_gr, n2); e != INVALID; ++e) {
    126126              if (!used[_gr.runningNode(e)] &&
    127                   (_cost[e] < _cost[min_edge2] || min_edge2 == INVALID)) {
     127                  (min_edge2 == INVALID||_cost[e] < _cost[min_edge2])) {
    128128                min_edge2 = e;
    129129              }
  • lemon/network_simplex.h

    r1270 r1318  
    199199
    200200    // Parameters of the problem
    201     bool _have_lower;
     201    bool _has_lower;
    202202    SupplyType _stype;
    203203    Value _sum_supply;
     
    683683    template <typename LowerMap>
    684684    NetworkSimplex& lowerMap(const LowerMap& map) {
    685       _have_lower = true;
     685      _has_lower = true;
    686686      for (ArcIt a(_graph); a != INVALID; ++a) {
    687687        _lower[_arc_id[a]] = map[a];
     
    880880        _cost[i] = 1;
    881881      }
    882       _have_lower = false;
     882      _has_lower = false;
    883883      _stype = GEQ;
    884884      return *this;
     
    937937        _node_id[n] = i;
    938938      }
    939       if (_arc_mixing) {
     939      if (_arc_mixing && _node_num > 1) {
    940940        // Store the arcs in a mixed order
    941941        const int skip = std::max(_arc_num / _node_num, 3);
     
    10731073
    10741074      // Remove non-zero lower bounds
    1075       if (_have_lower) {
     1075      if (_has_lower) {
    10761076        for (int i = 0; i != _arc_num; ++i) {
    10771077          Value c = _lower[i];
     
    12361236    }
    12371237
    1238     // Check if the upper bound is greater or equal to the lower bound
     1238    // Check if the upper bound is greater than or equal to the lower bound
    12391239    // on each arc.
    12401240    bool checkBoundMaps() {
     
    16131613
    16141614      // Transform the solution and the supply map to the original form
    1615       if (_have_lower) {
     1615      if (_has_lower) {
    16161616        for (int i = 0; i != _arc_num; ++i) {
    16171617          Value c = _lower[i];
  • lemon/preflow.h

    r1270 r1385  
    477477    /// flow to the given \c flowMap. The \c flowMap should contain a
    478478    /// flow or at least a preflow, i.e. at each node excluding the
    479     /// source node the incoming flow should greater or equal to the
     479    /// source node the incoming flow should be greater or equal to the
    480480    /// outgoing flow.
    481481    /// \return \c false if the given \c flowMap is not a preflow.
     
    496496          excess -= (*_flow)[e];
    497497        }
    498         if (excess < 0 && n != _source) return false;
     498        if (_tolerance.negative(excess) && n != _source) return false;
    499499        (*_excess)[n] = excess;
    500500      }
     
    640640          (*_excess)[n] = excess;
    641641
    642           if (excess != 0) {
     642          if (_tolerance.nonZero(excess)) {
    643643            if (new_level + 1 < _level->maxLevel()) {
    644644              _level->liftHighestActive(new_level + 1);
     
    721721          (*_excess)[n] = excess;
    722722
    723           if (excess != 0) {
     723          if (_tolerance.nonZero(excess)) {
    724724            if (new_level + 1 < _level->maxLevel()) {
    725725              _level->liftActiveOn(level, new_level + 1);
     
    792792        if (!reached[n]) {
    793793          _level->dirtyTopButOne(n);
    794         } else if ((*_excess)[n] > 0 && _target != n) {
     794        } else if (_tolerance.positive((*_excess)[n]) && _target != n) {
    795795          _level->activate(n);
    796796        }
     
    853853        (*_excess)[n] = excess;
    854854
    855         if (excess != 0) {
     855        if (_tolerance.nonZero(excess)) {
    856856          if (new_level + 1 < _level->maxLevel()) {
    857857            _level->liftHighestActive(new_level + 1);
  • lemon/radix_sort.h

    r1270 r1328  
    329329      Allocator allocator;
    330330
    331       int length = std::distance(first, last);
     331      int length = static_cast<int>(std::distance(first, last));
    332332      Key* buffer = allocator.allocate(2 * length);
    333333      try {
  • lemon/random.h

    r631 r1340  
    6363#define LEMON_RANDOM_H
    6464
     65#include <lemon/config.h>
     66
    6567#include <algorithm>
    6668#include <iterator>
     
    7274#include <lemon/dim2.h>
    7375
    74 #ifndef WIN32
     76#ifndef LEMON_WIN32
    7577#include <sys/time.h>
    7678#include <ctime>
     
    200202        initState(init);
    201203
    202         num = length > end - begin ? length : end - begin;
     204        num = static_cast<int>(length > end - begin ? length : end - begin);
    203205        while (num--) {
    204206          curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul1))
     
    214216        }
    215217
    216         num = length - 1; cnt = length - (curr - state) - 1;
     218        num = length - 1; cnt = static_cast<int>(length - (curr - state) - 1);
    217219        while (num--) {
    218220          curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul2))
     
    606608    /// \return Currently always \c true.
    607609    bool seed() {
    608 #ifndef WIN32
     610#ifndef LEMON_WIN32
    609611      if (seedFromFile("/dev/urandom", 0)) return true;
    610612#endif
     
    626628    /// \param offset The offset, from the file read.
    627629    /// \return \c true when the seeding successes.
    628 #ifndef WIN32
     630#ifndef LEMON_WIN32
    629631    bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0)
    630632#else
     
    648650    /// \return Currently always \c true.
    649651    bool seedFromTime() {
    650 #ifndef WIN32
     652#ifndef LEMON_WIN32
    651653      timeval tv;
    652654      gettimeofday(&tv, 0);
  • lemon/static_graph.h

    r956 r1328  
    204204
    205205      node_num = n;
    206       arc_num = std::distance(first, last);
     206      arc_num = static_cast<int>(std::distance(first, last));
    207207
    208208      node_first_out = new int[node_num + 1];
  • lemon/time_measure.h

    r1270 r1340  
    2424///\brief Tools for measuring cpu usage
    2525
    26 #ifdef WIN32
     26#include <lemon/config.h>
     27
     28#ifdef LEMON_WIN32
    2729#include <lemon/bits/windows.h>
    2830#else
     
    103105    void stamp()
    104106    {
    105 #ifndef WIN32
     107#ifndef LEMON_WIN32
    106108      timeval tv;
    107109      gettimeofday(&tv, 0);
  • test/arc_look_up_test.cc

    r1270 r1312  
    2525using namespace lemon;
    2626
    27 const int lgfn = 4;
    2827const std::string lgf =
    2928  "@nodes\n"
  • test/bpgraph_test.cc

    r1270 r1292  
    7979    e2 = G.addEdge(bn1, rn1),
    8080    e3 = G.addEdge(rn1, bn2);
     81  ::lemon::ignore_unused_variable_warning(e2,e3);
    8182
    8283  checkGraphNodeList(G, 3);
     
    120121    e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3),
    121122    e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3);
     123  ::lemon::ignore_unused_variable_warning(e1,e3,e4);
    122124
    123125  // Check edge deletion
     
    168170    e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3),
    169171    e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3);
     172  ::lemon::ignore_unused_variable_warning(e1,e3,e4);
    170173
    171174  G.changeRed(e2, n4);
     
    220223    e1 = G.addEdge(n1, n2),
    221224    e2 = G.addEdge(n1, n3);
     225  ::lemon::ignore_unused_variable_warning(e1,e2);
    222226
    223227  checkGraphNodeList(G, 3);
     
    305309    e1 = g.addEdge(n1, n2),
    306310    e2 = g.addEdge(n1, n3);
     311  ::lemon::ignore_unused_variable_warning(e2);
    307312
    308313  check(g.valid(n1), "Wrong validity check");
  • test/lp_test.cc

    r1270 r1300  
    4040#endif
    4141
     42#ifdef LEMON_HAVE_LP
     43#include <lemon/lp.h>
     44#endif
    4245using namespace lemon;
    4346
     
    417420  lpTest(lp_skel);
    418421
     422#ifdef LEMON_HAVE_LP
     423  {
     424    Lp lp,lp2;
     425    lpTest(lp);
     426    aTest(lp2);
     427    cloneTest<Lp>();
     428  }
     429#endif
     430
    419431#ifdef LEMON_HAVE_GLPK
    420432  {
  • test/max_flow_test.cc

    r1270 r1385  
    2727#include <lemon/lgf_reader.h>
    2828#include <lemon/elevator.h>
     29#include <lemon/tolerance.h>
    2930
    3031using namespace lemon;
     
    6667  "target 8\n";
    6768
     69char test_lgf_float[] =
     70  "@nodes\n"
     71  "label\n"
     72  "0\n"
     73  "1\n"
     74  "2\n"
     75  "3\n"
     76  "4\n"
     77  "5\n"
     78  "6\n"
     79  "7\n"
     80  "8\n"
     81  "9\n"
     82  "@arcs\n"
     83  "      capacity\n"
     84  "0 1 0.1\n"
     85  "0 2 0.1\n"
     86  "0 3 0.1\n"
     87  "1 4 0.1\n"
     88  "2 4 0.1\n"
     89  "3 4 0.1\n"
     90  "4 5 0.3\n"
     91  "5 6 0.1\n"
     92  "5 7 0.1\n"
     93  "5 8 0.1\n"
     94  "6 9 0.1\n"
     95  "7 9 0.1\n"
     96  "8 9 0.1\n"
     97  "@attributes\n"
     98  "source 0\n"
     99  "target 9\n";
    68100
    69101// Checks the general interface of a max flow algorithm
     
    166198  typedef concepts::Digraph Digraph;
    167199  typedef concepts::ReadMap<Digraph::Arc, Value> CapMap;
    168   typedef Elevator<Digraph, Digraph::Node> Elev;
    169   typedef LinkedElevator<Digraph, Digraph::Node> LinkedElev;
    170200
    171201  Digraph g;
     
    185215
    186216template <typename T>
    187 T cutValue (const SmartDigraph& g,
    188               const SmartDigraph::NodeMap<bool>& cut,
    189               const SmartDigraph::ArcMap<T>& cap) {
    190 
    191   T c=0;
    192   for(SmartDigraph::ArcIt e(g); e!=INVALID; ++e) {
    193     if (cut[g.source(e)] && !cut[g.target(e)]) c+=cap[e];
     217T cutValue(const SmartDigraph& g,
     218           const SmartDigraph::NodeMap<bool>& cut,
     219           const SmartDigraph::ArcMap<T>& cap) {
     220
     221  T c = 0;
     222  for (SmartDigraph::ArcIt e(g); e != INVALID; ++e) {
     223    if (cut[g.source(e)] && !cut[g.target(e)]) c += cap[e];
    194224  }
    195225  return c;
     
    200230               const SmartDigraph::ArcMap<T>& flow,
    201231               const SmartDigraph::ArcMap<T>& cap,
    202                SmartDigraph::Node s, SmartDigraph::Node t) {
     232               SmartDigraph::Node s, SmartDigraph::Node t,
     233               const Tolerance<T>& tol) {
    203234
    204235  for (SmartDigraph::ArcIt e(g); e != INVALID; ++e) {
    205     if (flow[e] < 0 || flow[e] > cap[e]) return false;
     236    if (tol.negative(flow[e]) || tol.less(cap[e], flow[e])) return false;
    206237  }
    207238
     
    215246      sum -= flow[e];
    216247    }
    217     if (sum != 0) return false;
     248    if (tol.nonZero(sum)) return false;
    218249  }
    219250  return true;
    220251}
    221252
    222 void initFlowTest()
     253void checkInitPreflow()
    223254{
    224255  DIGRAPH_TYPEDEFS(SmartDigraph);
    225256
    226257  SmartDigraph g;
    227   SmartDigraph::ArcMap<int> cap(g),iflow(g);
    228   Node s=g.addNode(); Node t=g.addNode();
    229   Node n1=g.addNode(); Node n2=g.addNode();
     258  SmartDigraph::ArcMap<int> cap(g), iflow(g);
     259  Node s = g.addNode(); Node t = g.addNode();
     260  Node n1 = g.addNode(); Node n2 = g.addNode();
    230261  Arc a;
    231   a=g.addArc(s,n1); cap[a]=20; iflow[a]=20;
    232   a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0;
    233   a=g.addArc(n2,t); cap[a]=20; iflow[a]=0;
    234 
    235   Preflow<SmartDigraph> pre(g,cap,s,t);
     262  a = g.addArc(s, n1); cap[a] = 20; iflow[a] = 20;
     263  a = g.addArc(n1, n2); cap[a] = 10; iflow[a] = 0;
     264  a = g.addArc(n2, t); cap[a] = 20; iflow[a] = 0;
     265
     266  Preflow<SmartDigraph> pre(g, cap, s, t);
    236267  pre.init(iflow);
    237268  pre.startFirstPhase();
    238   check(pre.flowValue() == 10, "The incorrect max flow value.");
     269
     270  check(pre.flowValue() == 10, "Incorrect max flow value.");
    239271  check(pre.minCut(s), "Wrong min cut (Node s).");
    240272  check(pre.minCut(n1), "Wrong min cut (Node n1).");
     
    244276
    245277template <typename MF, typename SF>
    246 void checkMaxFlowAlg() {
     278void checkMaxFlowAlg(const char *input_lgf,  typename MF::Value expected) {
    247279  typedef SmartDigraph Digraph;
    248280  DIGRAPH_TYPEDEFS(Digraph);
     
    253285  typedef BoolNodeMap CutMap;
    254286
     287  Tolerance<Value> tol;
     288
    255289  Digraph g;
    256290  Node s, t;
    257291  CapMap cap(g);
    258   std::istringstream input(test_lgf);
    259   DigraphReader<Digraph>(g,input)
     292  std::istringstream input(input_lgf);
     293  DigraphReader<Digraph>(g, input)
    260294      .arcMap("capacity", cap)
    261       .node("source",s)
    262       .node("target",t)
     295      .node("source", s)
     296      .node("target", t)
    263297      .run();
    264298
     
    266300  max_flow.run();
    267301
    268   check(checkFlow(g, max_flow.flowMap(), cap, s, t),
     302  check(!tol.different(expected, max_flow.flowValue()),
     303        "Incorrect max flow value.");
     304  check(checkFlow(g, max_flow.flowMap(), cap, s, t, tol),
    269305        "The flow is not feasible.");
    270306
     
    273309  Value min_cut_value = cutValue(g, min_cut, cap);
    274310
    275   check(max_flow.flowValue() == min_cut_value,
    276         "The max flow value is not equal to the min cut value.");
     311  check(!tol.different(expected, min_cut_value),
     312        "Incorrect min cut value.");
    277313
    278314  FlowMap flow(g);
    279   for (ArcIt e(g); e != INVALID; ++e) flow[e] = max_flow.flowMap()[e];
    280 
    281   Value flow_value = max_flow.flowValue();
    282 
    283   for (ArcIt e(g); e != INVALID; ++e) cap[e] = 2 * cap[e];
     315  for (ArcIt e(g); e != INVALID; ++e) flow[e] = 13 * max_flow.flowMap()[e];
     316  for (ArcIt e(g); e != INVALID; ++e) cap[e] = 17 * cap[e];
    284317  max_flow.init(flow);
    285318
     
    290323  min_cut_value = cutValue(g, min_cut1, cap);
    291324
    292   check(max_flow.flowValue() == min_cut_value &&
    293         min_cut_value == 2 * flow_value,
    294         "The max flow value or the min cut value is wrong.");
     325  check(!tol.different(17 * expected, max_flow.flowValue()),
     326        "Incorrect max flow value.");
     327  check(!tol.different(17 * expected, min_cut_value),
     328        "Incorrect min cut value.");
    295329
    296330  SF::startSecondPhase(max_flow);       // start second phase of the algorithm
    297331
    298   check(checkFlow(g, max_flow.flowMap(), cap, s, t),
     332  check(checkFlow(g, max_flow.flowMap(), cap, s, t, tol),
    299333        "The flow is not feasible.");
    300334
     
    303337  min_cut_value = cutValue(g, min_cut2, cap);
    304338
    305   check(max_flow.flowValue() == min_cut_value &&
    306         min_cut_value == 2 * flow_value,
    307         "The max flow value or the min cut value was not doubled");
    308 
     339  check(!tol.different(17 * expected, max_flow.flowValue()),
     340        "Incorrect max flow value.");
     341  check(!tol.different(17 * expected, min_cut_value),
     342        "Incorrect min cut value.");
    309343
    310344  max_flow.flowMap(flow);
     
    325359  CutMap min_cut3(g);
    326360  max_flow.minCutMap(min_cut3);
    327   min_cut_value=cutValue(g, min_cut3, cap);
    328 
    329   check(max_flow.flowValue() == min_cut_value,
     361  min_cut_value = cutValue(g, min_cut3, cap);
     362
     363  check(!tol.different(max_flow.flowValue(), min_cut_value),
    330364        "The max flow value or the min cut value is wrong.");
    331365}
     
    380414  typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<int> > PType1;
    381415  typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<float> > PType2;
    382   checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >();
    383   checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >();
    384   initFlowTest();
     416  typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<double> > PType3;
     417
     418  checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >(test_lgf, 13);
     419  checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf, 13);
     420  checkMaxFlowAlg<PType3, PreflowStartFunctions<PType3> >(test_lgf, 13);
     421
     422  checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf_float, 0.3);
     423  checkMaxFlowAlg<PType3, PreflowStartFunctions<PType3> >(test_lgf_float, 0.3);
     424
     425  checkInitPreflow();
    385426
    386427  // Check EdmondsKarp
    387428  typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<int> > EKType1;
    388429  typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<float> > EKType2;
    389   checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >();
    390   checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >();
    391 
    392   initFlowTest();
     430  typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<double> > EKType3;
     431
     432  checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >(test_lgf, 13);
     433  checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf, 13);
     434  checkMaxFlowAlg<EKType3, GeneralStartFunctions<EKType3> >(test_lgf, 13);
     435
     436  checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf_float, 0.3);
     437  checkMaxFlowAlg<EKType3, GeneralStartFunctions<EKType3> >(test_lgf_float, 0.3);
    393438
    394439  return 0;
  • test/min_cost_flow_test.cc

    r1270 r1318  
    396396  checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s,
    397397           mcf3.OPTIMAL, true,     -300, test_str + "-18", GEQ);
     398
     399  // Tests for empty graph
     400  Digraph gr0;
     401  MCF mcf0(gr0);
     402  mcf0.run(param);
     403  check(mcf0.totalCost() == 0, "Wrong total cost"); 
    398404}
    399405
  • test/mip_test.cc

    r795 r1300  
    3131#ifdef LEMON_HAVE_CBC
    3232#include <lemon/cbc.h>
     33#endif
     34
     35#ifdef LEMON_HAVE_MIP
     36#include <lemon/lp.h>
    3337#endif
    3438
     
    129133{
    130134
     135#ifdef LEMON_HAVE_MIP
     136  {
     137    Mip mip1;
     138    aTest(mip1);
     139    cloneTest<Mip>();
     140  }
     141#endif
     142
    131143#ifdef LEMON_HAVE_GLPK
    132144  {
  • test/radix_sort_test.cc

    r1270 r1341  
    1616 *
    1717 */
     18
     19#include <lemon/core.h>
    1820
    1921#include <lemon/time_measure.h>
  • test/tsp_test.cc

    r1271 r1303  
    133133    int esize = n <= 1 ? 0 : n;
    134134
    135     TSP alg(g, constMap<Edge, int>(1));
     135    ConstMap<Edge, int> cost_map(1);
     136    TSP alg(g, cost_map);
    136137
    137138    check(alg.run() == esize, alg_name + ": Wrong total cost");
  • tools/lgf-gen.cc

    r701 r1308  
    247247  struct BeachIt;
    248248
    249   typedef std::multimap<double, BeachIt> SpikeHeap;
     249  typedef std::multimap<double, BeachIt*> SpikeHeap;
    250250
    251251  typedef std::multimap<Part, SpikeHeap::iterator, YLess> Beach;
     
    330330
    331331      if (bit->second != spikeheap.end()) {
     332        delete bit->second->second;
    332333        spikeheap.erase(bit->second);
    333334      }
     
    343344          circle_form(points[prev], points[curr], points[site])) {
    344345        double x = circle_point(points[prev], points[curr], points[site]);
    345         pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
    346         pit->second.it =
     346        pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
     347        pit->second->it =
    347348          beach.insert(std::make_pair(Part(prev, curr, site), pit));
    348349      } else {
     
    356357          circle_form(points[site], points[curr],points[next])) {
    357358        double x = circle_point(points[site], points[curr], points[next]);
    358         nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
    359         nit->second.it =
     359        nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
     360        nit->second->it =
    360361          beach.insert(std::make_pair(Part(site, curr, next), nit));
    361362      } else {
     
    367368      sweep = spit->first;
    368369
    369       Beach::iterator bit = spit->second.it;
     370      Beach::iterator bit = spit->second->it;
    370371
    371372      int prev = bit->first.prev;
     
    400401      int nnt = nbit->first.next;
    401402
    402       if (bit->second != spikeheap.end()) spikeheap.erase(bit->second);
    403       if (pbit->second != spikeheap.end()) spikeheap.erase(pbit->second);
    404       if (nbit->second != spikeheap.end()) spikeheap.erase(nbit->second);
    405 
     403      if (bit->second != spikeheap.end())
     404        {
     405          delete bit->second->second;
     406          spikeheap.erase(bit->second);
     407        }
     408      if (pbit->second != spikeheap.end())
     409        {
     410          delete pbit->second->second;
     411          spikeheap.erase(pbit->second);
     412        }
     413      if (nbit->second != spikeheap.end())
     414        {
     415          delete nbit->second->second;
     416          spikeheap.erase(nbit->second);
     417        }
     418     
    406419      beach.erase(nbit);
    407420      beach.erase(bit);
     
    413426        double x = circle_point(points[ppv], points[prev], points[next]);
    414427        if (x < sweep) x = sweep;
    415         pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
    416         pit->second.it =
     428        pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
     429        pit->second->it =
    417430          beach.insert(std::make_pair(Part(ppv, prev, next), pit));
    418431      } else {
     
    425438        double x = circle_point(points[prev], points[next], points[nnt]);
    426439        if (x < sweep) x = sweep;
    427         nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end())));
    428         nit->second.it =
     440        nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end())));
     441        nit->second->it =
    429442          beach.insert(std::make_pair(Part(prev, next, nnt), nit));
    430443      } else {
Note: See TracChangeset for help on using the changeset viewer.