TrafficAssignment.jl

Julia package for finding traffic user equilibrium flow
Popularity
40 Stars
Updated Last
10 Months Ago
Started In
February 2015

TrafficAssignment.jl

Build Status codecov

This package for the Julia Language does basically two tasks: (1) loading a network data and (2) finding a user equilibrium traffic pattern. See Traffic Assignment.

Install

julia> Pkg.add("TrafficAssignment")

This will install LightGraphs.jl and Optim.jl, if you don't have them already.

To check if works

julia> Pkg.test("TrafficAssignment")

load_ta_network

This function loads a network data available in this TNTP github repository. The network name must match with the directory name in the TNTP repository.

Example:

using TrafficAssignment
ta_data = load_ta_network("SiouxFalls")
# ta_data = load_ta_network("Anaheim")
# ta_data = load_ta_network("Barcelona")
# ta_data = load_ta_network("Winnipeg")

The return value is of the TA_Data type, which is defined as

mutable struct TA_Data
    network_name::String

    number_of_zones::Int
    number_of_nodes::Int
    first_thru_node::Int
    number_of_links::Int

    init_node::Array{Int,1}
    term_node::Array{Int,1}
    capacity::Array{Float64,1}
    link_length::Array{Float64,1}
    free_flow_time::Array{Float64,1}
    b::Array{Float64,1}
    power::Array{Float64,1}
    speed_limit::Array{Float64,1}
    toll::Array{Float64,1}
    link_type::Array{Int64,1}

    total_od_flow::Float64

    travel_demand::Array{Float64,2}
    od_pairs::Array{Tuple{Int64,Int64},1}

    toll_factor::Float64
    distance_factor::Float64

    best_objective::Float64
end

ta_frank_wolfe

This function implements methods to find traffic equilibrium flows: currently, Frank-Wolfe (FW) method, Conjugate FW (CFW) method, and Bi-conjugate FW (BFW) method.

References:

Example:

link_flow, link_travel_time, objective = ta_frank_wolfe(ta_data, log="off", tol=1e-2)

Available optional arguments:

  • method=:fw / :cfw / :bfw (default=:bfw)
  • step="exact" / "newton" : exact line search using golden section / a simple Newton-type step (default=:exact)
  • log=:on / :off : displays information from each iteration or not (default=:off)
  • max_iter_no=integer value : maximum number of iterations (default=2000)
  • tol=numeric value : tolerance for the Average Excess Cost (AEC) (default=1e-3)

For example, one may do:

ta_data = load_ta_network("SiouxFalls")
link_flow, link_travel_time, objective =
ta_frank_wolfe(ta_data, method=:cfw, max_iter_no=50000, step=:newton, log=:on, tol=1e-5)

The total system travel time can be simply computed as

using LinearAlgebra
system_travel_time = dot(link_travel_time, link_flow)

Contributor

This package is written and maintained by Changhyun Kwon.