OpenTTD Source  1.11.2
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 #include <vector>
8 
9 typedef std::vector<Path *> PathVector;
10 
15 protected:
21  max_saturation(job.Settings().short_path_saturation)
22  {}
23 
24  template<class Tannotation, class Tedge_iterator>
25  void Dijkstra(NodeID from, PathVector &paths);
26 
27  uint PushFlow(Edge &edge, Path *path, uint accuracy, uint max_saturation);
28 
29  void CleanupPaths(NodeID source, PathVector &paths);
30 
33 };
34 
51 private:
52  bool EliminateCycles();
53  bool EliminateCycles(PathVector &path, NodeID origin_id, NodeID next_id);
54  void EliminateCycle(PathVector &path, Path *cycle_begin, uint flow);
55  uint FindCycleFlow(const PathVector &path, const Path *cycle_begin);
56 public:
58 };
59 
68 public:
70 };
71 
76 template<class Tpass>
77 class MCFHandler : public ComponentHandler {
78 public:
79 
84  virtual void Run(LinkGraphJob &job) const { Tpass pass(job); }
85 
89  virtual ~MCFHandler() {}
90 };
91 
92 #endif /* MCF_H */
Path
A leg of a path in the link graph.
Definition: linkgraphjob.h:365
MultiCommodityFlow::max_saturation
uint max_saturation
Maximum saturation for edges.
Definition: mcf.h:32
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:539
MCFHandler::Run
virtual void Run(LinkGraphJob &job) const
Run the calculation.
Definition: mcf.h:84
LinkGraphJob
Class for calculation jobs to be run on link graphs.
Definition: linkgraphjob.h:30
MultiCommodityFlow::MultiCommodityFlow
MultiCommodityFlow(LinkGraphJob &job)
Constructor.
Definition: mcf.h:20
MCF1stPass
First pass of the MCF calculation.
Definition: mcf.h:50
LinkGraph::Edge
An updatable edge class.
Definition: linkgraph.h:292
ComponentHandler
A handler doing "something" on a link graph component.
Definition: linkgraphschedule.h:21
MultiCommodityFlow::PushFlow
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.
Definition: mcf.cpp:336
MultiCommodityFlow::CleanupPaths
void CleanupPaths(NodeID source, PathVector &paths)
Clean up paths that lead nowhere and the root path.
Definition: mcf.cpp:305
MCF2ndPass
Second pass of the MCF calculation.
Definition: mcf.h:67
MCF1stPass::EliminateCycles
bool EliminateCycles()
Eliminate all cycles in the graph.
Definition: mcf.cpp:473
MCFHandler::~MCFHandler
virtual ~MCFHandler()
Destructor.
Definition: mcf.h:89
MCF1stPass::MCF1stPass
MCF1stPass(LinkGraphJob &job)
Run the first pass of the MCF calculation.
Definition: mcf.cpp:491
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:369
MultiCommodityFlow::Dijkstra
void Dijkstra(NodeID from, PathVector &paths)
A slightly modified Dijkstra algorithm.
Definition: mcf.cpp:259
MCFHandler
Link graph handler for MCF.
Definition: mcf.h:77
MultiCommodityFlow::job
LinkGraphJob & job
Job we're working with.
Definition: mcf.h:31
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:352
MultiCommodityFlow
Multi-commodity flow calculating base class.
Definition: mcf.h:14