API reference
Public
TrafficAssignment.AequilibraE
— ConstantAequilibraE
Solutions computed with the Python package AequilibraE.
TrafficAssignment.TransCAD
— ConstantTransCAD
Solutions computed with the commercial software TransCAD.
TrafficAssignment.TransportationNetworks
— ConstantTransportationNetworks
Dataset available at https://github.com/bstabler/TransportationNetworks.
TrafficAssignment.Unified
— ConstantUnified
Dataset available at https://figshare.com/articles/dataset/Aunifiedandvalidatedtrafficdatasetfor20UScities/24235696.
TrafficAssignment.TrafficAssignmentDataset
— TypeTrafficAssignmentDataset
Enum type listing the two possible sources of data: TransportationNetworks
or Unified
.
TrafficAssignment.TrafficAssignmentProblem
— Typestruct TrafficAssignmentProblem{Coord<:Union{Missing, Tuple{Number, Number}}, Capa<:Number, Length<:Number, Free<:Number, Speed<:Number, BPRMult<:Number, BPRPow<:Number, Toll<:Union{Missing, Number}, LinkT, Flow<:Union{Missing, Number}, Dem<:Number, TF<:Union{Missing, Number}, DF<:Union{Missing, Number}}
Instance of the static traffic assignment problem.
Details
The link travel time is given by the formula of the Bureau of Public Roads (BPR):
t = t0 * (1 + α * (f/c)^β)
where
t
is the travel timet0
is the free flow timef
is the flow along the linkc
is the link capacityα
is a multiplicative coefficient (often taken to be0.15
)β
is an exponent (often taken to be4
)
Fields
dataset::TrafficAssignmentDataset
: name of the datasetinstance_name::String
: name of the instance (subfolder inside the dataset)nb_nodes::Int64
: number of nodes in the network (nodes are numbered from1
tonb_nodes
)nb_links::Int64
: number of directed links in the networkreal_nodes::UnitRange{Int64}
: interval of nodes that correspond to real intersectionszone_nodes::UnitRange{Int64}
: interval of nodes that correspond to artificial zonesnode_coord::Vector{Coord} where Coord<:Union{Missing, Tuple{Number, Number}}
: coordinates of the nodes for plottingvalid_longitude_latitude::Bool
: whethernode_coord
corresponds to the longitude and latitudelink_id::SparseArrays.SparseMatrixCSC{Int64, Int64}
: matrix of link ids starting at onelink_capacity::SparseArrays.SparseMatrixCSC{Capa, Int64} where Capa<:Number
: matrix of link capacities (c
in the BPR formula)link_length::SparseArrays.SparseMatrixCSC{Length, Int64} where Length<:Number
: matrix of link lengthslink_free_flow_time::SparseArrays.SparseMatrixCSC{Free, Int64} where Free<:Number
: matrix of link free flow times (t0
in the BPR formula)link_speed_limit::SparseArrays.SparseMatrixCSC{Speed, Int64} where Speed<:Number
: matrix of link speed limitslink_bpr_mult::SparseArrays.SparseMatrixCSC{BPRMult, Int64} where BPRMult<:Number
: link multiplicative factorsα
in the BPR formula, either a single scalar or a matrixlink_bpr_power::SparseArrays.SparseMatrixCSC{BPRPow, Int64} where BPRPow<:Number
: link exponentsβ
in the BPR formula, either a single scalar or a matrixlink_toll::SparseArrays.SparseMatrixCSC{Toll, Int64} where Toll<:Union{Missing, Number}
: matrix of link tollslink_type::SparseArrays.SparseMatrixCSC{LinkT, Int64} where LinkT
: matrix of link typesdemand::Dict{Tuple{Int64, Int64}, Dem} where Dem<:Number
: demand by OD pairorigins::Vector{Int64}
: vector of unique origins for the OD pairsdestinations::Vector{Int64}
: vector of unique destinations for the OD pairsremoved_od_pairs::Vector{Tuple{Int64, Int64}}
: OD pairs removed because no path between them existsdestination_free_flow_time::Dict{Int64, Vector{Free}} where Free<:Number
: dictionary mapping each destination to a vector of free flow path times for every possible origintoll_factor::Union{Missing, Number}
: conversion factor turning toll costs into temporal costs, expressed in time/tolldistance_factor::Union{Missing, Number}
: conversion factor turning distance costs into temporal costs, expressed in time/lengthsolution_software::Union{Missing, TrafficAssignmentSoftware}
: software used to compute the provided solution, if knownoptimal_flow::SparseArrays.SparseMatrixCSC{Flow, Int64} where Flow<:Union{Missing, Number}
: provided matrix of optimal link flows
TrafficAssignment.TrafficAssignmentProblem
— MethodTrafficAssignmentProblem(dataset, instance_name)
User-friendly constructor for TrafficAssignmentProblem
.
The dataset must be a TrafficAssignmentDataset
, the instance can be chosen from list_instances
.
TrafficAssignment.TrafficAssignmentSoftware
— TypeTrafficAssignmentSoftware
Enum type listing the two possible software tools used to create solutions for instances from the Unified
dataset: AequilibraE
or TransCAD
.
TrafficAssignment.list_instances
— Methodlist_instances()
list_instances(dataset::TrafficAssignmentDataset)
Return a list of the available instances, given as a tuple with their dataset.
TrafficAssignment.nb_links
— Methodnb_links(problem::TrafficAssignmentProblem)
Return the number of links in the network (including links to and from zone nodes).
TrafficAssignment.nb_nodes
— Methodnb_nodes(problem::TrafficAssignmentProblem)
Return the number of nodes in the network (including zone nodes).
TrafficAssignment.nb_zones
— Methodnb_zones(problem::TrafficAssignment)
Return the number of fake nodes in the network that represent zones.
TrafficAssignment.plot_network
— Methodplot_network(
problem::TrafficAssignmentProblem, flow=nothing;
offset_ratio=0,
nodes=false, zones=false, tiles=false
)
Plot a transportation network, possibly on top of real-world map tiles.
If a flow
is provided, network edges will be colored according to their congestion level.
This function requires loading one of Makie.jl's backends beforehand, ideally GLMakie.jl. Using tiles=true
requires loading Tyler.jl in addition.
Keyword arguments
offset_ratio
: whether to shift directed edges slightly so that they become distinct (the convention being that cars travel on the right-hand side of the road)nodes
,zones
,tiles
: whether to visualize certain aspects of the network
TrafficAssignment.price_of_anarchy
— Methodprice_of_anarchy(problem::TrafficAssignmentProblem, args...; kwargs...)
Compute the price of anarchy (cost of equilibrium flow over cost of centralized flow) for problem
.
Positional and keyword arguments are forwarded to solve_frank_wolfe
.
TrafficAssignment.social_cost
— Methodsocial_cost(problem::TrafficAssignmentProblem, flow::SparseMatrixCSC)
Return the social cost (total travel time) of a given solution flow
to problem
.
TrafficAssignment.solve_frank_wolfe
— Methodsolve_frank_wolfe(
problem::TrafficAssignmentProblem,
control::Val,
frank_wolfe_alg=frank_wolfe;
verbose, relative_gap, kwargs...
)
Solve a traffic assignment problem
with a specific control
setting (either :centralized
or :equilibrium
), using an algorithm from the FrankWolfe library.
Remaining keyword arguments are passed to frank_wolfe_alg
.
TrafficAssignment.summarize_instances
— Methodsummarize_instances()
summarize_instances(dataset::TrafficAssignmentDataset)
Return a DataFrame
summarizing the dimensions of the available instances inside a datase.
Private
TrafficAssignment.datapath
— Methoddatapath(dataset::TrafficAssignmentDataset)
datapath(dataset::TrafficAssignmentDataset, instance_name::AbstractString)
Return the absolute path to the raw data.
TrafficAssignment.instance_files
— Methodinstance_files(dataset, instance_name)
Return a named tuple containing the absolute paths to the individual data tables of an instance.
TrafficAssignment.postprocess!
— Methodpostprocess!(pb)
Perform some data cleaning on a TrafficAssignmentProblem
:
- precompute free flow times to every destination present in the demand
- remove OD pairs without a path between them (the free flow time is infinite)