COIN-OR::LEMON - Graph Library

Ticket #391: 391-2-f6f2a3139f64.patch

File 391-2-f6f2a3139f64.patch, 1.7 KB (added by Peter Kovacs, 14 years ago)
  • lemon/network_simplex.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1282514892 -7200
    # Node ID f6f2a3139f64df654e708aed8dc63185a3fbf10d
    # Parent  dca9eed2c375a0121a33e12412ae4be3e6dceed5
    Improve arc mixing in NS and enable it by default (#391)
    
    diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h
    a b  
    636636    /// The constructor of the class.
    637637    ///
    638638    /// \param graph The digraph the algorithm runs on.
    639     /// \param arc_mixing Indicate if the arcs have to be stored in a
     639    /// \param arc_mixing Indicate if the arcs will be stored in a
    640640    /// mixed order in the internal data structure.
    641     /// In special cases, it could lead to better overall performance,
    642     /// but it is usually slower. Therefore it is disabled by default.
    643     NetworkSimplex(const GR& graph, bool arc_mixing = false) :
     641    /// In general, it leads to similar performance as using the original
     642    /// arc order, but it makes the algorithm more robust and for certain
     643    /// problem instances, even significantly faster.
     644    /// Therefore, it is enabled by default.
     645    NetworkSimplex(const GR& graph, bool arc_mixing = true) :
    644646      _graph(graph), _node_id(graph), _arc_id(graph),
    645647      _arc_mixing(arc_mixing),
    646648      MAX(std::numeric_limits<Value>::max()),
     
    930932      }
    931933      if (_arc_mixing) {
    932934        // Store the arcs in a mixed order
    933         int k = std::max(int(std::sqrt(double(_arc_num))), 10);
     935        int skip = int(std::sqrt(double(_arc_num * _arc_num) / _node_num));
     936        int k = std::max(skip, 3);
    934937        int i = 0, j = 0;
    935938        for (ArcIt a(_graph); a != INVALID; ++a) {
    936939          _arc_id[a] = i;