OpenTTD Source  20240919-master-gdf0233f4c2
mcf.h
Go to the documentation of this file.
1 
3 #ifndef MCF_H
4 #define MCF_H
5 
6 #include "linkgraphjob_base.h"
7 
8 typedef std::vector<Path *> PathVector;
9 
14 protected:
20  max_saturation(job.Settings().short_path_saturation)
21  {}
22 
23  template<class Tannotation, class Tedge_iterator>
24  void Dijkstra(NodeID from, PathVector &paths);
25 
26  uint PushFlow(Node &node, NodeID to, Path *path, uint accuracy, uint max_saturation);
27 
28  void CleanupPaths(NodeID source, PathVector &paths);
29 
32 };
33 
50 private:
51  bool EliminateCycles();
52  bool EliminateCycles(PathVector &path, NodeID origin_id, NodeID next_id);
53  void EliminateCycle(PathVector &path, Path *cycle_begin, uint flow);
54  uint FindCycleFlow(const PathVector &path, const Path *cycle_begin);
55 public:
57 };
58 
67 public:
69 };
70 
75 template<class Tpass>
76 class MCFHandler : public ComponentHandler {
77 public:
78 
83  void Run(LinkGraphJob &job) const override { Tpass pass(job); }
84 };
85 
86 #endif /* MCF_H */
Path
A leg of a path in the link graph.
Definition: linkgraphjob.h:275
MultiCommodityFlow::max_saturation
uint max_saturation
Maximum saturation for edges.
Definition: mcf.h:31
linkgraphjob_base.h
MCF2ndPass::MCF2ndPass
MCF2ndPass(LinkGraphJob &job)
Run the second pass of the MCF calculation which assigns all remaining demands to existing paths.
Definition: mcf.cpp:547
LinkGraphJob
Class for calculation jobs to be run on link graphs.
Definition: linkgraphjob.h:29
MultiCommodityFlow::MultiCommodityFlow
MultiCommodityFlow(LinkGraphJob &job)
Constructor.
Definition: mcf.h:19
MCF1stPass
First pass of the MCF calculation.
Definition: mcf.h:49
ComponentHandler
A handler doing "something" on a link graph component.
Definition: linkgraphschedule.h:21
MultiCommodityFlow::CleanupPaths
void CleanupPaths(NodeID source, PathVector &paths)
Clean up paths that lead nowhere and the root path.
Definition: mcf.cpp:312
MCF2ndPass
Second pass of the MCF calculation.
Definition: mcf.h:66
MCF1stPass::EliminateCycles
bool EliminateCycles()
Eliminate all cycles in the graph.
Definition: mcf.cpp:481
MCF1stPass::MCF1stPass
MCF1stPass(LinkGraphJob &job)
Run the first pass of the MCF calculation.
Definition: mcf.cpp:499
MCF1stPass::EliminateCycle
void EliminateCycle(PathVector &path, Path *cycle_begin, uint flow)
Eliminate a cycle of the given flow in the given set of paths.
Definition: mcf.cpp:377
MultiCommodityFlow::Dijkstra
void Dijkstra(NodeID from, PathVector &paths)
A slightly modified Dijkstra algorithm.
Definition: mcf.cpp:257
MCFHandler::Run
void Run(LinkGraphJob &job) const override
Run the calculation.
Definition: mcf.h:83
MCFHandler
Link graph handler for MCF.
Definition: mcf.h:76
MultiCommodityFlow::job
LinkGraphJob & job
Job we're working with.
Definition: mcf.h:30
MCF1stPass::FindCycleFlow
uint FindCycleFlow(const PathVector &path, const Path *cycle_begin)
Find the flow along a cycle including cycle_begin in path.
Definition: mcf.cpp:360
LinkGraph::BaseNode
Node of the link graph.
Definition: linkgraph.h:90
MultiCommodityFlow::PushFlow
uint PushFlow(Node &node, NodeID to, Path *path, uint accuracy, uint max_saturation)
Push flow along a path and update the unsatisfied_demand of the associated edge.
Definition: mcf.cpp:344
MultiCommodityFlow
Multi-commodity flow calculating base class.
Definition: mcf.h:13