NetworkSimplex Class Template Reference
[Minimum Cost Flow algorithms]

#include <lemon/network_simplex.h>

Inheritance diagram for NetworkSimplex:

Inheritance graph
[legend]

List of all members.


Detailed Description

template<typename Graph, typename LowerMap = typename Graph::template EdgeMap<int>, typename CapacityMap = typename Graph::template EdgeMap<int>, typename CostMap = typename Graph::template EdgeMap<int>, typename SupplyMap = typename Graph::template NodeMap<int>>
class lemon::NetworkSimplex< Graph, LowerMap, CapacityMap, CostMap, SupplyMap >

NetworkSimplex implements the network simplex algorithm for finding a minimum cost flow.

Template Parameters:
Graph The directed graph type the algorithm runs on.
LowerMap The type of the lower bound map.
CapacityMap The type of the capacity (upper bound) map.
CostMap The type of the cost (length) map.
SupplyMap The type of the supply map.
Warning:
  • Edge capacities and costs should be non-negative integers.
  • Supply values should be signed integers.
  • The value types of the maps should be convertible to each other.
  • CostMap::Value must be signed type.
Note:
NetworkSimplex provides six different pivot rule implementations that significantly affect the efficiency of the algorithm. By default a combined pivot rule is used, which is the fastest implementation according to our benchmark tests. Another pivot rule can be selected using run() function with the proper parameter.
Author:
Peter Kovacs

Public Types

enum  PivotRuleEnum
 Enum type to select the pivot rule used by run().
typedef Graph::template
EdgeMap< Capacity > 
FlowMap
 The type of the flow map.
typedef Graph::template
NodeMap< Cost > 
PotentialMap
 The type of the potential map.

Public Member Functions

 NetworkSimplex (const Graph &graph, const LowerMap &lower, const CapacityMap &capacity, const CostMap &cost, const SupplyMap &supply)
 General constructor (with lower bounds).
 NetworkSimplex (const Graph &graph, const CapacityMap &capacity, const CostMap &cost, const SupplyMap &supply)
 General constructor (without lower bounds).
 NetworkSimplex (const Graph &graph, const LowerMap &lower, const CapacityMap &capacity, const CostMap &cost, typename Graph::Node s, typename Graph::Node t, typename SupplyMap::Value flow_value)
 Simple constructor (with lower bounds).
 NetworkSimplex (const Graph &graph, const CapacityMap &capacity, const CostMap &cost, typename Graph::Node s, typename Graph::Node t, typename SupplyMap::Value flow_value)
 Simple constructor (without lower bounds).
 ~NetworkSimplex ()
 Destructor.
NetworkSimplexflowMap (FlowMap &map)
 Sets the flow map.
NetworkSimplexpotentialMap (PotentialMap &map)
 Sets the potential map.
Execution control
The only way to execute the algorithm is to call the run() function.

bool run (PivotRuleEnum pivot_rule=COMBINED_PIVOT)
 Runs the algorithm.
Query Functions
The result of the algorithm can be obtained using these functions.
run() must be called before using them.

const FlowMapflowMap () const
 Returns a const reference to the edge map storing the found flow.
const PotentialMappotentialMap () const
 Returns a const reference to the node map storing the found potentials (the dual solution).
Capacity flow (const typename Graph::Edge &edge) const
 Returns the flow on the given edge.
Cost potential (const typename Graph::Node &node) const
 Returns the potential of the given node.
Cost totalCost () const
 Returns the total cost of the found flow.

Private Member Functions

bool init ()
 Extends the underlaying graph and initializes all the node and edge maps.
Node findJoinNode ()
 Finds the join node.
bool findLeavingEdge ()
 Finds the leaving edge of the cycle. Returns true if the leaving edge is not the same as the entering edge.
void changeFlows (bool change)
 Changes flow and state edge maps.
void updateThreadParent ()
 Updates thread and parent node maps.
void updatePredEdge ()
 Updates pred_edge and forward node maps.
void updateDepthPotential ()
 Updates depth and potential node maps.
bool start (PivotRuleEnum pivot_rule)
 Executes the algorithm.

Classes

class  BestEligiblePivotRule
 Implementation of the "Best Eligible" pivot rule for the network simplex algorithm. More...
class  BlockSearchPivotRule
 Implementation of the "Block Search" pivot rule for the network simplex algorithm. More...
class  CandidateListPivotRule
 Implementation of the "Candidate List" pivot rule for the network simplex algorithm. More...
class  FirstEligiblePivotRule
 Implementation of the "First Eligible" pivot rule for the network simplex algorithm. More...
