traffic_demand_calculation

common

class ArgDefaultDict

Bases: defaultdict

class Contributor

Bases: object

class DemandEstimation(global_params: Sequence[GlobalContributor] = (), local_params: Sequence[LocalContributor] = ())

Bases: object

close()
initialize(mapper: LocalMapper)
setup(*, state: TrackedState, settings: Settings, schema: AttributeSchema, logger: Logger)
update(matrix: ndarray, force_update: bool = False, *, moment: Moment) ndarray
class GlobalContributor(parameter: str, csv_tape: CsvTape)

Bases: Contributor

get_value()
has_changes()
update_factor(factor: float, *, moment: Moment) float
class LocalContributor

Bases: Contributor

close()
has_changes()
initialize(mapper: LocalMapper)
setup(*, state: TrackedState, settings: Settings, schema: AttributeSchema, logger: Logger)
update_demand(matrix: ndarray, force_update: bool = False, *, moment: Moment)
class LocalMapper(demand_geometry: Geometry)

Bases: object

get_nearest(target_entities) ndarray

The resulting array length matches the demand entities, the values match indices in the target entity group

global_contributors

class GlobalElasticityParameter(parameter: str, csv_tape: CsvTape, elasticity: float)

Bases: GlobalContributor

Formulation: F_ij = (GP_n / GP_(n-1))_i ** (eta) * (GP_n / GP_(n-1))_j ** (eta)

F_ij: Multiplication factor for demand from node i to node j GP: Global Parameter n: iteration number (eg: year) eta: elasticity

get_factor(value)
reset_value()
update_factor(factor: float, **_) float
class ScalarParameter(parameter: str, csv_tape: CsvTape)

Bases: GlobalContributor

update_factor(factor: float, **_) float

local_contributors

class Investment(seconds, entity_id, multiplier)

Bases: NamedTuple

entity_id: int

Alias for field number 1

multiplier: float

Alias for field number 2

seconds: int

Alias for field number 0

class InvestmentContributor(investments: Sequence[Investment], demand_node_index: Index)

Bases: LocalContributor

investments: List[Investment]
update_demand(matrix: ndarray, force_update: bool = False, *, moment: Moment)
class LocalEffectsContributor(info: LocalParameterInfo)

Bases: LocalContributor

calculate_contribution(new_values, old_values)

Calculate the contribution (P_ij/P_ij_old)**elasticity to the demand change factor

calculate_values()

Calculate parameter values P[] so that P_ij can be reconstructed, this can be a 1d-array which together with self._indices can reconstruct P_ij (See eg. NearestValue) or a 2d-array containing every P_ij (See RouteCostFactor). P_ij will then be used to calculate the contribution (P_ij/P_ij_old)**elasticity to the demand change factor

has_changes() bool
old_value: ndarray | None = None
update_demand(matrix: ndarray, force_update: bool = False, **_) ndarray
class LocalParameterInfo(target_dataset: str, target_entity_group: str, target_geometry: str, target_attribute: movici_simulation_core.core.attribute.UniformAttribute | movici_simulation_core.core.attribute.CSRAttribute, elasticity: float)

Bases: object

elasticity: float
target_attribute: UniformAttribute | CSRAttribute
target_dataset: str
target_entity_group: str
target_geometry: str
class NearestValue(info: LocalParameterInfo)

Bases: LocalEffectsContributor

calculate_contribution(new_values, old_values)
calculate_values()
initialize(mapper: LocalMapper)
setup(state: TrackedState, **_)
class RouteCostFactor(info: LocalParameterInfo)

Bases: LocalEffectsContributor, ShortestPathMixin

This effect calculator computes the paths between pairs of demand nodes connected by a route. It calculates the sum of the given _attribute on this route and returns that.

calculate_values()
initialize(mapper: LocalMapper)
setup(*, state: TrackedState, logger: Logger, **_)
class ShortestPathMixin

Bases: object

static deduplicate_nodes(meth)

When mapping a demand OD matrix onto a target network, such as the effect of travel time on roads (target network) on the waterway demand (demand OD matrix). There may be duplicate mapped road virtual nodes, since this is an N -> M mapping, where M <= N. As an optimization, these duplicates can be detected by this decorator, and only the unique indices are passed to the decorated method as the first positional argument after self. The decorated method is expected to return a MxM matrix and this decorator expands it back to NxN

This only works for methods in classes that inherit from LocalEffectsContributor

initialize_network()
setup_state(state: TrackedState, info: LocalParameterInfo)
calculate_localized_contribution_1d(values, old_values, indices, elasticity)
get_ratio_for_node(node_i, values, old_values, indices)

model

class TrafficDemandCalculation(model_config: dict)

Bases: TrackedModel

Implementation of the demand estimation model. Reads a csv with scenario parameters. Calculates changes in the od matrices based on change of scenario parameters in time.

Asgarpour, S., Konstantinos, K., Hartmann, A., and Neef, R. (2021). Modeling interdependent infrastructures under future scenarios. Work in Progress.

auto_reset = 8
configure_demand_nodes(state: TrackedState, schema: AttributeSchema)
demand_estimation: DemandEstimation
get_global_elasticity_contributors(data_handler: InitDataHandler) List[GlobalContributor]
static get_global_parameters_tape(data_handler: InitDataHandler, name: str) CsvTape
get_investment_contributors()
get_local_contributors(state: TrackedState, schema: AttributeSchema) List[LocalContributor]
get_scenario_multipliers()
initialize(state: TrackedState)
new_time(state: TrackedState, moment: Moment)
proceed_tape(moment: Moment)
setup(state: TrackedState, settings: Settings, schema: AttributeSchema, init_data_handler: InitDataHandler, logger: Logger, **_)
shutdown(state: TrackedState) None
update(state: TrackedState, moment: Moment) Moment | None
convert_v1_v2(config)