OpenTTD Source: SymmetricScaler Class Reference

OpenTTD Source 15.0-beta1

Public Member Functions | Private Attributes
SymmetricScaler Class Reference

Scaler for symmetric distribution. More...

Inheritance diagram for SymmetricScaler:

## Public Member Functions
| SymmetricScaler (uint mod_size)
| Constructor.
void | AddNode (const Node &node)
| Count a node's supply into the sum of supplies.
void | SetDemandPerNode (uint num_demands)
| Calculate the mean demand per node using the sum of supplies.
uint | EffectiveSupply (const Node &from, const Node &to)
| Get the effective supply of one node towards another one.
bool | HasDemandLeft (const Node &to)
| Check if there is any acceptance left for this node.
void | SetDemands (LinkGraphJob &job, NodeID from, NodeID to, uint demand_forw)
| Set the demands between two nodes using the given base demand.
Public Member Functions inherited from Scaler
void | SetDemands (LinkGraphJob &job, NodeID from, NodeID to, uint demand_forw)
| Set the demands between two nodes using the given base demand.

## Private Attributes
uint | mod_size
| Size modifier. Determines how much demands increase with the supply of the remote station.
uint | supply_sum
| Sum of all supplies in the component.
uint | demand_per_node
| Mean demand associated with each node.

## Detailed Description

Scaler for symmetric distribution.

Definition at line 23 of file demands.cpp.

## Constructor & Destructor Documentation

## ◆ SymmetricScaler()

SymmetricScaler::SymmetricScaler | ( | uint | mod_size | ) |
| inline

Constructor.

Parameters

  mod_size | Size modifier to be used. Determines how much demands increase with the supply of the remote station.

Definition at line 30 of file demands.cpp.

## Member Function Documentation

## ◆ AddNode()

void SymmetricScaler::AddNode | ( | const Node & | node | ) |
| inline

Count a node's supply into the sum of supplies.

Parameters

  node | Node.

Definition at line 38 of file demands.cpp.

References LinkGraph::BaseNode::supply, and supply_sum.

## ◆ EffectiveSupply()

uint SymmetricScaler::EffectiveSupply | ( | const Node & | from,
|  | const Node & | to
| ) |  |
| inline

Get the effective supply of one node towards another one.

In symmetric distribution the supply of the other node is weighed in.

Parameters

  from | The supplying node.
  to | The receiving node.

Returns
  Effective supply.

Definition at line 59 of file demands.cpp.

References LinkGraph::BaseNode::supply.

## ◆ HasDemandLeft()

bool SymmetricScaler::HasDemandLeft | ( | const Node & | to | ) |
| inline

Check if there is any acceptance left for this node.

In symmetric distribution nodes only accept anything if they also supply something. So if undelivered_supply == 0 at the node there isn't any demand left either.

Parameters

  to | Node to be checked.

Returns
  If demand is left.

Definition at line 71 of file demands.cpp.

References LinkGraph::BaseNode::demand, and LinkGraph::BaseNode::supply.

## ◆ SetDemandPerNode()

void SymmetricScaler::SetDemandPerNode | ( | uint | num_demands | ) |
| inline

Calculate the mean demand per node using the sum of supplies.

Parameters

  num_demands | Number of accepting nodes.

Definition at line 47 of file demands.cpp.

References demand_per_node, and supply_sum.

## ◆ SetDemands()

void SymmetricScaler::SetDemands | ( | LinkGraphJob & | job,
|  | NodeID | from_id,
|  | NodeID | to_id,
|  | uint | demand_forw
| ) |  |

Set the demands between two nodes using the given base demand.

In symmetric mode this sets demands in both directions.

Parameters

  job | The link graph job.
  from_id | The supplying node.
  to_id | The receiving node.
  demand_forw | Demand calculated for the "forward" direction.

Definition at line 131 of file demands.cpp.

References mod_size, and Scaler::SetDemands().

## Field Documentation

## ◆ demand_per_node

uint SymmetricScaler::demand_per_node
| private

Mean demand associated with each node.

Definition at line 81 of file demands.cpp.

Referenced by SetDemandPerNode().

## ◆ mod_size

uint SymmetricScaler::mod_size
| private

Size modifier. Determines how much demands increase with the supply of the remote station.

Definition at line 79 of file demands.cpp.

Referenced by SetDemands().

## ◆ supply_sum

uint SymmetricScaler::supply_sum
| private

Sum of all supplies in the component.

Definition at line 80 of file demands.cpp.

Referenced by AddNode(), and SetDemandPerNode().

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

- src/linkgraph/demands.cpp