API reference

Public

TrafficAssignment.TrafficAssignmentProblemType
struct 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 time
  • t0 is the free flow time
  • f is the flow along the link
  • c is the link capacity
  • α is a multiplicative coefficient (often taken to be 0.15)
  • β is an exponent (often taken to be 4)

Fields

  • dataset::TrafficAssignmentDataset: name of the dataset

  • instance_name::String: name of the instance (subfolder inside the dataset)

  • nb_nodes::Int64: number of nodes in the network (nodes are numbered from 1 to nb_nodes)

  • nb_links::Int64: number of directed links in the network

  • real_nodes::UnitRange{Int64}: interval of nodes that correspond to real intersections

  • zone_nodes::UnitRange{Int64}: interval of nodes that correspond to artificial zones

  • node_coord::Vector{Coord} where Coord<:Union{Missing, Tuple{Number, Number}}: coordinates of the nodes for plotting

  • valid_longitude_latitude::Bool: whether node_coord corresponds to the longitude and latitude

  • link_id::SparseArrays.SparseMatrixCSC{Int64, Int64}: matrix of link ids starting at one

  • link_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 lengths

  • link_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 limits

  • link_bpr_mult::SparseArrays.SparseMatrixCSC{BPRMult, Int64} where BPRMult<:Number: link multiplicative factors α in the BPR formula, either a single scalar or a matrix

  • link_bpr_power::SparseArrays.SparseMatrixCSC{BPRPow, Int64} where BPRPow<:Number: link exponents β in the BPR formula, either a single scalar or a matrix

  • link_toll::SparseArrays.SparseMatrixCSC{Toll, Int64} where Toll<:Union{Missing, Number}: matrix of link tolls

  • link_type::SparseArrays.SparseMatrixCSC{LinkT, Int64} where LinkT: matrix of link types

  • demand::Dict{Tuple{Int64, Int64}, Dem} where Dem<:Number: demand by OD pair

  • origins::Vector{Int64}: vector of unique origins for the OD pairs

  • destinations::Vector{Int64}: vector of unique destinations for the OD pairs

  • removed_od_pairs::Vector{Tuple{Int64, Int64}}: OD pairs removed because no path between them exists

  • destination_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 origin

  • toll_factor::Union{Missing, Number}: conversion factor turning toll costs into temporal costs, expressed in time/toll

  • distance_factor::Union{Missing, Number}: conversion factor turning distance costs into temporal costs, expressed in time/length

  • solution_software::Union{Missing, TrafficAssignmentSoftware}: software used to compute the provided solution, if known

  • optimal_flow::SparseArrays.SparseMatrixCSC{Flow, Int64} where Flow<:Union{Missing, Number}: provided matrix of optimal link flows

source
TrafficAssignment.list_instancesMethod
list_instances()
list_instances(dataset::TrafficAssignmentDataset)

Return a list of the available instances, given as a tuple with their dataset.

source
TrafficAssignment.nb_linksMethod
nb_links(problem::TrafficAssignmentProblem)

Return the number of links in the network (including links to and from zone nodes).

source
TrafficAssignment.plot_networkMethod
plot_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.

Warning

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
source
TrafficAssignment.price_of_anarchyMethod
price_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.

source
TrafficAssignment.social_costMethod
social_cost(problem::TrafficAssignmentProblem, flow::SparseMatrixCSC)

Return the social cost (total travel time) of a given solution flow to problem.

source
TrafficAssignment.solve_frank_wolfeMethod
solve_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.

source
TrafficAssignment.summarize_instancesMethod
summarize_instances()
summarize_instances(dataset::TrafficAssignmentDataset)

Return a DataFrame summarizing the dimensions of the available instances inside a datase.

source

Private

TrafficAssignment.datapathMethod
datapath(dataset::TrafficAssignmentDataset)
datapath(dataset::TrafficAssignmentDataset, instance_name::AbstractString)

Return the absolute path to the raw data.

source
TrafficAssignment.postprocess!Method
postprocess!(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)
source