OpenTTD Source 20241224-master-gf74b0cf984
|
A leg of a path in the link graph. More...
#include <linkgraphjob.h>
Public Member Functions | |
Path (NodeID n, bool source=false) | |
Create a leg of a path in the link graph. | |
NodeID | GetNode () const |
Get the node this leg passes. | |
NodeID | GetOrigin () const |
Get the overall origin of the path. | |
Path * | GetParent () |
Get the parent leg of this one. | |
uint | GetCapacity () const |
Get the overall capacity of the path. | |
int | GetFreeCapacity () const |
Get the free capacity of the path. | |
int | GetCapacityRatio () const |
Get capacity ratio of this path. | |
uint | GetDistance () const |
Get the overall distance of the path. | |
void | ReduceFlow (uint f) |
Reduce the flow on this leg only by the specified amount. | |
void | AddFlow (uint f) |
Increase the flow on this leg only by the specified amount. | |
uint | GetFlow () const |
Get the flow on this leg. | |
uint | GetNumChildren () const |
Get the number of "forked off" child legs of this one. | |
void | Detach () |
Detach this path from its parent. | |
uint | AddFlow (uint f, LinkGraphJob &job, uint max_saturation) |
Push some flow along a path and register the path in the nodes it passes if successful. | |
void | Fork (Path *base, uint cap, int free_cap, uint dist) |
Add this path as a new child to the given base path, thus making this path a "fork" of the base path. | |
Static Public Member Functions | |
static int | GetCapacityRatio (int free, uint total) |
Get ratio of free * 16 (so that we get fewer 0) / max(total capacity, 1) (so that we don't divide by 0). | |
Static Public Attributes | |
static Path * | invalid_path = new Path(INVALID_NODE, true) |
Static instance of an invalid path. | |
Protected Attributes | |
uint | distance |
Sum(distance of all legs up to this one). | |
uint | capacity |
This capacity is min(capacity) fom all edges. | |
int | free_capacity |
This capacity is min(edge.capacity - edge.flow) for the current run of Dijkstra. | |
uint | flow |
Flow the current run of the mcf solver assigns. | |
NodeID | node |
Link graph node this leg passes. | |
NodeID | origin |
Link graph node this path originates from. | |
uint | num_children |
Number of child legs that have been forked from this path. | |
Path * | parent |
Parent leg of this one. | |
Static Protected Attributes | |
static constexpr int | PATH_CAP_MULTIPLIER = 16 |
static constexpr int | PATH_CAP_MIN_FREE = (INT_MIN + 1) / PATH_CAP_MULTIPLIER |
static constexpr int | PATH_CAP_MAX_FREE = (INT_MAX - 1) / PATH_CAP_MULTIPLIER |
A leg of a path in the link graph.
Paths can form trees by being "forked".
Definition at line 275 of file linkgraphjob.h.
Path::Path | ( | NodeID | n, |
bool | source = false |
||
) |
Create a leg of a path in the link graph.
n | Id of the link graph node this path passes. |
source | If true, this is the first leg of the path. |
Definition at line 248 of file linkgraphjob.cpp.
|
inline |
Increase the flow on this leg only by the specified amount.
Definition at line 325 of file linkgraphjob.h.
References flow.
Referenced by AddFlow(), MCF1stPass::EliminateCycles(), and MultiCommodityFlow::PushFlow().
uint Path::AddFlow | ( | uint | new_flow, |
LinkGraphJob & | job, | ||
uint | max_saturation | ||
) |
Push some flow along a path and register the path in the nodes it passes if successful.
new_flow | Amount of flow to push. |
job | Link graph job this node belongs to. |
max_saturation | Maximum saturation of edges. |
Definition at line 221 of file linkgraphjob.cpp.
References AddFlow(), LinkGraphJob::EdgeAnnotation::AddFlow(), LinkGraphJob::EdgeAnnotation::base, LinkGraph::BaseEdge::capacity, LinkGraphJob::EdgeAnnotation::Flow(), flow, node, and parent.
|
inline |
Detach this path from its parent.
Definition at line 336 of file linkgraphjob.h.
References num_children, and parent.
Referenced by MultiCommodityFlow::CleanupPaths(), and Fork().
void Path::Fork | ( | Path * | base, |
uint | cap, | ||
int | free_cap, | ||
uint | dist | ||
) |
Add this path as a new child to the given base path, thus making this path a "fork" of the base path.
base | Path to fork from. |
cap | Maximum capacity of the new leg. |
free_cap | Remaining free capacity of the new leg. |
dist | Distance of the new leg. |
Definition at line 199 of file linkgraphjob.cpp.
References capacity, Detach(), distance, free_capacity, num_children, origin, and parent.
|
inline |
Get the overall capacity of the path.
Definition at line 292 of file linkgraphjob.h.
References capacity.
|
inline |
Get capacity ratio of this path.
Definition at line 313 of file linkgraphjob.h.
References capacity, free_capacity, and GetCapacityRatio().
Referenced by GetCapacityRatio(), CapacityAnnotation::IsBetter(), and CapacityAnnotation::UpdateAnnotation().
|
inlinestatic |
Get ratio of free * 16 (so that we get fewer 0) / max(total capacity, 1) (so that we don't divide by 0).
free | Free capacity. |
total | Total capacity. |
Definition at line 304 of file linkgraphjob.h.
|
inline |
Get the overall distance of the path.
Definition at line 319 of file linkgraphjob.h.
References distance.
|
inline |
Get the flow on this leg.
Definition at line 328 of file linkgraphjob.h.
References flow.
Referenced by MultiCommodityFlow::CleanupPaths(), MCF1stPass::EliminateCycle(), MCF1stPass::EliminateCycles(), and MCF1stPass::FindCycleFlow().
|
inline |
Get the free capacity of the path.
Definition at line 295 of file linkgraphjob.h.
References free_capacity.
Referenced by MCF1stPass::MCF1stPass(), and MCF2ndPass::MCF2ndPass().
|
inline |
Get the node this leg passes.
Definition at line 283 of file linkgraphjob.h.
References node.
Referenced by MultiCommodityFlow::CleanupPaths(), MCF1stPass::EliminateCycle(), MCF1stPass::EliminateCycles(), and MCF1stPass::FindCycleFlow().
|
inline |
Get the number of "forked off" child legs of this one.
Definition at line 331 of file linkgraphjob.h.
References num_children.
Referenced by MultiCommodityFlow::CleanupPaths().
|
inline |
Get the overall origin of the path.
Definition at line 286 of file linkgraphjob.h.
References origin.
Referenced by MCF1stPass::EliminateCycles().
|
inline |
Get the parent leg of this one.
Definition at line 289 of file linkgraphjob.h.
References parent.
Referenced by MultiCommodityFlow::CleanupPaths(), and MCF1stPass::EliminateCycle().
|
inline |
Reduce the flow on this leg only by the specified amount.
Definition at line 322 of file linkgraphjob.h.
References flow.
Referenced by MCF1stPass::EliminateCycle(), and MCF1stPass::EliminateCycles().
|
protected |
This capacity is min(capacity) fom all edges.
Definition at line 357 of file linkgraphjob.h.
Referenced by Fork(), GetCapacity(), GetCapacityRatio(), and CapacityAnnotation::IsBetter().
|
protected |
Sum(distance of all legs up to this one).
Definition at line 356 of file linkgraphjob.h.
Referenced by Fork(), DistanceAnnotation::GetAnnotation(), GetDistance(), CapacityAnnotation::IsBetter(), and DistanceAnnotation::IsBetter().
|
protected |
Flow the current run of the mcf solver assigns.
Definition at line 359 of file linkgraphjob.h.
Referenced by AddFlow(), AddFlow(), GetFlow(), and ReduceFlow().
|
protected |
This capacity is min(edge.capacity - edge.flow) for the current run of Dijkstra.
Definition at line 358 of file linkgraphjob.h.
Referenced by Fork(), GetCapacityRatio(), GetFreeCapacity(), CapacityAnnotation::IsBetter(), and DistanceAnnotation::IsBetter().
Static instance of an invalid path.
Note: This instance is created on task start. Lazy creation on first usage results in a data race between the CDist threads.
Definition at line 277 of file linkgraphjob.h.
Referenced by MCF1stPass::EliminateCycles().
|
protected |
Link graph node this leg passes.
Definition at line 360 of file linkgraphjob.h.
|
protected |
Number of child legs that have been forked from this path.
Definition at line 362 of file linkgraphjob.h.
Referenced by Detach(), Fork(), and GetNumChildren().
|
protected |
Link graph node this path originates from.
Definition at line 361 of file linkgraphjob.h.
Referenced by Fork(), and GetOrigin().
|
protected |
Parent leg of this one.
Definition at line 363 of file linkgraphjob.h.
Referenced by AddFlow(), Detach(), Fork(), and GetParent().
|
staticconstexprprotected |
Definition at line 354 of file linkgraphjob.h.
|
staticconstexprprotected |
Definition at line 353 of file linkgraphjob.h.
|
staticconstexprprotected |
Definition at line 352 of file linkgraphjob.h.