Tutorial

Warning

Page in construction.

using TrafficAssignment
using PrettyTables  # for table display
using CairoMakie, Tyler  # for plotting

Instances

The package gives you access to the following instances:

pretty_table(summarize_instances())
┌ Warning: Loading Munich from TransportationNetworks dataset failed
  exception = ArgumentError: row indices I[k] must satisfy 1 <= I[k] <= m
@ TrafficAssignment ~/work/TrafficAssignment.jl/TrafficAssignment.jl/src/read.jl:582
┌──────────────────────────┬────────────────────────────────────────────────────
│                  dataset                                           instance ⋯
│ TrafficAssignmentDataset                                             String ⋯
├──────────────────────────┼────────────────────────────────────────────────────
│   TransportationNetworks │                                           Anaheim ⋯
│   TransportationNetworks │                                            Austin ⋯
│   TransportationNetworks │                                         Barcelona ⋯
│   TransportationNetworks │                                     Berlin-Center ⋯
│   TransportationNetworks │                             Berlin-Friedrichshain ⋯
│   TransportationNetworks │                               Berlin-Mitte-Center ⋯
│   TransportationNetworks │ Berlin-Mitte-Prenzlauerberg-Friedrichshain-Center ⋯
│   TransportationNetworks │                      Berlin-Prenzlauerberg-Center ⋯
│   TransportationNetworks │                                 Berlin-Tiergarten ⋯
│   TransportationNetworks │                                Birmingham-England ⋯
│   TransportationNetworks │                                    Braess-Example ⋯
│   TransportationNetworks │                                    Chicago-Sketch ⋯
│   TransportationNetworks │                             Eastern-Massachusetts ⋯
│   TransportationNetworks │                                         GoldCoast ⋯
│   TransportationNetworks │                                 Hessen-Asymmetric ⋯
│                        ⋮ │                                                 ⋮ ⋱
└──────────────────────────┴────────────────────────────────────────────────────
                                                   4 columns and 28 rows omitted

To download and parse one, just specify its name inside the TrafficAssignmentProblem constructor:

dataset = TransportationNetworks
instance_name = "SiouxFalls"
problem = TrafficAssignmentProblem(dataset, instance_name)
Traffic assignment problem on the SiouxFalls network with 24 nodes, 76 links and 0 zones

Visualization

You can visualize instances as follows:

plot_network(problem; nodes=true, zones=false, tiles=true)
Example block output

Solution

You can solve instances as follows:

flow = solve_frank_wolfe(problem; verbose=false, max_iteration=1000)
24×24 SparseArrays.SparseMatrixCSC{Float64, Int64} with 76 stored entries:
⎡⠎⡡⡐⠀⠀⡠⠀⠀⠀⠀⠀⠀⎤
⎢⠐⠈⢊⡰⡁⠀⠀⢀⠠⠀⠀⠀⎥
⎢⠀⡠⠁⠈⠪⡢⡠⠒⠂⠀⠀⠀⎥
⎢⠀⠀⠀⢀⢠⠊⠠⠂⣀⠄⠠⠊⎥
⎢⠀⠀⠀⠂⠈⠀⠀⠜⢄⡱⣀⠀⎥
⎣⠀⠀⠀⠀⠀⠀⡠⠂⠀⠘⡪⡪⎦

The solution can be visualized with the same plotting function:

plot_network(problem, flow; nodes=false, zones=false, tiles=false)
Example block output