class  LimitedSearchPivotRule
 Implementation of the "Limited Search" pivot rule for the network simplex algorithm. More...
class  ReducedCostMap
 Map adaptor class for handling reduced edge costs. More...

Constructor & Destructor Documentation

NetworkSimplex ( const Graph graph,
const LowerMap &  lower,
const CapacityMap &  capacity,
const CostMap &  cost,
const SupplyMap &  supply 
) [inline]

General constructor (with lower bounds).

Parameters:
graph The directed graph the algorithm runs on.
lower The lower bounds of the edges.
capacity The capacities (upper bounds) of the edges.
cost The cost (length) values of the edges.
supply The supply values of the nodes (signed).

NetworkSimplex ( const Graph graph,
const CapacityMap &  capacity,
const CostMap &  cost,
const SupplyMap &  supply 
) [inline]

General constructor (without lower bounds).

Parameters:
graph The directed graph the algorithm runs on.
capacity The capacities (upper bounds) of the edges.
cost The cost (length) values of the edges.
supply The supply values of the nodes (signed).

NetworkSimplex ( const Graph graph,
const LowerMap &  lower,
const CapacityMap &  capacity,
const CostMap &  cost,
typename Graph::Node  s,
typename Graph::Node  t,
typename SupplyMap::Value  flow_value 
) [inline]

Simple constructor (with lower bounds).

Parameters:
graph The directed graph the algorithm runs on.
lower The lower bounds of the edges.
capacity The capacities (upper bounds) of the edges.
cost The cost (length) values of the edges.
s The source node.
t The target node.
flow_value The required amount of flow from node s to node t (i.e. the supply of s and the demand of t).

NetworkSimplex ( const Graph graph,
const CapacityMap &  capacity,
const CostMap &  cost,
typename Graph::Node  s,
typename Graph::Node  t,
typename SupplyMap::Value  flow_value 
) [inline]

Simple constructor (without lower bounds).

Parameters:
graph The directed graph the algorithm runs on.
capacity The capacities (upper bounds) of the edges.
cost The cost (length) values of the edges.
s The source node.
t The target node.
flow_value The required amount of flow from node s to node t (i.e. the supply of s and the demand of t).


Member Function Documentation

NetworkSimplex& flowMap ( FlowMap map  )  [inline]

Sets the flow map.

Returns:
(*this)

NetworkSimplex& potentialMap ( PotentialMap map  )  [inline]

Sets the potential map.

Returns:
(*this)

bool run ( PivotRuleEnum  pivot_rule = COMBINED_PIVOT  )  [inline]

Runs the algorithm.

Parameters:
pivot_rule The pivot rule that is used during the algorithm.
The available pivot rules:

  • FIRST_ELIGIBLE_PIVOT The next eligible edge is selected in a wraparound fashion in every iteration (FirstEligiblePivotRule).

  • BLOCK_SEARCH_PIVOT A specified number of edges are examined in every iteration in a wraparound fashion and the best eligible edge is selected from this block (BlockSearchPivotRule).

  • LIMITED_SEARCH_PIVOT A specified number of eligible edges are examined in every iteration in a wraparound fashion and the best one is selected from them (LimitedSearchPivotRule).

  • CANDIDATE_LIST_PIVOT In major iterations a candidate list is built from eligible edges and it is used for edge selection in the following minor iterations (CandidateListPivotRule).

  • COMBINED_PIVOT This is a combined version of the two fastest pivot rules. For rather sparse graphs Limited Search implementation is used, otherwise Block Search pivot rule is used. According to our benchmark tests this combined method is the most efficient.

Returns:
true if a feasible flow can be found.

const FlowMap& flowMap (  )  const [inline]

Returns a const reference to the edge map storing the found flow.

Precondition:
run() must be called before using this function.

const PotentialMap& potentialMap (  )  const [inline]

Returns a const reference to the node map storing the found potentials (the dual solution).

Precondition:
run() must be called before using this function.

Capacity flow ( const typename Graph::Edge &  edge  )  const [inline]

Returns the flow on the given edge.

Precondition:
run() must be called before using this function.

Cost potential ( const typename Graph::Node &  node  )  const [inline]

Returns the potential of the given node.

Precondition:
run() must be called before using this function.

Cost totalCost (  )  const [inline]

Returns the total cost of the found flow. The complexity of the function is $ O(e) $.

Precondition:
run() must be called before using this function.


The documentation for this class was generated from the following file:

Generated on Sat Apr 19 14:21:10 2008 for LEMON by  doxygen 1.5.5