OpenTTD Source  20240919-master-gdf0233f4c2
DemandCalculator Class Reference

Calculate the demands. More...

#include <demands.h>

Public Member Functions

 DemandCalculator (LinkGraphJob &job)
 Create the DemandCalculator and immediately do the calculation. More...
 

Private Member Functions

template<class Tscaler >
void CalcDemand (LinkGraphJob &job, Tscaler scaler)
 Do the actual demand calculation, called from constructor. More...
 

Private Attributes

int32_t base_distance
 Base distance for scaling purposes.
 
int32_t mod_dist
 Distance modifier, determines how much demands decrease with distance.
 
int32_t accuracy
 Accuracy of the calculation.
 

Detailed Description

Calculate the demands.

This class has a state, but is recreated for each call to of DemandHandler::Run.

Definition at line 12 of file demands.h.

Constructor & Destructor Documentation

◆ DemandCalculator()

DemandCalculator::DemandCalculator ( LinkGraphJob job)

Create the DemandCalculator and immediately do the calculation.

Parameters
jobJob to calculate the demands for.

Definition at line 262 of file demands.cpp.

References accuracy, LinkGraphSettings::accuracy, LinkGraphJob::Cargo(), LinkGraphSettings::demand_distance, DT_ASYMMETRIC, DT_SYMMETRIC, mod_dist, settings, and LinkGraphJob::Settings().

Member Function Documentation

◆ CalcDemand()

template<class Tscaler >
void DemandCalculator::CalcDemand ( LinkGraphJob job,
Tscaler  scaler 
)
private

Do the actual demand calculation, called from constructor.

Parameters
jobJob to calculate the demands for.
Template Parameters
TscalerScaler to be used for scaling demands.

Definition at line 165 of file demands.cpp.

References accuracy, base_distance, DistanceMaxPlusManhattan(), mod_dist, and LinkGraphJob::Size().


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