COIN-OR::LEMON - Graph Library

Changeset 987:a22b3f1bf83e in lemon


Ignore:
Timestamp:
06/25/10 06:00:56 (14 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Parents:
979:0bca98cbebbb (diff), 982:bb70ad62c95f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge bugfix #372

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/preflow.h

    r956 r985  
    577577      _phase = true;
    578578
    579       Node n = _level->highestActive();
    580       int level = _level->highestActiveLevel();
    581       while (n != INVALID) {
     579      while (true) {
    582580        int num = _node_num;
    583581
    584         while (num > 0 && n != INVALID) {
     582        Node n = INVALID;
     583        int level = -1;
     584
     585        while (num > 0) {
     586          n = _level->highestActive();
     587          if (n == INVALID) goto first_phase_done;
     588          level = _level->highestActiveLevel();
     589          --num;
     590         
    585591          Value excess = (*_excess)[n];
    586592          int new_level = _level->maxLevel();
     
    648654            _level->deactivate(n);
    649655          }
    650 
    651           n = _level->highestActive();
    652           level = _level->highestActiveLevel();
     656        }
     657
     658        num = _node_num * 20;
     659        while (num > 0) {
     660          while (level >= 0 && _level->activeFree(level)) {
     661            --level;
     662          }
     663          if (level == -1) {
     664            n = _level->highestActive();
     665            level = _level->highestActiveLevel();
     666            if (n == INVALID) goto first_phase_done;
     667          } else {
     668            n = _level->activeOn(level);
     669          }
    653670          --num;
    654         }
    655 
    656         num = _node_num * 20;
    657         while (num > 0 && n != INVALID) {
     671
    658672          Value excess = (*_excess)[n];
    659673          int new_level = _level->maxLevel();
     
    721735            _level->deactivate(n);
    722736          }
    723 
    724           while (level >= 0 && _level->activeFree(level)) {
    725             --level;
    726           }
    727           if (level == -1) {
    728             n = _level->highestActive();
    729             level = _level->highestActiveLevel();
    730           } else {
    731             n = _level->activeOn(level);
    732           }
    733           --num;
    734         }
    735       }
     737        }
     738      }
     739    first_phase_done:;
    736740    }
    737741
  • lemon/preflow.h

    r982 r985  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5353    /// The type of the map that stores the flow values.
    5454    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     55#ifdef DOXYGEN
     56    typedef GR::ArcMap<Value> FlowMap;
     57#else
    5558    typedef typename Digraph::template ArcMap<Value> FlowMap;
     59#endif
    5660
    5761    /// \brief Instantiates a FlowMap.
     
    6872    /// The elevator type used by Preflow algorithm.
    6973    ///
    70     /// \sa Elevator
    71     /// \sa LinkedElevator
    72     typedef LinkedElevator<Digraph, typename Digraph::Node> Elevator;
     74    /// \sa Elevator, LinkedElevator
     75#ifdef DOXYGEN
     76    typedef lemon::Elevator<GR, GR::Node> Elevator;
     77#else
     78    typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator;
     79#endif
    7380
    7481    /// \brief Instantiates an Elevator.
     
    96103  /// This class provides an implementation of Goldberg-Tarjan's \e preflow
    97104  /// \e push-relabel algorithm producing a \ref max_flow
    98   /// "flow of maximum value" in a digraph.
     105  /// "flow of maximum value" in a digraph \ref clrs01algorithms,
     106  /// \ref amo93networkflows, \ref goldberg88newapproach.
    99107  /// The preflow algorithms are the fastest known maximum
    100   /// flow algorithms. The current implementation use a mixture of the
     108  /// flow algorithms. The current implementation uses a mixture of the
    101109  /// \e "highest label" and the \e "bound decrease" heuristics.
    102110  /// The worst case time complexity of the algorithm is \f$O(n^2\sqrt{e})\f$.
     
    106114  /// second phase constructs a feasible maximum flow on each arc.
    107115  ///
     116  /// \warning This implementation cannot handle infinite or very large
     117  /// capacities (e.g. the maximum value of \c CAP::Value).
     118  ///
    108119  /// \tparam GR The type of the digraph the algorithm runs on.
    109120  /// \tparam CAP The type of the capacity map. The default map
    110121  /// type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
     122  /// \tparam TR The traits class that defines various types used by the
     123  /// algorithm. By default, it is \ref PreflowDefaultTraits
     124  /// "PreflowDefaultTraits<GR, CAP>".
     125  /// In most cases, this parameter should not be set directly,
     126  /// consider to use the named template parameters instead.
    111127#ifdef DOXYGEN
    112128  template <typename GR, typename CAP, typename TR>
     
    258274    /// able to automatically created by the algorithm (i.e. the
    259275    /// digraph and the maximum level should be passed to it).
    260     /// However an external elevator object could also be passed to the
     276    /// However, an external elevator object could also be passed to the
    261277    /// algorithm with the \ref elevator(Elevator&) "elevator()" function
    262278    /// before calling \ref run() or \ref init().
     
    372388    }
    373389
    374     /// \brief Sets the tolerance used by algorithm.
    375     ///
    376     /// Sets the tolerance used by algorithm.
     390    /// \brief Sets the tolerance used by the algorithm.
     391    ///
     392    /// Sets the tolerance object used by the algorithm.
     393    /// \return <tt>(*this)</tt>
    377394    Preflow& tolerance(const Tolerance& tolerance) {
    378395      _tolerance = tolerance;
     
    382399    /// \brief Returns a const reference to the tolerance.
    383400    ///
    384     /// Returns a const reference to the tolerance.
     401    /// Returns a const reference to the tolerance object used by
     402    /// the algorithm.
    385403    const Tolerance& tolerance() const {
    386404      return _tolerance;
     
    390408    /// The simplest way to execute the preflow algorithm is to use
    391409    /// \ref run() or \ref runMinCut().\n
    392     /// If you need more control on the initial solution or the execution,
    393     /// first you have to call one of the \ref init() functions, then
     410    /// If you need better control on the initial solution or the execution,
     411    /// you have to call one of the \ref init() functions first, then
    394412    /// \ref startFirstPhase() and if you need it \ref startSecondPhase().
    395413
Note: See TracChangeset for help on using the changeset viewer.