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  valid  nodes  links  zones │
│ TrafficAssignmentDataset                                             String   Bool  Int64  Int64  Int64 │
├──────────────────────────┼───────────────────────────────────────────────────┼───────┼───────┼───────┼───────┤
│   TransportationNetworks │                                           Anaheim │  true │   416 │   914 │    38 │
│   TransportationNetworks │                                            Austin │  true │  7388 │ 18961 │     0 │
│   TransportationNetworks │                                         Barcelona │  true │  1020 │  2522 │   110 │
│   TransportationNetworks │                                     Berlin-Center │  true │ 12981 │ 28376 │   865 │
│   TransportationNetworks │                             Berlin-Friedrichshain │  true │   224 │   523 │    23 │
│   TransportationNetworks │                               Berlin-Mitte-Center │  true │   398 │   871 │    36 │
│   TransportationNetworks │ Berlin-Mitte-Prenzlauerberg-Friedrichshain-Center │  true │   975 │  2184 │    98 │
│   TransportationNetworks │                      Berlin-Prenzlauerberg-Center │  true │   352 │   749 │    38 │
│   TransportationNetworks │                                 Berlin-Tiergarten │  true │   361 │   766 │    26 │
│   TransportationNetworks │                                Birmingham-England │  true │ 14639 │ 33937 │   898 │
│   TransportationNetworks │                                    Braess-Example │  true │     4 │     5 │     0 │
│   TransportationNetworks │                                    Chicago-Sketch │  true │   933 │  2950 │     0 │
│   TransportationNetworks │                             Eastern-Massachusetts │  true │    74 │   258 │     0 │
│   TransportationNetworks │                                         GoldCoast │  true │  4807 │ 11140 │  1068 │
│   TransportationNetworks │                                 Hessen-Asymmetric │  true │  4660 │  6674 │   245 │
│   TransportationNetworks │                                            Munich │ false │    -1 │    -1 │    -1 │
│   TransportationNetworks │                                      Philadelphia │  true │ 13389 │ 40003 │  1525 │
│   TransportationNetworks │                                        SiouxFalls │  true │    24 │    76 │     0 │
│   TransportationNetworks │                                            Sydney │  true │ 33113 │ 75379 │  3264 │
│   TransportationNetworks │                               Terrassa-Asymmetric │  true │  1609 │  3264 │    55 │
│   TransportationNetworks │                                          Winnipeg │  true │  1052 │  2836 │   147 │
│   TransportationNetworks │                               Winnipeg-Asymmetric │  true │  1057 │  2535 │   154 │
│   TransportationNetworks │                                  chicago-regional │  true │ 12982 │ 39018 │  1790 │
│                  Unified │                                     San Francisco │  true │  4986 │ 18002 │   194 │
│                  Unified │                                           Seattle │  true │  6891 │ 27361 │   139 │
│                  Unified │                                          Portland │  true │  8245 │ 31939 │   157 │
│                  Unified │                                         Las Vegas │  true │  7823 │ 28831 │   175 │
│                  Unified │                                           Chicago │  true │ 14434 │ 54469 │   819 │
│                  Unified │                                       New Orleans │  true │  7217 │ 24073 │   185 │
│                  Unified │                                            Austin │  true │ 10717 │ 40158 │   199 │
│                  Unified │                                       Minneapolis │  true │  4004 │ 15363 │   130 │
│                  Unified │                                            Dallas │  true │ 21389 │ 77818 │   328 │
│                  Unified │                                         Milwaukee │  true │  8521 │ 30747 │   234 │
│                  Unified │                                          New York │  true │ 28626 │ 99410 │  2005 │
│                  Unified │                                        Washington │  true │  6136 │ 23573 │   179 │
│                  Unified │                                            Boston │  true │  5542 │ 20487 │   191 │
│                  Unified │                                      Philadelphia │  true │ 10410 │ 38641 │   389 │
│                  Unified │                                        Pittsburgh │  true │  3532 │ 13662 │   149 │
│                  Unified │                                             Miami │  true │  4121 │ 15108 │   108 │
│                  Unified │                                           Atlanta │  true │  5207 │ 20243 │   141 │
│                  Unified │                                           Phoenix │  true │ 15324 │ 58070 │   378 │
│                  Unified │                                            Denver │  true │  9205 │ 34724 │   175 │
│                  Unified │                                          Honolulu │  true │  2982 │ 11205 │   117 │
└──────────────────────────┴───────────────────────────────────────────────────┴───────┴───────┴───────┴───────┘

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