OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Private Member Functions
MCF1stPass Class Reference

First pass of the MCF calculation. More...

`#include <mcf.h>`

Inheritance diagram for MCF1stPass:

## Public Member Functions
| MCF1stPass (LinkGraphJob &job)
| Run the first pass of the MCF calculation.

## Private Member Functions
bool | EliminateCycles ()
| Eliminate all cycles in the graph.
bool | EliminateCycles (PathVector &path, NodeID origin_id, NodeID next_id)
| Eliminate cycles for origin_id in the graph.
void | EliminateCycle (PathVector &path, Path *cycle_begin, uint flow)
| Eliminate a cycle of the given flow in the given set of paths.
uint | FindCycleFlow (const PathVector &path, const Path *cycle_begin)
| Find the flow along a cycle including cycle_begin in path.

## Additional Inherited Members
Protected Member Functions inherited from MultiCommodityFlow
| MultiCommodityFlow (LinkGraphJob &job)
| Constructor.
template<class Tannotation , class Tedge_iterator >
void | Dijkstra (NodeID from, PathVector &paths)
| A slightly modified Dijkstra algorithm.
uint | PushFlow (Edge &edge, Path *path, uint accuracy, uint max_saturation)
| Push flow along a path and update the unsatisfied_demand of the associated edge.
void | CleanupPaths (NodeID source, PathVector &paths)
| Clean up paths that lead nowhere and the root path.
Protected Attributes inherited from MultiCommodityFlow
LinkGraphJob & | job
| Job we're working with.
uint | max_saturation
| Maximum saturation for edges.

## Detailed Description

First pass of the MCF calculation.

Saturates shortest paths first, creates new paths if needed, eliminates cycles. This calculation is of exponential complexity in the number of nodes but the constant factors are sufficiently small to make it usable for most real-life link graph components. You can deal with performance problems that might occur here in multiple ways:

- The overall accuracy is used here to determine how much flow is assigned in each loop. The lower the accuracy, the more flow is assigned, the less loops it takes to assign all flow.
- The short_path_saturation setting determines when this pass stops. The lower you set it, the less flow will be assigned in this pass, the less time it will take.
- You can increase the recalculation interval to allow for longer running times without creating lags.

Definition at line 50 of file mcf.h.

## Constructor & Destructor Documentation

MCF1stPass::MCF1stPass | ( | LinkGraphJob & | job | ) |

Run the first pass of the MCF calculation.

Parameters

  job | Link graph job to calculate.

Definition at line 491 of file mcf.cpp.

References LinkGraphSettings::accuracy, MultiCommodityFlow::CleanupPaths(), EliminateCycles(), Path::GetFreeCapacity(), MultiCommodityFlow::max_saturation, MultiCommodityFlow::PushFlow(), LinkGraphJob::Settings(), and LinkGraphJob::Size().

## Member Function Documentation

void MCF1stPass::EliminateCycle | ( | PathVector & | path,
|  | Path * | cycle_begin,
|  | uint | flow
| ) |  |
| private

Eliminate a cycle of the given flow in the given set of paths.

Parameters

  path | Set of paths containing the cycle.
  cycle_begin | Part of the cycle to start at.
  flow | Flow along the cycle.

Definition at line 369 of file mcf.cpp.

References Path::GetFlow(), Path::GetNode(), Path::GetParent(), MultiCommodityFlow::job, and Path::ReduceFlow().

Referenced by EliminateCycles().

bool MCF1stPass::EliminateCycles | ( |  | ) |
| private

Eliminate all cycles in the graph.

Check paths starting at each node for potential cycles.

Returns
  If any cycles have been found and eliminated.

Definition at line 473 of file mcf.cpp.

References MultiCommodityFlow::job, and LinkGraphJob::Size().

Referenced by EliminateCycles(), and MCF1stPass().

bool MCF1stPass::EliminateCycles | ( | PathVector & | path,
|  | NodeID | origin_id,
|  | NodeID | next_id
| ) |  |
| private

Eliminate cycles for origin_id in the graph.

Start searching at next_id and work recursively. Also "summarize" paths: Add up the flows along parallel paths in one.

Parameters

  path | Paths checked in parent calls to this method.
  origin_id | Origin of the paths to be checked.
  next_id | Next node to be checked.

Returns
  If any cycles have been found and eliminated.

Definition at line 400 of file mcf.cpp.

References Path::AddFlow(), EliminateCycle(), EliminateCycles(), FindCycleFlow(), Path::GetFlow(), Path::GetNode(), Path::GetOrigin(), Path::invalid_path, MultiCommodityFlow::job, and Path::ReduceFlow().

uint MCF1stPass::FindCycleFlow | ( | const PathVector & | path,
|  | const Path * | cycle_begin
| ) |  |
| private

Find the flow along a cycle including cycle_begin in path.

Parameters

  path | Set of paths that form the cycle.
  cycle_begin | Path to start at.

Returns
  Flow along the cycle.

Definition at line 352 of file mcf.cpp.

References Path::GetFlow(), and min().

Referenced by EliminateCycles().

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

- src/linkgraph/mcf.h
- src/linkgraph/mcf.cpp