Skip to content
Transportation

transportation-ai999x

Vehicle dynamics, braking and stopping distances, traffic flow, highway geometry, railway operations, route planning and transit capacity.

77capabilities
13topics
77formulas typeset
8worked examples below
1.0.1version
About this model

What Transportation does

Transportation (transportation-ai999x) is an offline Python package for transportation. It covers vehicle dynamics, braking and stopping distances, traffic flow, highway geometry, railway operations, route planning and transit capacity.

It has 77 capabilities — 77 computational procedures — in 13 topics, the largest being Traffic flow, Highway geometry, Vehicle dynamics, Vehicle performance, Braking and stopping and Mode choice. Ask a question in words with ask(), or call a capability by name with typed inputs with solve(). Every answer carries its value and unit, the steps that produced it and the formula in LaTeX.

When a question is not determined — a value is missing, an input is out of range, or the request is outside the package — it says so and names what it needs, instead of guessing. It runs on an ordinary CPU without a network connection (Python >=3.10), and the same question always gets the same answer.

Install

pip install transportation-ai999x
hf download AI999X/transportation-ai999x --local-dir transportation-ai999x

What it covers

Braking and stopping6Braking distance from speed and deceleration · Distance to slow from one speed to another (friction and grade) · Impact speed with an obstacle after reaction and braking …Highway geometry12Clothoid (spiral) transition curve coordinates · Curve radius or speed by the simplified e + f formula · Horizontal sightline offset on a circular curve …Mode choice5Direct and cross elasticities of logit choice probabilities · Logit mode choice from attributes and coefficients · Multinomial logit mode shares from utilities …Queueing5Blocking probability with no waiting room (Erlang B), e.g. parking spaces · First-come-first-served queue from arrival and service times · Multi-server random queue (M/M/c, Erlang C), e.g. a toll plaza …Railway operations4Minimum headway of trains at a station stop (moving block) · Running time between stations (accelerate, cruise, brake) · Train acceleration time and distance (tractive effort curve, Davis resistance) …Route planning2Fastest route on a road network (link lengths and speeds) · Zone-to-zone travel time matrix (skim) of a road networkTraffic flow14Fit the Greenberg (logarithmic) model to speed-density observations · Fit the Greenshields model to speed-density observations · Fit the Underwood (exponential) model to speed-density observations …Traffic signals5Green splits by equal degree of saturation (flow-ratio method) · Optimum cycle length by Webster's formula · Queue and uniform delay at a signal (deterministic D/D/1) …Traffic studies285th, 50th and 15th percentile spot speeds · Time-mean and space-mean speed of spot speedsTravel demand4All-or-nothing traffic assignment · Doubly constrained gravity model of trip distribution · Growth-factor (Furness) balancing of a trip matrix …Unsignalized intersections1Capacity of a minor stream by gap acceptanceVehicle dynamics9Lateral load transfer in a steady turn · Longitudinal weight transfer under braking and ideal brake proportioning · Quarter-car model: body and wheel-hop natural frequencies …Vehicle performance8Acceleration time and distance under constant engine power · Coast-down time and distance (rolling and aerodynamic resistance) · Distance and time to accelerate (acceleration lane length) …
Try it

Worked examples

Each question below was put to transportation-ai999x and the answer shown is the one it returned, with the steps it took.

Braking and stoppingm.ask(…)

Stopping sight distance with speed = 100 km/h, reaction time = 2.5 s and deceleration = 3.4 m/s^2.

SSD = 182.9157589 m
d_r = 69.44444444 m
d_b = 113.4713145 m
Show the steps
  1. Stopping sight distance (reaction plus braking, with grade)
    SSD = v\,t_r + \frac{v^2}{2 g (f + G)}
    with v = 27.77777778 m/s, t_r = 2.5 s, a = 3.4 m/s^2
    → SSD = 182.9157589 m, d_r = 69.44444444 m, d_b = 113.4713145 m
Traffic signalsm.ask(…)

Signal queue and uniform delay with arrival flow = 600 veh/h, saturation flow = 1800 veh/h, red = 40 s and green = 30 s.

Q_max = 6.666666667
t_clear = 20 s
D_total = 200 s
d_uniform = 17.14285714 s
P_stopped = 0.8571428571
Show the steps
  1. Queue and uniform delay at a signal (deterministic D/D/1)
    d = \frac{r^2}{2C\,(1 - \lambda/s)} = \frac{C (1 - g/C)^2}{2 (1 - \lambda/s)}
    with lam = 600 1/h, s = 1800 1/h, r = 40 s, g = 30 s
    → Q_max = 6.666666667, t_clear = 20 s, D_total = 200 s, d_uniform = 17.14285714 s, P_stopped = 0.8571428571
Route planningm.ask(…)

Fastest route with roads = [A-B 4, A-C 2.5, B-C 1.2, B-D 5, C-D 8, C-E 10, D-E 2], speeds = [60, 50, 40, 80, 100, 90, 50], origin = A and destination = E.

route = A-C-E
time = 9.666666667 min
distance = 12.5 km
Show the steps
  1. Fastest route on a road network (link lengths and speeds)
    t_{link} = \frac{60\,L}{v},\quad \min \sum t_{link}
    with roads = A-B (4), A-C (2.5), B-C (1.2), B-D (5), C-D (8), C-E (10), D-E (2), speeds = [60, 50, 40, 80, 100, 90, 50], origin = A, destination = E
    → route = A-C-E, time = 9.666666667 min, distance = 12.5 km
Highway geometrym.ask(…)

Maximum safe speed on a curve with radius = 300 m, superelevation = 6 % and side friction = 0.12.

v = 23.09938936 m/s
v_kmh = 83.1578017 km/h
Show the steps
  1. Maximum safe speed on a superelevated horizontal curve
    v = \sqrt{\frac{g R (e + f)}{1 - e f}}
    with R = 300 m, e = 0.06 1, f = 0.12 1
    → v = 23.09938936 m/s, v_kmh = 83.1578017 km/h
Vehicle dynamicsm.solve(…)
m.solve("transport_understeer_gradient", m="1500 kg", L="2.7 m", l_f="1.2 m", C_f="90000 N/rad", C_r="85000 N/rad")
K = 0.001416122004 rad*s^2/m
K_deg_per_g = 0.7959619566 deg
behaviour = understeer
v_c = 43.66480716 m/s
v_c_kmh = 157.1933058 km/h
Show the steps
  1. Understeer gradient and characteristic or critical speed (bicycle model)
    K = \frac{m}{L}\left(\frac{l_r}{C_f} - \frac{l_f}{C_r}\right),\quad v_{ch} = \sqrt{L/K}
    with m = 1500 kg, L = 2.7 m, l_f = 1.2 m, C_f = 90000 N/rad, C_r = 85000 N/rad
    → K = 0.001416122004 rad*s^2/m, K_deg_per_g = 0.7959619566 deg, behaviour = understeer rad*s^2/m, v_c = 43.66480716 m/s, v_c_kmh = 157.1933058 km/h
Mode choicem.ask(…)

Logit elasticities with utilities = [-1.2, -0.8, -2.1], attribute = [30, 45, 20] and beta = -0.04.

P = [0.3450186126, 0.5147072874, 0.1402740999]
direct = [-0.7859776649, -0.8735268826, -0.6877807201]
cross = [0.4140223351, 0.9264731174, 0.1122192799]
Show the steps
  1. Direct and cross elasticities of logit choice probabilities
    E^{P_i}_{x_i} = \beta x_i (1 - P_i),\quad E^{P_j}_{x_i} = -\beta x_i P_i
    with V = [-1.2, -0.8, -2.1], x = [30, 45, 20], beta = -0.04
    → P = [0.3450186126, 0.5147072874, 0.1402740999], direct = [-0.7859776649, -0.8735268826, -0.6877807201], cross = [0.4140223351, 0.9264731174, 0.1122192799]
Queueingm.ask(…)

Erlang b blocking with arrival rate = 60 veh/h, service rate = 0.5 veh/h and spaces = 120.

P_block = 0.06941876906
carried = 111.6697477
lost_per_h = 4.165126144 1/h
Show the steps
  1. Blocking probability with no waiting room (Erlang B), e.g. parking spaces
    B(c, a) = \frac{a^c/c!}{\sum_{k=0}^{c} a^k/k!}
    with lam = 60 1/h, mu = 0.5 1/h, c = 120
    → P_block = 0.06941876906, carried = 111.6697477, lost_per_h = 4.165126144 1/h
Railway operationsm.ask(…)

Station headway with line speed = 80 km/h, acceleration = 1 m/s^2, braking rate = 1.1 m/s^2, train length = 150 m, dwell time = 30 s and safety margin = 50 m.

h = 70.2020202 s
trains_per_h = 51.28057554 1/h
Show the steps
  1. Minimum headway of trains at a station stop (moving block)
    h = t_d + \sqrt{\frac{2(L_t + s_m)}{a}} + \frac{v}{b}
    with v = 22.22222222 m/s, a = 1 m/s^2, b = 1.1 m/s^2, L_t = 150 m, t_d = 30 s, s_m = 50 m
    → h = 70.2020202 s, trains_per_h = 51.28057554 1/h
Use it

From Python or the command line

Every snippet was run as shown; the output under it is what it printed.

import transportation_ai999x as m

a = m.ask("Stopping sight distance with speed = 100 km/h, reaction time = 2.5 s and deceleration = 3.4 m/s^2.")
print(a.outcome)
print(a.values)
for step in a.steps:
    print(step["name"])
Output
SOLVED
{'SSD': 182.915758896, 'd_r': 69.4444444444, 'd_b': 113.471314452}
Stopping sight distance (reaction plus braking, with grade)
Figures

Computed, not drawn by hand

Every value in these figures was computed by the package, each point a run of solve(); in a notebook, plot() and plot_relation() draw a capability's curves the same way.

Speed–density data and the fitted traffic-flow model

v = v_f - \frac{v_f}{k_j} k,\quad q_{max} = \frac{v_f k_j}{4}
Speed–density data and the fitted traffic-flow modelSix observed speed–density pairs and the linear speed–density model fitted to them by the package: free-flow speed vf = 95.3537 km/h, jam density kj = 120.141 veh/km, R² = 0.99869; the line is traced by the package's speeds at 80 flows up to the capacity 2863.96 veh/h. Marked: k = 0, v = vf.0501000255075100vf = 95.3537 km/hfitted line, R² = 0.99869observedk — density [veh/km]v — speed [km/h]
Six observed speed–density pairs and the linear speed–density model fitted to them by the package: free-flow speed vf = 95.3537 km/h, jam density kj = 120.141 veh/km, R² = 0.99869; the line is traced by the package's speeds at 80 flows up to the capacity 2863.96 veh/h. Marked: k = 0, v = vf.

The flow–density fundamental diagram and capacity

q_{max} = \frac{v_f k_j}{4},\quad k_m = \frac{k_j}{2},\quad v_m = \frac{v_f}{2}
The flow–density fundamental diagram and capacityFundamental diagram for free-flow speed 100 km/h and jam density 120 veh/km: for each of 40 flows the package returns the two densities that carry it (uncongested left, congested right). Marked: the capacity it returned, q = 3000 veh/h at the optimum density k = 60 veh/km and speed 50 km/h.02550751000100020003000k = 60 veh/kmcapacity 3000 veh/hflow–density curvek — density [veh/km]q — flow [veh/h]
Fundamental diagram for free-flow speed 100 km/h and jam density 120 veh/km: for each of 40 flows the package returns the two densities that carry it (uncongested left, congested right). Marked: the capacity it returned, q = 3000 veh/h at the optimum density k = 60 veh/km and speed 50 km/h.

Stopping sight distance: reaction plus braking

SSD = v\,t_r + \frac{v^2}{2 g (f + G)}
Stopping sight distance: reaction plus brakingStopping sight distance against design speed (reaction time 2.5 s, deceleration 3.4 m/s², level road), 25 speeds computed by the package: the lower band is the distance travelled during the reaction time, the upper band the braking distance. Marked: v = 100 km/h, SSD = 182.916 m (reaction 69.4444 m + braking 113.471 m).2550751001250100200300182.916 mbraking distancereaction distancestopping sight distance (total)v — design speed [km/h]distance [m]
Stopping sight distance against design speed (reaction time 2.5 s, deceleration 3.4 m/s², level road), 25 speeds computed by the package: the lower band is the distance travelled during the reaction time, the upper band the braking distance. Marked: v = 100 km/h, SSD = 182.916 m (reaction 69.4444 m + braking 113.471 m).

Queue at a traffic signal over one cycle

d = \frac{r^2}{2C\,(1 - \lambda/s)} = \frac{C (1 - g/C)^2}{2 (1 - \lambda/s)}
Queue at a traffic signal over one cycleQueue at a signal over one cycle (arrivals 600 veh/h, saturation flow 1800 veh/h, red 40 s, green 30 s): it grows during red to the maximum the package returned, 6.66667 vehicles, and clears 20 s into green; the shaded area is the total delay 200 veh·s (17.1429 s per vehicle, 85.7143 % stopped). Marked: t = 40 s, queue = 6.66667 vehicles.02040600246red → green6.66667 vehtotal delay 200 veh·squeue lengtht — time in the cycle [s]queue [vehicles]
Queue at a signal over one cycle (arrivals 600 veh/h, saturation flow 1800 veh/h, red 40 s, green 30 s): it grows during red to the maximum the package returned, 6.66667 vehicles, and clears 20 s into green; the shaded area is the total delay 200 veh·s (17.1429 s per vehicle, 85.7143 % stopped). Marked: t = 40 s, queue = 6.66667 vehicles.

Time–space diagram of a signal queue

t^* = \frac{w_2\, r}{w_2 - w_1},\quad L_{max} = -w_1 t^*
Time–space diagram of a signal queueTime–space diagram of the queue at a signal (arrivals 1000 veh/h at 20 veh/km, jam density 140 veh/km, discharge 1800 veh/h at 50 veh/km, red 40 s): the queue tail moves upstream at 8.33333 km/h, the discharge wave from the start of green at 20 km/h (both returned by the package); where they meet the queue is longest. Marked: t = 68.5714 s, maximum queue 158.73 m.020406080-200-150-100-500redgreen158.73 m at 68.5714 sstopped queue (jam density)queue tail, 8.33333 km/h upstreamdischarge wave, 20 km/h upstreamt — time since the start of red [s]position relative to the stop line [m]
Time–space diagram of the queue at a signal (arrivals 1000 veh/h at 20 veh/km, jam density 140 veh/km, discharge 1800 veh/h at 50 veh/km, red 40 s): the queue tail moves upstream at 8.33333 km/h, the discharge wave from the start of green at 20 km/h (both returned by the package); where they meet the queue is longest. Marked: t = 68.5714 s, maximum queue 158.73 m.
Formulas

The mathematics inside

12 of its 77 formulas; every one is in the capability browser below.

Queue and uniform delay at a signal (deterministic D/D/1)
d = \frac{r^2}{2C\,(1 - \lambda/s)} = \frac{C (1 - g/C)^2}{2 (1 - \lambda/s)}
Fastest route on a road network (link lengths and speeds)
t_{link} = \frac{60\,L}{v},\quad \min \sum t_{link}
Maximum safe speed on a superelevated horizontal curve
v = \sqrt{\frac{g R (e + f)}{1 - e f}}
Understeer gradient and characteristic or critical speed (bicycle model)
K = \frac{m}{L}\left(\frac{l_r}{C_f} - \frac{l_f}{C_r}\right),\quad v_{ch} = \sqrt{L/K}
Direct and cross elasticities of logit choice probabilities
E^{P_i}_{x_i} = \beta x_i (1 - P_i),\quad E^{P_j}_{x_i} = -\beta x_i P_i
Minimum headway of trains at a station stop (moving block)
h = t_d + \sqrt{\frac{2(L_t + s_m)}{a}} + \frac{v}{b}
Braking distance from speed and deceleration
d = \frac{v^2}{2a},\quad t = \frac{v}{a}
Clothoid (spiral) transition curve coordinates
x = \int_0^s \cos\frac{u^2}{2A^2}\,du,\quad y = \int_0^s \sin\frac{u^2}{2A^2}\,du,\quad \theta = \frac{s^2}{2RL_s}
Logit mode choice from attributes and coefficients
V_i = ASC_i + \sum_k \beta_k x_{ik},\quad P_i = \frac{e^{V_i}}{\sum_j e^{V_j}}
First-come-first-served queue from arrival and service times
S_n = \max(A_n,\ \min_j F_j),\quad W_n = S_n - A_n
Capabilities

Every capability, with an example

Search by name, formula, input or topic. Each capability opens to show what it takes, what it returns, when it applies, and a question it answered.

77 capabilities

Braking and stopping 6

Braking distance from speed and decelerationtransport_braking_distance

Distance and time for a vehicle to stop from speed v at a constant deceleration a (no reaction time).

d = \frac{v^2}{2a},\quad t = \frac{v}{a}

Inputs

  • v initial speed [m/s]
  • a deceleration (magnitude) [m/s^2]

Returns

  • d braking distance (m) [m]
  • t braking time (s) [s]

Applies when

  • v > 0
  • a > 0

Example

m.ask("Braking distance with speed = 100 km/h and deceleration = 3.4 m/s^2.")
→ d = 113.471 m, t = 8.16993 s
Distance to slow from one speed to another (friction and grade)transport_speed_reduction_distance

Braking distance and time to slow from v1 to v2 with friction coefficient f on a grade G (deceleration g (f + G)).

d = \frac{v_1^2 - v_2^2}{2 g (f + G)}

Inputs

  • v1 initial speed [m/s]
  • v2 final speed [m/s]
  • f friction coefficient
  • G grade, decimal (positive uphill) optional

Returns

  • d braking distance (m) [m]
  • t braking time (s) [s]

Applies when

  • v1 > v2 >= 0
  • f + G > 0

Example

m.ask("Speed reduction braking distance with initial speed = 90 km/h, final speed = 40 km/h, friction = 0.4 and grade = 3 %.")
→ d = 59.4485 m, t = 3.29253 s
Impact speed with an obstacle after reaction and brakingtransport_impact_speed

A driver at speed v sees an obstacle at distance D, reacts after t_r and brakes with friction f on grade G: the speed at the obstacle (0 if the vehicle stops in time) and the full stopping distance.

v_i = \sqrt{v^2 - 2 g (f + G)(D - v t_r)}

Inputs

  • v initial speed [m/s]
  • D distance to the obstacle [m]
  • t_r perception-reaction time [s]
  • f friction coefficient
  • G grade, decimal (positive uphill) optional

Returns

  • v_impact speed at the obstacle (m/s), 0 if the vehicle stops before it [m/s]
  • v_impact_kmh speed at the obstacle (km/h) [km/h]
  • d_stop stopping distance from the moment the obstacle is seen (m) [m]

Applies when

  • v > 0
  • D > 0
  • t_r >= 0
  • f + G > 0

Example

m.ask("Impact speed with speed = 90 km/h, distance = 60 m, reaction time = 1 s and friction = 0.6.")
→ v_impact = 14.5938 m/s, v_impact_kmh = 52.5378 km/h, d_stop = 78.0921 m
Speed estimate from skid-mark lengthtransport_skid_speed

Initial speed of a vehicle that skidded to rest over a length d with friction coefficient f on a grade G.

v = \sqrt{2 g (f + G)\, d}

Inputs

  • d skid-mark length [m]
  • f friction coefficient
  • G grade, decimal (positive uphill) optional

Returns

  • v initial speed (m/s) [m/s]
  • v_kmh initial speed (km/h) [km/h]

Applies when

  • d > 0
  • f > 0
  • f + G > 0

Example

m.ask("Skid mark speed with skid length = 30 m and friction = 0.6.")
→ v = 18.7926 m/s, v_kmh = 67.6532 km/h
Stopping sight distance (reaction plus braking, with grade)transport_stopping_sight_distance

Stopping sight distance = perception-reaction distance + braking distance on a grade, with either the longitudinal friction coefficient f (braking deceleration g (f + G)) or a deceleration rate a (AASHTO: a + g G, design value 3.4 m/s^2).

SSD = v\,t_r + \frac{v^2}{2 g (f + G)}

Inputs

  • v design speed [m/s]
  • t_r perception-reaction time [s]
  • f longitudinal friction coefficient optional
  • a deceleration rate [m/s^2] optional
  • G grade, decimal (positive uphill) optional

Returns

  • SSD stopping sight distance (m) [m]
  • d_r perception-reaction distance (m) [m]
  • d_b braking distance (m) [m]

Applies when

  • v > 0
  • t_r >= 0
  • exactly one of f, a
  • f + G > 0 (or a + g G > 0)

Example

m.ask("Stopping sight distance with speed = 100 km/h, reaction time = 2.5 s and deceleration = 3.4 m/s^2.")
→ SSD = 182.916 m, d_r = 69.4444 m, d_b = 113.471 m
Theoretical stopping distance with aerodynamic and rolling resistancetransport_braking_with_air_resistance

Stopping (or slowing) distance and time of a road vehicle braking with tyre-road friction mu and braking efficiency eta, helped by aerodynamic drag (rho C_D A v^2 / 2), rolling resistance f_r and the grade; gamma is the mass factor for rotating parts (1.04 for braking).

S = \frac{\gamma m}{2K}\ln\frac{F_0 + K v_1^2}{F_0 + K v_2^2}

Inputs

  • m vehicle mass [kg]
  • v1 initial speed [m/s]
  • mu tyre-road friction coefficient
  • C_D drag coefficient
  • A frontal area [m^2]
  • rho air density (default 1.2 kg/m^3) [kg/m^3] optional
  • f_r rolling resistance coefficient (default 0.01) optional
  • G grade, decimal (positive uphill) optional
  • eta braking efficiency (default 1) optional
  • gamma mass factor for braking (default 1.04) optional
  • v2 final speed (default 0) [m/s] optional

Returns

  • S braking distance (m) [m]
  • t braking time (s) [s]

Applies when

  • m, v1, mu, C_D, A > 0
  • 0 < eta <= 1
  • v2 < v1
  • a positive constant retarding force

Example

m.ask("Theoretical stopping distance with mass = 1500 kg, initial speed = 120 km/h, friction = 0.7, drag coefficient = 0.35, frontal area = 2.2 m^2, rolling resistance = 0.012 and braking efficiency = 0.95.")
→ S = 84.8295 m, t = 5.13282 s

Highway geometry 12

Clothoid (spiral) transition curve coordinatestransport_clothoid_coordinates

Coordinates along the tangent (x) and offset from it (y), and the tangent deflection angle, at distance s along a clothoid transition of length L_s that ends at a circular curve of radius R (A^2 = R L_s).

x = \int_0^s \cos\frac{u^2}{2A^2}\,du,\quad y = \int_0^s \sin\frac{u^2}{2A^2}\,du,\quad \theta = \frac{s^2}{2RL_s}

Inputs

  • R radius of the circular curve [m]
  • L_s spiral length [m]
  • s distance along the spiral (default L_s) [m] optional

Returns

  • x distance along the initial tangent (m) [m]
  • y offset from the tangent (m) [m]
  • theta tangent deflection angle (degrees) [deg]

Applies when

  • 0 < s <= L_s
  • tangent angle <= 90 degrees

Example

m.ask("Clothoid coordinates with radius = 300 m and spiral length = 80 m.")
→ x = 79.8579 m, y = 3.55104 m, theta = 7.63944 deg
Curve radius or speed by the simplified e + f formulatransport_simplified_curve_formula

The minimum radius R = v^2/(g (e + f)) for a speed, or the maximum speed sqrt(g R (e + f)) on a radius, by the simplified (small-angle) point-mass formula of horizontal curves (the exact form is minimum curve radius).

R = \frac{v^2}{g\,(e + f)}

Inputs

  • e superelevation rate, decimal
  • f side friction factor
  • v design speed (give v or R) [m/s] optional
  • R curve radius (give v or R) [m] optional

Returns

  • R curve radius (m) [m]
  • v speed (m/s) [m/s]
  • v_kmh speed (km/h)

Applies when

  • -0.1 <= e <= 0.2
  • 0 < f <= 0.5
  • the speed or the radius (one of them)
  • small-angle (simplified) form

Example

m.ask("Simplified curve formula with superelevation = 0.06 %, side friction = 0.12 and speed = 100 km/h.")
→ R = 652.197 m, v = 27.7778 m/s, v_kmh = 100
Horizontal sightline offset on a circular curvetransport_horizontal_sight_offset

The clearance M needed from the centre of the inside lane to an obstruction (middle ordinate) so that a driver on a curve of radius R sees the sight distance S, both driver and object on the curve.

M = R\left(1 - \cos\frac{S}{2R}\right)

Inputs

  • R radius of the inside lane centreline [m]
  • S sight distance [m]

Returns

  • M horizontal sightline offset (m) [m]

Applies when

  • R > 0
  • 0 < S < pi R

Example

m.ask("Horizontal sightline offset with radius = 300 m and sight distance = 160 m.")
→ M = 10.6036 m
Maximum safe speed on a superelevated horizontal curvetransport_curve_safe_speed

The highest speed at which a vehicle (point mass) can hold a curve of radius R with superelevation e and side friction factor f.

v = \sqrt{\frac{g R (e + f)}{1 - e f}}

Inputs

  • R curve radius [m]
  • e superelevation rate, decimal
  • f side friction factor

Returns

  • v maximum safe speed (m/s) [m/s]
  • v_kmh maximum safe speed (km/h) [km/h]

Applies when

  • R > 0
  • f > 0
  • e f < 1

Example

m.ask("Maximum safe speed on a curve with radius = 300 m, superelevation = 6 % and side friction = 0.12.")
→ v = 23.0994 m/s, v_kmh = 83.1578 km/h
Minimum length of a crest vertical curve for a sight distancetransport_crest_curve_length

The shortest crest vertical curve between grades g1 and g2 that provides the sight distance S (AASHTO: eye height 1.08 m, object height 0.60 m unless stated), choosing the S < L or S > L form.

L = \frac{A S^2}{200\left(\sqrt{h_1} + \sqrt{h_2}\right)^2}\ \ (S<L),\qquad L = 2S - \frac{200\left(\sqrt{h_1}+\sqrt{h_2}\right)^2}{A}\ \ (S>L)

Inputs

  • g1 grade before the curve, decimal (positive uphill)
  • g2 grade after the curve, decimal
  • S required sight distance [m]
  • h1 driver eye height (default 1.08 m) [m] optional
  • h2 object height (default 0.60 m) [m] optional

Returns

  • L minimum curve length (m) [m]
  • case S < L, S > L or no curve needed

Applies when

  • g1 > g2
  • S > 0

Example

m.ask("Crest vertical curve length with g1 = 3 %, g2 = -2 % and sight distance = 185 m.")
→ L = 260.071 m, case = S < L
Minimum radius of a horizontal curvetransport_minimum_curve_radius

The smallest curve radius for a design speed v, maximum superelevation e and side friction factor f.

R_{min} = \frac{v^2 (1 - e f)}{g (e + f)}

Inputs

  • v design speed [m/s]
  • e superelevation rate, decimal
  • f side friction factor

Returns

  • R_min minimum curve radius (m) [m]

Applies when

  • v > 0
  • f > 0
  • e f < 1

Example

m.ask("Minimum curve radius with speed = 100 km/h, superelevation = 8 % and side friction = 0.12.")
→ R_min = 389.499 m
Passing sight distance (four-component method)transport_passing_sight_distance

The passing sight distance on a two-lane road as d1 + d2 + d3 + d4: the initial manoeuvre d1 = t1 (v - m + a t1/2), the time in the left lane d2 = v t2, the clearance d3 and the opposing vehicle's travel d4 = 2 d2/3 (AASHTO 2001).

PSD = t_1\left(v - m + \frac{a t_1}{2}\right) + v t_2 + d_3 + \frac23 v t_2

Inputs

  • v average speed of the passing vehicle [m/s]
  • m_diff speed difference between passing and passed vehicles [m/s]
  • a average acceleration during the initial manoeuvre [m/s^2]
  • t1 time of the initial manoeuvre [s]
  • t2 time in the left lane [s]
  • d3 clearance between the passing and opposing vehicles [m]

Returns

  • PSD passing sight distance (m) [m]
  • d1 initial manoeuvre distance (m) [m]
  • d2 distance in the left lane (m) [m]
  • d3 clearance (m) [m]
  • d4 opposing vehicle distance (m) [m]

Applies when

  • 0 < m < v
  • a, t1, t2 > 0
  • d3 >= 0
  • AASHTO 2001 four-component model

Example

m.ask("Passing sight distance with speed = 90 km/h, speed difference = 15 km/h, acceleration = 0.64 m/s^2, initial manoeuvre time = 4.3 s, left lane time = 10.4 s and clearance = 60 m.")
→ PSD = 588.833 m, d1 = 95.5001 m, d2 = 260 m, d3 = 60 m, d4 = 173.333 m
Sag vertical curve length for headlight sight distancetransport_sag_curve_headlight

The minimum length of a sag vertical curve for the headlight sight distance S by the AASHTO formulas (headlight 0.6 m high, beam rising 1 degree): L = A S^2/(120 + 3.5 S) when S < L, L = 2S - (120 + 3.5 S)/A when S > L, A = g2 - g1 in percent.

L = \frac{A S^2}{120 + 3.5 S}\ (S < L),\quad L = 2S - \frac{120 + 3.5S}{A}\ (S > L)

Inputs

  • g1 entering grade, decimal
  • g2 leaving grade, decimal
  • S headlight sight distance [m]

Returns

  • L minimum curve length (m) [m]
  • A algebraic grade difference (%)
  • K rate of vertical curvature L/A (m per %)
  • case S < L or S > L

Applies when

  • g2 > g1 (a sag)
  • AASHTO headlight height 0.6 m and 1 degree upward beam (coefficients 120 and 3.5)

Example

m.ask("Sag vertical curve length with g1 = -3 %, g2 = 2 % and sight distance = 185 m.")
→ L = 222.964 m, A = 5, K = 44.5928, case = S < L
Side friction demanded on a superelevated curvetransport_side_friction_demand

The side friction factor a vehicle needs at speed v on a curve of radius R with superelevation e (negative: the superelevation alone exceeds the demand and friction acts up the slope).

f = \frac{v^2/(gR) - e}{1 + e\,v^2/(gR)}

Inputs

  • v design speed [m/s]
  • R curve radius [m]
  • e superelevation rate, decimal

Returns

  • f side friction factor demanded

Applies when

  • v > 0
  • R > 0

Example

m.ask("Side friction demand with speed = 90 km/h, radius = 250 m and superelevation = 6 %.")
→ f = 0.191908 1
Sight distance available on a curve with a roadside obstructiontransport_sight_distance_from_offset

The sight distance available on a curve of radius R (inside lane centreline) when an obstruction stands at the offset M from that centreline.

S = 2R\,\arccos\left(1 - \frac{M}{R}\right)

Inputs

  • R radius of the inside lane centreline [m]
  • M offset to the obstruction [m]

Returns

  • S available sight distance (m) [m]

Applies when

  • 0 < M < R

Example

m.ask("Sight distance from offset with radius = 300 m and offset = 9 m.")
→ S = 147.339 m
Sight distance available over a crest vertical curvetransport_crest_curve_sight_distance

The sight distance a crest vertical curve of length L between grades g1 and g2 provides (eye height 1.08 m, object height 0.60 m unless stated).

S = \sqrt{\frac{200\left(\sqrt{h_1}+\sqrt{h_2}\right)^2 L}{A}}

Inputs

  • g1 grade before the curve, decimal (positive uphill)
  • g2 grade after the curve, decimal
  • L curve length [m]
  • h1 driver eye height (default 1.08 m) [m] optional
  • h2 object height (default 0.60 m) [m] optional

Returns

  • S available sight distance (m) [m]
  • case S < L or S > L

Applies when

  • g1 > g2
  • L >= 0

Example

m.ask("Crest vertical curve sight distance with g1 = 3 %, g2 = -2 % and curve length = 300 m.")
→ S = 198.695 m, case = S < L
Superelevation required on a horizontal curvetransport_superelevation_required

The superelevation rate needed at speed v on a curve of radius R when the side friction factor f is used.

e = \frac{v^2/(gR) - f}{1 + f\,v^2/(gR)}

Inputs

  • v design speed [m/s]
  • R curve radius [m]
  • f side friction factor

Returns

  • e superelevation rate (decimal)
  • e_percent superelevation rate (%)

Applies when

  • v > 0
  • R > 0
  • f >= 0

Example

m.ask("Superelevation required with speed = 100 km/h, radius = 450 m and side friction = 0.12.")
→ e = 0.0536632 1, e_percent = 5.36632

Mode choice 5

Direct and cross elasticities of logit choice probabilitiestransport_logit_elasticities

Point elasticities of logit probabilities with respect to an attribute x (such as cost or time) that enters the utility linearly with coefficient beta: direct E_ii = beta x_i (1 - P_i) and cross E_ji = -beta x_i P_i (the same for every other alternative j, the IIA property).

E^{P_i}_{x_i} = \beta x_i (1 - P_i),\quad E^{P_j}_{x_i} = -\beta x_i P_i

Inputs

  • V utility of each alternative vector
  • x value of the attribute for each alternative vector
  • beta coefficient of the attribute

Returns

  • P probability of each alternative
  • direct direct elasticity of each alternative
  • cross cross elasticity of the other alternatives with respect to each alternative's attribute

Applies when

  • one attribute value per alternative

Example

m.ask("Logit elasticities with utilities = [-1.2, -0.8, -2.1], attribute = [30, 45, 20] and beta = -0.04.")
→ P = [0.345018612617, 0.514707287448, 0.140274099936], direct = [-0.78597766486, -0.873526882594, -0.687780720051], cross = [0.41402233514, 0.926473117406, 0.112219279949]
Logit mode choice from attributes and coefficientstransport_logit_from_attributes

Utilities V_i = ASC_i + sum_k beta_k x_ik of each mode from its attributes (rows of X: modes; columns: attributes such as time in min and cost) and the coefficients, and the resulting logit choice probabilities.

V_i = ASC_i + \sum_k \beta_k x_{ik},\quad P_i = \frac{e^{V_i}}{\sum_j e^{V_j}}

Inputs

  • X attributes: one row per mode, one column per attribute matrix
  • beta coefficient of each attribute vector
  • asc alternative-specific constant of each mode (default 0) vector optional

Returns

  • V utility of each mode
  • P probability of each mode

Applies when

  • one coefficient per attribute column
  • at least two modes

Example

m.ask("Logit from attributes with attributes = [30 2.5; 45 1.5; 60 0.8], coefficients = [-0.05, -0.4] and constants = [0, -0.5, -1].")
→ V = [-2.5, -3.35, -4.32], P = [0.629152135572, 0.268909017211, 0.101938847218]
Multinomial logit mode shares from utilitiestransport_logit_mode_shares

Choice probabilities (mode shares) of a multinomial logit model from the systematic utilities of the alternatives, and the logsum (expected maximum utility).

P_i = \frac{e^{V_i}}{\sum_j e^{V_j}}

Inputs

  • V utility of each alternative vector

Returns

  • P probability of each alternative
  • logsum logsum ln(sum exp V)

Applies when

  • at least two alternatives

Example

m.ask("Logit mode shares with utilities = [-1.2, -0.8, -2.1].")
→ P = [0.345018612617, 0.514707287448, 0.140274099936], logsum = -0.135843
Nested logit choice probabilitiestransport_nested_logit

Choice probabilities of a two-level nested logit model (for example car / public transport nests holding bus and rail): alternatives grouped into nests 1..K with dissimilarity (logsum) parameters lam_k in (0, 1]; also the probability of each nest.

P_i = \frac{e^{V_i/\lambda_k}}{e^{I_k}}\cdot\frac{e^{\lambda_k I_k}}{\sum_m e^{\lambda_m I_m}},\quad I_k = \ln\sum_{j\in k} e^{V_j/\lambda_k}

Inputs

  • V utility of each alternative vector
  • nest nest number (1, 2, ...) of each alternative vector
  • lam dissimilarity parameter of each nest, in (0, 1] vector

Returns

  • P probability of each alternative
  • P_nest probability of each nest

Applies when

  • nests numbered 1..K, each used
  • 0 < lam_k <= 1

Example

m.ask("Nested logit with utilities = [-0.5, -1.2, -1], nests = [1, 2, 2] and nest parameters = [1, 0.5].")
→ P = [0.560574109573, 0.176347032294, 0.263078858132], P_nest = [0.560574109573, 0.439425890427]
User benefit of a change from the logit logsumtransport_logsum_user_benefit

Change in consumer surplus per trip (in money units) when the utilities of the alternatives change from V0 to V1, from the difference of the logsums divided by the (negative) cost coefficient.

\Delta CS = \frac{1}{-\beta_c}\left[\ln\sum_j e^{V^1_j} - \ln\sum_j e^{V^0_j}\right]

Inputs

  • V0 utilities before the change vector
  • V1 utilities after the change vector
  • beta_cost cost coefficient (utility per money unit, negative)

Returns

  • dCS change in consumer surplus per trip (money units)
  • logsum0 logsum before
  • logsum1 logsum after

Applies when

  • same alternatives before and after
  • beta_cost < 0

Example

m.ask("Logsum user benefit with utilities before = [-1.2, -0.8, -2.1], utilities after = [-1.2, -0.5, -1.6] and cost coefficient = -0.25.")
→ dCS = 0.959448, logsum0 = -0.135843, logsum1 = 0.104019

Queueing 5

Blocking probability with no waiting room (Erlang B), e.g. parking spacestransport_erlang_b_blocking

Arrivals at lam (veh/h) to c spaces or servers held for a mean time 1/mu with no waiting room (a car park, loading bays, taxi ranks): the probability an arrival is turned away (Erlang B), the mean number of occupied spaces and the vehicles lost per hour. Rates in veh/h.

B(c, a) = \frac{a^c/c!}{\sum_{k=0}^{c} a^k/k!}

Inputs

  • lam arrival rate (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • mu service rate per server (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • c number of spaces or servers (whole number) integer

Returns

  • P_block probability an arrival is turned away
  • carried mean number of occupied spaces
  • lost_per_h vehicles turned away (veh/h) [1/h]

Applies when

  • 1 <= c <= 1000

Example

m.ask("Erlang b blocking with arrival rate = 60 veh/h, service rate = 0.5 veh/h and spaces = 120.")
→ P_block = 0.0694188, carried = 111.67, lost_per_h = 4.16513 1/h
First-come-first-served queue from arrival and service timestransport_fifo_queue_simulation

Waiting time of every vehicle (or passenger) at c identical servers in first-come-first-served order from given arrival times and service times (a toll plaza, a bus stop with c berths): mean and longest wait, mean time in the system, when the last one leaves and the longest waiting line. Times in s.

S_n = \max(A_n,\ \min_j F_j),\quad W_n = S_n - A_n

Inputs

  • arrivals arrival times in s, increasing vector
  • service service times in s (one per arrival, or one for all) vector
  • c number of servers (default 1) integer optional

Returns

  • waits waiting time of each arrival (s)
  • mean_wait mean waiting time (s) [s]
  • max_wait longest wait (s) [s]
  • mean_time_in_system mean time in the system (s) [s]
  • last_departure time the last one leaves (s) [s]
  • max_queue longest waiting line

Applies when

  • arrival times increasing
  • service times > 0
  • c >= 1

Example

m.ask("Fifo queue simulation with arrivals = [0, 5, 7, 12, 14, 20, 21] and service = [8, 6, 9, 4, 7, 5, 6].")
→ waits = [0.0, 3.0, 7.0, 11.0, 13.0, 14.0, 18.0], mean_wait = 9.42857 s, max_wait = 18 s, mean_time_in_system = 15.8571 s, last_departure = 45 s, max_queue = 4
Multi-server random queue (M/M/c, Erlang C), e.g. a toll plazatransport_mmc_queue

Poisson arrivals at lam served by c parallel exponential servers at mu each (toll lanes, loading bays, ticket windows): probability of waiting (Erlang C), mean queue, mean wait, mean time in the system and mean number in the system. Rates in veh/h.

P_W = \frac{\frac{a^c}{c!}\frac{1}{1-\rho}}{\sum_{k=0}^{c-1}\frac{a^k}{k!} + \frac{a^c}{c!}\frac{1}{1-\rho}},\quad L_q = P_W\frac{\rho}{1-\rho}

Inputs

  • lam arrival rate (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • mu service rate per server (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • c number of servers (whole number) integer

Returns

  • P_wait probability an arrival waits (Erlang C)
  • Lq mean number waiting (veh)
  • Wq mean waiting time (s) [s]
  • W mean time in the system (s) [s]
  • L mean number in the system (veh)

Applies when

  • lam < c mu
  • 1 <= c <= 200

Example

m.ask("Multi server random queue with arrival rate = 1500 veh/h, service rate = 400 veh/h and servers = 5.")
→ P_wait = 0.461789, Lq = 1.38537, Wq = 3.32488 s, W = 12.3249 s, L = 5.13537
Single server with constant service time (M/D/1)transport_md1_queue

Poisson arrivals at lam and a constant service time 1/mu (an automated toll gate, a ramp meter): mean queue, mean wait, mean time in the system and mean number in the system. Rates in veh/h.

L_q = \frac{\rho^2}{2(1-\rho)},\quad W_q = \frac{\rho}{2\mu(1-\rho)}

Inputs

  • lam arrival rate (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • mu service rate per server (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]

Returns

  • Lq mean number waiting (veh)
  • Wq mean waiting time (s) [s]
  • W mean time in the system (s) [s]
  • L mean number in the system (veh)

Applies when

  • lam < mu

Example

m.ask("Constant service time queue with arrival rate = 400 veh/h and service rate = 500 veh/h.")
→ Lq = 1.6, Wq = 14.4 s, W = 21.6 s, L = 2.4
Single-server random queue (M/M/1), e.g. a toll boothtransport_mm1_queue

Poisson arrivals at lam and exponential service at mu at one server (a toll booth, a ramp meter): utilisation, mean number in the system and in the queue, mean time in the system and waiting, and the probability that the server is idle. Rates in veh/h.

L = \frac{\rho}{1-\rho},\quad W = \frac{1}{\mu - \lambda},\quad W_q = \frac{\rho}{\mu - \lambda}

Inputs

  • lam arrival rate (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • mu service rate per server (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]

Returns

  • rho utilisation lam / mu
  • L mean number in the system (veh)
  • Lq mean number waiting (veh)
  • W mean time in the system (s) [s]
  • Wq mean waiting time (s) [s]
  • P0 probability the system is empty

Applies when

  • lam < mu

Example

m.ask("Single server random queue with arrival rate = 400 veh/h and service rate = 500 veh/h.")
→ rho = 0.8, L = 4, Lq = 3.2, W = 36 s, Wq = 28.8 s, P0 = 0.2

Railway operations 4

Minimum headway of trains at a station stop (moving block)transport_rail_station_headway

Shortest headway between trains serving a station under a brick-wall (moving-block) separation: the leader dwells t_d, accelerates at a until its rear clears the platform plus the safety margin s_m, while the follower approaches at the line speed v and brakes at b to stop at the platform; and the corresponding line capacity in trains per hour.

h = t_d + \sqrt{\frac{2(L_t + s_m)}{a}} + \frac{v}{b}

Inputs

  • v line (approach) speed [m/s]
  • a acceleration [m/s^2]
  • b braking rate [m/s^2]
  • L_t train length [m]
  • t_d dwell time [s]
  • s_m safety margin (default 0) [m] optional

Returns

  • h minimum headway (s) [s]
  • trains_per_h line capacity (trains/h) [1/h]

Applies when

  • v, a, b, L_t > 0
  • t_d, s_m >= 0

Example

m.ask("Station headway with line speed = 80 km/h, acceleration = 1 m/s^2, braking rate = 1.1 m/s^2, train length = 150 m, dwell time = 30 s and safety margin = 50 m.")
→ h = 70.202 s, trains_per_h = 51.2806 1/h
Running time between stations (accelerate, cruise, brake)transport_train_running_time

Minimum running time of a train (or bus) between two stops a distance D apart with acceleration a, braking rate b and line speed v_max; when the stops are too close to reach v_max the profile is accelerate-brake.

T = \frac{D}{v} + \frac{v}{2a} + \frac{v}{2b}

Inputs

  • D distance between stops [m]
  • v_max maximum (line) speed [m/s]
  • a acceleration [m/s^2]
  • b braking rate [m/s^2]

Returns

  • T running time stop to stop (s) [s]
  • v_peak highest speed reached (m/s) [m/s]
  • profile accelerate-cruise-brake or accelerate-brake

Applies when

  • all inputs positive

Example

m.ask("Train running time with distance = 1.5 km, line speed = 80 km/h, acceleration = 1 m/s^2 and braking rate = 1.2 m/s^2.")
→ T = 87.8704 s, v_peak = 22.2222 m/s, profile = accelerate-cruise-brake
Train acceleration time and distance (tractive effort curve, Davis resistance)transport_train_acceleration

Time and distance for a train to accelerate from v1 to v2 with a tractive effort F_max up to the speed P / F_max and constant power P above it, against the Davis resistance A + B v + C v^2 and the gradient, with a rotating-mass factor gamma.

t = \int_{v_1}^{v_2}\frac{\gamma m\,dv}{\min(F_{max}, P/v) - (A + Bv + Cv^2) - mg\sin\theta}

Inputs

  • m train mass [kg]
  • v1 initial speed [m/s]
  • v2 final speed [m/s]
  • F_max maximum (starting) tractive effort [N]
  • P power at the wheel rim [W]
  • A Davis coefficient A (constant resistance) [N]
  • B Davis coefficient B (per speed) [N*s/m]
  • C Davis coefficient C (per speed squared) [N*s^2/m^2]
  • G grade, decimal (positive uphill) optional
  • gamma rotating-mass factor (default 1.08) optional

Returns

  • t acceleration time (s) [s]
  • d distance travelled (m) [m]

Applies when

  • tractive effort exceeds resistance up to v2
  • v2 > v1 >= 0

Example

m.ask("Train acceleration with mass = 400 t, initial speed = 0 km/h, final speed = 100 km/h, tractive effort = 150 kN, power = 4000 kW, davis a = 6 kN, davis b = 0.05 kN/(km/h) and davis c = 0.0008 kN/(km/h)^2.")
→ t = 86.5875 s, d = 1222.69 m
Train braking distance with Davis resistance and gradienttransport_train_braking_distance

Braking distance and time of a train of mass m braking with a constant brake force F_b from v1 to v2, helped by the Davis train resistance R = A + B v + C v^2 and the gradient (positive uphill), with a rotating-mass factor gamma.

S = \int_{v_2}^{v_1}\frac{\gamma m\,v\,dv}{F_b + A + Bv + Cv^2 + mg\sin\theta}

Inputs

  • m train mass [kg]
  • v1 initial speed [m/s]
  • F_b brake force [N]
  • A Davis coefficient A (constant resistance) [N]
  • B Davis coefficient B (per speed) [N*s/m]
  • C Davis coefficient C (per speed squared) [N*s^2/m^2]
  • G grade, decimal (positive uphill) optional
  • gamma rotating-mass factor (default 1.06) optional
  • v2 final speed (default 0) [m/s] optional

Returns

  • S braking distance (m) [m]
  • t braking time (s) [s]

Applies when

  • F_b + R(v) + grade force > 0 over the speed range
  • v2 < v1

Example

m.ask("Train braking distance with mass = 400 t, initial speed = 120 km/h, brake force = 320 kN, davis a = 6 kN, davis b = 0.05 kN/(km/h) and davis c = 0.0008 kN/(km/h)^2.")
→ S = 701.698 m, t = 42.4729 s

Route planning 2

Fastest route on a road network (link lengths and speeds)transport_fastest_route

The quickest route between two places on a road network whose links are given by length (km) and speed (km/h): the route, its travel time in minutes and its length in km. Roads are two-way unless directed = yes.

t_{link} = \frac{60\,L}{v},\quad \min \sum t_{link}

Inputs

  • roads roads as 'A-B length' with lengths in km edges
  • speeds speed on each road in km/h, in the same order vector
  • origin starting place text
  • destination destination text
  • directed one-way links as written (default no) boolean optional

Returns

  • route fastest route (places joined by '-')
  • time travel time (min) [min]
  • distance route length (km) [km]

Applies when

  • one positive length and speed per road
  • the destination is reachable

Example

m.ask("Fastest route with roads = [A-B 4, A-C 2.5, B-C 1.2, B-D 5, C-D 8, C-E 10, D-E 2], speeds = [60, 50, 40, 80, 100, 90, 50], origin = A and destination = E.")
→ route = A-C-E, time = 9.66667 min, distance = 12.5 km
Zone-to-zone travel time matrix (skim) of a road networktransport_travel_time_skim

The fastest travel time in minutes between every pair of places of a road network given by link lengths (km) and speeds (km/h), as a matrix in alphabetical order of the places (the skim used for trip distribution).

t_{ij} = \min_{paths\ i \to j} \sum t_{link}

Inputs

  • roads roads as 'A-B length' with lengths in km edges
  • speeds speed on each road in km/h, in the same order vector
  • directed one-way links as written (default no) boolean optional

Returns

  • places places in the order of the matrix
  • times travel time matrix (min)

Applies when

  • every place reachable
  • at most 60 places

Example

m.ask("Travel time skim with roads = [A-B 4, A-C 2.5, B-C 1.2, B-D 5, C-D 8, C-E 10, D-E 2] and speeds = [60, 50, 40, 80, 100, 90, 50].")
→ places = A, B, C, D, E, times = [[0.0, 4.0, 3.0, 7.75, 9.66666666667], [4.0, 0.0, 1.8, 3.75, 6.15], [3.0, 1.8, 0.0, 4.8, 6.66666666667], [7.75, 3.75, 4.8, 0.0, 2.4], [9.66666666667, 6.15, 6.66666666667, 2.4, 0.0]]

Traffic flow 14

Fit the Greenberg (logarithmic) model to speed-density observationstransport_greenberg_fit

Least-squares fit of Greenberg's model v = v0 ln(kj / k) (v against ln k) to observed speeds (km/h) and densities (veh/km): the optimum speed v0, jam density, capacity v0 kj / e and the coefficient of determination.

v = v_0 \ln\frac{k_j}{k},\quad q_{max} = \frac{v_0 k_j}{e}

Inputs

  • speeds observed space-mean speeds in km/h vector
  • densities observed densities in veh/km, in the same order vector

Returns

  • v0 optimum speed v0 (km/h) [km/h]
  • kj jam density (veh/km) [1/km]
  • q_max capacity (veh/h) [1/h]
  • r2 coefficient of determination (v on ln k)

Applies when

  • at least three observations
  • speeds fall with density

Example

m.ask("Greenberg fit with speeds = [82, 70, 58, 47, 33, 21] and densities = [18, 32, 46, 60, 78, 95].")
→ v0 = 36.4384 km/h, kj = 197.836 1/km, q_max = 2651.98 1/h, r2 = 0.957329
Fit the Greenshields model to speed-density observationstransport_greenshields_fit

Least-squares fit of Greenshields' line v = vf - (vf/kj) k to observed speeds (km/h) and densities (veh/km): the free-flow speed, jam density, capacity and the coefficient of determination of the line.

v = v_f - \frac{v_f}{k_j} k,\quad q_{max} = \frac{v_f k_j}{4}

Inputs

  • speeds observed space-mean speeds in km/h vector
  • densities observed densities in veh/km, in the same order vector

Returns

  • vf free-flow speed (km/h) [km/h]
  • kj jam density (veh/km) [1/km]
  • q_max capacity (veh/h) [1/h]
  • r2 coefficient of determination of the fit

Applies when

  • at least three observations
  • speeds fall with density

Example

m.ask("Greenshields fit with speeds = [82, 70, 58, 47, 33, 21] and densities = [18, 32, 46, 60, 78, 95].")
→ vf = 95.3537 km/h, kj = 120.141 1/km, q_max = 2863.96 1/h, r2 = 0.99869
Fit the Underwood (exponential) model to speed-density observationstransport_underwood_fit

Least-squares fit of Underwood's model v = vf exp(-k / k0) (ln v against k) to observed speeds (km/h) and densities (veh/km): the free-flow speed, the optimum density k0, capacity vf k0 / e and the coefficient of determination.

v = v_f\,e^{-k/k_0},\quad q_{max} = \frac{v_f k_0}{e}

Inputs

  • speeds observed space-mean speeds in km/h vector
  • densities observed densities in veh/km, in the same order vector

Returns

  • vf free-flow speed (km/h) [km/h]
  • k0 optimum density (veh/km) [1/km]
  • q_max capacity (veh/h) [1/h]
  • r2 coefficient of determination (ln v on k)

Applies when

  • at least three observations
  • speeds fall with density

Example

m.ask("Underwood fit with speeds = [82, 70, 58, 47, 33, 21] and densities = [18, 32, 46, 60, 78, 95].")
→ vf = 122.302 km/h, k0 = 57.396 1/km, q_max = 2582.38 1/h, r2 = 0.974956
Greenberg model: capacity and density at capacitytransport_greenberg_capacity

Capacity of a traffic stream following Greenberg's model v = v0 ln(kj / k) and the density at which it occurs (the speed there is v0).

q_{max} = \frac{v_0 k_j}{e}

Inputs

  • v0 optimum speed v0 [m/s]
  • kj jam density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]

Returns

  • q_max capacity (veh/h) [1/h]
  • k_m density at capacity (veh/km) [1/km]

Applies when

  • v0 > 0
  • kj > 0

Example

m.ask("Greenberg capacity with optimum speed = 30 km/h and jam density = 140 veh/km.")
→ q_max = 1545.09 1/h, k_m = 51.5031 1/km
Greenshields model: capacity, optimum speed and densitytransport_greenshields_capacity

Capacity (maximum flow) of a traffic stream following Greenshields' linear speed-density model v = vf (1 - k/kj), with the density and speed at which it occurs.

q_{max} = \frac{v_f k_j}{4},\quad k_m = \frac{k_j}{2},\quad v_m = \frac{v_f}{2}

Inputs

  • vf free-flow speed [m/s]
  • kj jam density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]

Returns

  • q_max capacity (veh/h) [1/h]
  • k_m density at capacity (veh/km) [1/km]
  • v_m speed at capacity (km/h) [km/h]

Applies when

  • vf > 0
  • kj > 0

Example

m.ask("Greenshields capacity with free flow speed = 100 km/h and jam density = 120 veh/km.")
→ q_max = 3000 1/h, k_m = 60 1/km, v_m = 50 km/h
Greenshields model: densities and speeds at a given flowtransport_greenshields_speed_at_flow

The two traffic states (uncongested and congested) of a Greenshields stream that carry the flow q: their densities and speeds.

k = \frac{k_j}{2}\left(1 \mp \sqrt{1 - \frac{4q}{v_f k_j}}\right)

Inputs

  • vf free-flow speed [m/s]
  • kj jam density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]
  • q traffic flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]

Returns

  • k_1 uncongested density (veh/km) [1/km]
  • v_1 uncongested speed (km/h) [km/h]
  • k_2 congested density (veh/km) [1/km]
  • v_2 congested speed (km/h) [km/h]

Applies when

  • 0 < q <= vf kj / 4

Example

m.ask("Greenshields speed at a flow with free flow speed = 100 km/h, jam density = 120 veh/km and flow = 2000 veh/h.")
→ k_1 = 25.359 1/km, v_1 = 78.8675 km/h, k_2 = 94.641 1/km, v_2 = 21.1325 km/h
Probability of a headway longer than h (negative exponential)transport_headway_probability

Probability that the time headway between random vehicles at flow q is at least h (and shorter than h), for the negative exponential distribution or the shifted one with a minimum headway tau.

P(H \ge h) = e^{-(h-\tau)/(\bar h - \tau)},\ \bar h = 1/q

Inputs

  • q traffic flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • h headway [s]
  • tau minimum headway (default 0) [s] optional

Returns

  • P_ge P(headway >= h)
  • P_lt P(headway < h)

Applies when

  • q > 0
  • tau < 1/q

Example

m.ask("Headway probability with flow = 600 veh/h and headway = 8 s.")
→ P_ge = 0.263597, P_lt = 0.736403
Probability of n vehicle arrivals in an interval (Poisson)transport_poisson_arrivals

Probability that exactly n, at most n and at least n vehicles arrive in an interval t when arrivals are random (Poisson) at the flow q.

P(n) = \frac{(qt)^n e^{-qt}}{n!}

Inputs

  • q traffic flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • t interval length [s]
  • n number of arrivals (whole number) integer

Returns

  • P_n P(exactly n arrivals)
  • P_le P(at most n arrivals)
  • P_ge P(at least n arrivals)

Applies when

  • q > 0
  • t > 0
  • n a whole number >= 0

Example

m.ask("Poisson arrivals with flow = 360 veh/h, interval = 30 s and arrivals = 2.")
→ P_n = 0.224042, P_le = 0.42319, P_ge = 0.800852
Queue and delay at a temporary bottleneck (incident, lane closure)transport_bottleneck_queue

Deterministic queue when the capacity of a road falls from mu to mu_r for a time t_r (an incident or a work zone) while vehicles arrive at lam: the longest queue, how long the queue lasts and the total delay.

Q_{max} = (\lambda - \mu_r) t_r,\quad T = t_r + \frac{Q_{max}}{\mu - \lambda},\quad D = \tfrac12 Q_{max} T

Inputs

  • lam arrival flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • mu normal capacity (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • mu_r reduced capacity (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • t_r duration of the reduction [s]

Returns

  • Q_max longest queue (veh)
  • T duration of the queue from the start of the reduction (s) [s]
  • T_min duration of the queue (min) [min]
  • D_total total delay (veh h) [h]

Applies when

  • mu_r < lam < mu

Example

m.ask("Bottleneck queue with arrival flow = 3200 veh/h, capacity = 4000 veh/h, reduced capacity = 1800 veh/h and duration = 30 min.")
→ Q_max = 700, T = 4950 s, T_min = 82.5 min, D_total = 481.25 h
Queue from arrival counts and capacity per intervaltransport_interval_queue

Vehicles queued at the end of each counting interval when the arrivals per interval are served up to the capacity per interval (deterministic queue, first in first out), the longest queue and the vehicles served per interval.

Q_k = \max\left(0,\ Q_{k-1} + a_k - c_k\right)

Inputs

  • arrivals arrivals in each interval (veh) vector
  • capacity capacity of each interval (veh), or one value for all vector

Returns

  • queue queue at the end of each interval (veh)
  • Q_max longest queue (veh)
  • served vehicles served in each interval (veh)

Applies when

  • counts >= 0
  • capacity: one value or one per interval

Example

m.ask("Interval queue with arrivals = [90, 120, 140, 110, 80, 60] and capacity = [100].")
→ queue = [0.0, 20.0, 60.0, 70.0, 50.0, 10.0], Q_max = 70, served = [90.0, 100.0, 100.0, 100.0, 100.0, 100.0]
Shockwave speed between two traffic statestransport_shockwave_speed

Speed of the boundary (shockwave) between an upstream traffic state (q1, k1) and a downstream state (q2, k2): u = (q2 - q1) / (k2 - k1), negative when it moves upstream (for example the back of a queue).

u_w = \frac{q_2 - q_1}{k_2 - k_1}

Inputs

  • q1 upstream flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • k1 upstream density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]
  • q2 downstream flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • k2 downstream density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]

Returns

  • u shockwave speed (km/h), positive downstream [km/h]
  • u_ms shockwave speed (m/s) [m/s]
  • direction upstream, downstream or stationary

Applies when

  • k1, k2 > 0, q1, q2 >= 0
  • the denser state is the slower one

Example

m.ask("Shockwave speed with upstream flow = 1800 veh/h, upstream density = 25 veh/km, downstream flow = 1200 veh/h and downstream density = 80 veh/km.")
→ u = -10.9091 km/h, u_ms = -3.0303 m/s, direction = upstream
Shockwave speed in a Greenshields traffic streamtransport_greenshields_shockwave

Speed of the shockwave between two states of a Greenshields stream with densities k1 (upstream) < k2 (downstream): u = vf (1 - (k1 + k2) / kj).

u_w = v_f\left(1 - \frac{k_1 + k_2}{k_j}\right)

Inputs

  • vf free-flow speed [m/s]
  • kj jam density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]
  • k1 upstream density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]
  • k2 downstream density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]

Returns

  • u shockwave speed (km/h), positive downstream [km/h]
  • u_ms shockwave speed (m/s) [m/s]

Applies when

  • 0 < k1 < k2 < kj

Example

m.ask("Greenshields shockwave with free flow speed = 90 km/h, jam density = 130 veh/km, upstream density = 30 veh/km and downstream density = 90 veh/km.")
→ u = 6.92308 km/h, u_ms = 1.92308 m/s
Travel-time reliability indices (buffer, planning time, travel time index)transport_travel_time_reliability

The buffer index (T95 - mean)/mean, the planning time index T95/T_free and the travel time index mean/T_free of observed travel times on a route (T95 the 95th percentile by linear interpolation). Times in minutes.

BI = \frac{T_{95} - \bar T}{\bar T},\quad PTI = \frac{T_{95}}{T_{free}},\quad TTI = \frac{\bar T}{T_{free}}

Inputs

  • times observed travel times in min vector
  • t_free free-flow travel time in min

Returns

  • mean mean travel time (min)
  • t95 95th-percentile travel time (min)
  • buffer_index buffer index (T95 - mean)/mean
  • planning_time_index planning time index T95/T_free
  • travel_time_index travel time index mean/T_free

Applies when

  • at least five positive travel times
  • T95 by linear interpolation (type 7)

Example

m.ask("Travel time reliability indices with travel times = [22, 25, 24, 30, 27, 23, 35, 26, 24, 28] and free flow time = 18 min.")
→ mean = 26.4, t95 = 32.75, buffer_index = 0.24053, planning_time_index = 1.81944, travel_time_index = 1.46667
Underwood model: capacity and speed at capacitytransport_underwood_capacity

Capacity of a traffic stream following Underwood's model v = vf exp(-k / k0), with the speed and density at capacity.

q_{max} = \frac{v_f k_0}{e},\quad v_m = \frac{v_f}{e}

Inputs

  • vf free-flow speed [m/s]
  • k0 optimum density k0 (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]

Returns

  • q_max capacity (veh/h) [1/h]
  • v_m speed at capacity (km/h) [km/h]
  • k_m density at capacity (veh/km) [1/km]

Applies when

  • vf > 0
  • k0 > 0

Example

m.ask("Underwood capacity with free flow speed = 100 km/h and optimum density = 50 veh/km.")
→ q_max = 1839.4 1/h, v_m = 36.7879 km/h, k_m = 50 1/km

Traffic signals 5

Green splits by equal degree of saturation (flow-ratio method)transport_signal_green_splits

Effective green time of each critical phase for a given cycle C and total lost time L, shared in proportion to the critical flow ratios y_i = v_i / s_i (equal degree of saturation), and the critical degree of saturation X_c. Greens in s.

g_i = \frac{y_i}{Y}(C - L),\quad X_c = \frac{Y\,C}{C - L}

Inputs

  • C cycle length [s]
  • L total lost time per cycle [s]
  • y critical flow ratio v/s of each phase vector

Returns

  • g effective green of each phase (s)
  • X_c critical degree of saturation

Applies when

  • C > L
  • sum of y < 1

Example

m.ask("Signal green splits with cycle = 90 s, lost time = 10 s and flow ratios = [0.3, 0.25, 0.15].")
→ g = [34.2857142857, 28.5714285714, 17.1428571429], X_c = 0.7875
Optimum cycle length by Webster's formulatransport_webster_optimum_cycle

Webster's optimum cycle length C0 = (1.5 L + 5)/(1 - Y) of a fixed-time signal from the total lost time L (s) and the critical flow ratios y_i = v_i/s_i (Y = sum y_i), with the minimum cycle L/(1 - Y) and the total effective green. Times in s.

C_0 = \frac{1.5L + 5}{1 - Y}

Inputs

  • L total lost time per cycle [s]
  • y critical flow ratio v/s of each phase vector

Returns

  • C0 Webster optimum cycle length (s) [s]
  • Y sum of the critical flow ratios
  • C_min minimum cycle length L/(1 - Y) (s) [s]
  • green_total total effective green C0 - L (s) [s]

Applies when

  • 0 < y_i < 1
  • Y < 0.95
  • fixed-time signal, Webster's delay model

Example

m.ask("Webster optimum cycle length with lost time = 12 s and flow ratios = [0.3, 0.25, 0.15].")
→ C0 = 76.6667 s, Y = 0.7, C_min = 40 s, green_total = 64.6667 s
Queue and uniform delay at a signal (deterministic D/D/1)transport_signal_queue_uniform_delay

Uniform arrivals at a fixed-time signal with saturation flow s, effective red r and effective green g (undersaturated): the largest queue, the time after the start of green until it clears, the total delay per cycle, the average (uniform) delay per vehicle and the share of vehicles that stop.

d = \frac{r^2}{2C\,(1 - \lambda/s)} = \frac{C (1 - g/C)^2}{2 (1 - \lambda/s)}

Inputs

  • lam arrival flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • s saturation flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • r effective red [s]
  • g effective green [s]

Returns

  • Q_max largest queue (veh)
  • t_clear time after the start of green to clear the queue (s) [s]
  • D_total total delay per cycle (veh s) [s]
  • d_uniform average delay per vehicle (s) [s]
  • P_stopped share of vehicles that stop

Applies when

  • lam < s
  • the queue clears within the green (lam C <= s g)

Example

m.ask("Signal queue and uniform delay with arrival flow = 600 veh/h, saturation flow = 1800 veh/h, red = 40 s and green = 30 s.")
→ Q_max = 6.66667, t_clear = 20 s, D_total = 200 s, d_uniform = 17.1429 s, P_stopped = 0.857143
Queue at a signal by shockwave analysistransport_signal_queue_shockwave

Kinematic-wave analysis of a signal: the queue grows upstream during the red at the shock speed between the arrival state (q_a, k_a) and jam density k_j, and from the start of green the discharge wave (saturation state q_s, k_s) chases it. The longest queue, the time it is reached (from the start of red) and both wave speeds.

t^* = \frac{w_2\, r}{w_2 - w_1},\quad L_{max} = -w_1 t^*

Inputs

  • q_a arrival flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • k_a arrival density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]
  • k_j jam density (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]
  • q_s saturation (discharge) flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • k_s density of the discharging stream (veh/km in questions; veh/m in solve(), or '25 1/km') [1/m]
  • r red time [s]

Returns

  • L_max longest queue (m) [m]
  • t_max time from the start of red to the longest queue (s) [s]
  • w_queue speed of the back of the queue (km/h) [km/h]
  • w_discharge speed of the discharge wave (km/h) [km/h]

Applies when

  • k_a, k_s < k_j
  • the discharge wave is faster than the queue growth

Example

m.ask("Queue at a signal by shockwave analysis with arrival flow = 1000 veh/h, arrival density = 20 veh/km, jam density = 140 veh/km, saturation flow = 1800 veh/h, discharge density = 50 veh/km and red time = 40 s.")
→ L_max = 158.73 m, t_max = 68.5714 s, w_queue = -8.33333 km/h, w_discharge = -20 km/h
Yellow change interval (kinematic, ITE)transport_yellow_change_interval

Minimum yellow change interval Y = t_r + v / (2a + 2gG) so that a driver who is just too close to stop can clear at the approach speed, and the critical stopping distance from the stop line.

Y = t_r + \frac{v}{2a + 2gG}

Inputs

  • v approach speed [m/s]
  • t_r perception-reaction time [s]
  • a comfortable deceleration rate [m/s^2]
  • G grade, decimal (positive uphill) optional

Returns

  • Y yellow change interval (s) [s]
  • x_c critical stopping distance (m) [m]

Applies when

  • v > 0
  • a + g G > 0

Example

m.ask("Yellow change interval with speed = 50 km/h, reaction time = 1 s and deceleration = 3.05 m/s^2.")
→ Y = 3.27687 s, x_c = 45.512 m

Traffic studies 2

85th, 50th and 15th percentile spot speedstransport_spot_speed_percentiles

Percentile speeds of a spot-speed sample (85th percentile for speed limits and design, median, 15th) by linear interpolation between ranks (position (n - 1) p / 100, as Excel PERCENTILE.INC). Speeds in km/h.

v_p = v_{(i)} + f\,(v_{(i+1)} - v_{(i)}),\quad i + f = (n-1)\,p/100

Inputs

  • speeds spot speeds in km/h vector

Returns

  • p85 85th percentile speed (km/h) [km/h]
  • p50 median speed (km/h) [km/h]
  • p15 15th percentile speed (km/h) [km/h]

Applies when

  • at least two positive speeds

Example

m.ask("Spot speed percentiles with speeds = [52, 61, 48, 70, 55, 63, 58, 66, 49, 72].")
→ p85 = 68.6 km/h, p50 = 59.5 km/h, p15 = 50.05 km/h
Time-mean and space-mean speed of spot speedstransport_time_and_space_mean_speed

From spot speeds measured at a point: the time-mean speed (arithmetic mean), the space-mean speed (harmonic mean, the speed that matches travel times over a fixed length) and the sample standard deviation. Speeds in km/h.

\bar v_t = \frac{1}{n}\sum v_i,\quad \bar v_s = \frac{n}{\sum 1/v_i}

Inputs

  • speeds spot speeds in km/h vector

Returns

  • TMS time-mean speed (km/h) [km/h]
  • SMS space-mean speed (km/h) [km/h]
  • s sample standard deviation (km/h) [km/h]

Applies when

  • at least two positive speeds

Example

m.ask("Time mean and space mean speed with speeds = [52, 61, 48, 70, 55, 63].")
→ TMS = 58.1667 km/h, SMS = 57.2529 km/h, s = 8.03534 km/h

Travel demand 4

All-or-nothing traffic assignmenttransport_all_or_nothing_assignment

Loads every origin-destination demand onto its fastest path through a network of one-way links with travel times (min): the flow on each link (in the order given) and the total vehicle-hours travelled.

x_a = \sum_{rs} q_{rs}\,\delta_{a, p^*_{rs}}

Inputs

  • network one-way links as 'A-B time' with travel times in min edges
  • od trip demands as 'origin-destination trips' (veh) edges

Returns

  • flows flow on each link in the order given (veh)
  • VHT vehicle-hours travelled (veh h) [h]

Applies when

  • positive link times
  • every trip pair connected

Example

m.ask("All or nothing assignment with network = [A-B 5, B-A 5, A-C 3, C-A 3, B-D 4, D-B 4, C-D 7, D-C 7, B-C 1, C-B 1] and od = [A-D 800, C-B 200, D-A 300].")
→ flows = [0.0, 0.0, 800.0, 300.0, 800.0, 300.0, 0.0, 0.0, 300.0, 1000.0], VHT = 150 h
Doubly constrained gravity model of trip distributiontransport_gravity_model

Trips between zones T_ij = A_i O_i B_j D_j f(c_ij) that match both the productions O_i and the attractions D_j, with deterrence f(c) = exp(-beta c) or c^-beta, balanced by Furness iterations until every total matches to 1e-13.

T_{ij} = A_i O_i B_j D_j f(c_{ij}),\quad \sum_j T_{ij} = O_i,\ \sum_i T_{ij} = D_j

Inputs

  • O trip productions of the origin zones vector
  • D trip attractions of the destination zones vector
  • costs travel cost (time) matrix, rows origins, in min matrix
  • beta deterrence parameter
  • deterrence exponential (default) or power choice optional

Returns

  • trips trip matrix (rows origins, columns destinations)

Applies when

  • sum of productions = sum of attractions
  • beta >= 0
  • power deterrence: positive costs

Example

m.ask("Gravity model with productions = [1000, 1500, 800], attractions = [1200, 900, 1200], costs = [5 12 20; 10 6 15; 18 14 7] and beta = 0.1.")
→ trips = [[585.291609215, 216.598390059, 198.110000726], [494.749778142, 550.037708887, 455.212512971], [119.958612642, 133.363901055, 546.677486303]]
Growth-factor (Furness) balancing of a trip matrixtransport_furness_balancing

Scales a base-year trip matrix to future row totals (productions) and column totals (attractions) by the Furness (biproportional) method, iterated until every total matches to 1e-13.

T_{ij} = t_{ij}\,a_i\,b_j

Inputs

  • base base-year trip matrix (rows origins) matrix
  • O target row totals (productions) vector
  • D target column totals (attractions) vector

Returns

  • trips balanced trip matrix

Applies when

  • sum of row totals = sum of column totals
  • non-negative base matrix with a positive entry in every row and column

Example

m.ask("Furness balancing with base matrix = [100 200 150; 300 100 250; 50 150 200], productions = [600, 800, 500] and attractions = [550, 600, 750].")
→ trips = [[128.005362822, 275.799789296, 196.194847882], [361.892088736, 129.955182633, 308.15272863], [60.1025484415, 194.24502807, 245.652423488]]
Trip generation by multiple linear regressiontransport_trip_generation_regression

Least-squares trip-generation model trips = b0 + b1 x1 + ... fitted to zonal data (rows of X: zones; columns: households, employment, cars, ...), its coefficient of determination, and optionally the trips predicted for a new zone.

\hat{\mathbf b} = \arg\min \lVert \mathbf y - [\mathbf 1\ X]\mathbf b\rVert^2

Inputs

  • X zonal predictors: one row per zone matrix
  • y observed trips of each zone vector
  • x_new predictors of a zone to forecast (optional) vector optional

Returns

  • coef coefficients b0 (intercept), b1, ...
  • r2 coefficient of determination
  • y_new forecast trips of the new zone

Applies when

  • more zones than coefficients
  • predictors not collinear

Example

m.ask("Trip generation regression with predictors = [120 300; 250 420; 400 380; 180 600; 520 700; 300 250; 450 520], trips = [1450, 2300, 3100, 2050, 4200, 2200, 3600] and new zone = [350, 500].")
→ coef = [258.227672282, 5.71819751176, 1.38738416969], r2 = 0.994434, y_new = 2953.29

Unsignalized intersections 1

Capacity of a minor stream by gap acceptancetransport_gap_acceptance_capacity

Capacity of a minor (stop- or yield-controlled) movement crossing a random major stream of flow q, with critical gap t_c and follow-up time t_f: Harders' formula (as in the HCM) or Siegloch's.

c = \frac{q\,e^{-q t_c}}{1 - e^{-q t_f}}

Inputs

  • q major-stream flow (veh/h in questions; veh/s in solve(), or a string such as '600 1/h') [1/s]
  • t_c critical gap [s]
  • t_f follow-up time [s]
  • model harders (HCM, default) or siegloch choice optional

Returns

  • c capacity of the minor movement (veh/h) [1/h]

Applies when

  • q, t_c, t_f > 0
  • Siegloch: t_c > t_f / 2

Example

m.ask("Gap acceptance capacity with major flow = 800 veh/h, critical gap = 6.5 s and follow up time = 3.3 s.")
→ c = 363.101 1/h

Vehicle dynamics 9

Lateral load transfer in a steady turntransport_lateral_load_transfer

Outer and inner wheel loads of a rigid vehicle (no suspension roll) cornering at lateral acceleration a_y, and the load transferred to the outer wheels.

\Delta W = \frac{m a_y h}{t}

Inputs

  • m vehicle mass [kg]
  • a_y lateral acceleration [m/s^2]
  • h height of the centre of gravity [m]
  • t_w track width [m]

Returns

  • W_out load on the outer wheels (N) [N]
  • W_in load on the inner wheels (N) [N]
  • dW load transferred to the outer wheels (N) [N]

Applies when

  • all inputs positive
  • the inner wheels keep contact

Example

m.ask("Lateral load transfer with mass = 1500 kg, lateral acceleration = 0.6 m/s^2, cg height = 0.55 m and track width = 1.55 m.")
→ W_out = 7676.85 N, W_in = 7038.15 N, dW = 319.355 N
Longitudinal weight transfer under braking and ideal brake proportioningtransport_braking_weight_transfer

Dynamic front and rear axle loads of a vehicle decelerating at a, the load transferred to the front axle, and the ideal front share of the braking force (both axles at the same friction use).

W_f = \frac{W l_r + m a h}{L},\quad \Delta W = \frac{m a h}{L}

Inputs

  • m vehicle mass [kg]
  • a deceleration [m/s^2]
  • h height of the centre of gravity [m]
  • L wheelbase [m]
  • l_f distance from the front axle to the centre of gravity [m]

Returns

  • W_f front axle load (N) [N]
  • W_r rear axle load (N) [N]
  • dW load transferred to the front axle (N) [N]
  • front_share ideal front brake share

Applies when

  • a > 0 (deceleration)
  • 0 < l_f < L
  • the rear axle keeps contact

Example

m.ask("Braking weight transfer with mass = 1500 kg, deceleration = 7 m/s^2, cg height = 0.55 m, wheelbase = 2.7 m and cg to front axle = 1.2 m.")
→ W_f = 10313.9 N, W_r = 4401.11 N, dW = 2138.89 N, front_share = 0.70091
Quarter-car model: body and wheel-hop natural frequenciestransport_quarter_car_frequencies

Undamped natural frequencies of the two-degree-of-freedom quarter-car ride model: the body (bounce) mode and the wheel-hop mode, from the sprung and unsprung masses, suspension and tyre stiffnesses.

m_s m_u\omega^4 - \left[k_s m_u + (k_s + k_t) m_s\right]\omega^2 + k_s k_t = 0

Inputs

  • m_s sprung mass (a quarter of the body) [kg]
  • m_u unsprung mass (wheel) [kg]
  • k_s suspension spring stiffness [N/m]
  • k_t tyre vertical stiffness [N/m]

Returns

  • f_body body (bounce) natural frequency (Hz) [Hz]
  • f_wheel wheel-hop natural frequency (Hz) [Hz]

Applies when

  • all inputs positive

Example

m.ask("Quarter car natural frequencies with sprung mass = 400 kg, unsprung mass = 45 kg, spring stiffness = 25 kN/m and tyre stiffness = 200 kN/m.")
→ f_body = 1.18544 Hz, f_wheel = 11.2619 Hz
Quarter-car model: road-to-body transmissibility at a frequencytransport_quarter_car_transmissibility

Amplitude ratio between body (sprung-mass) motion and road displacement, and between wheel motion and road displacement, of the damped quarter-car model for a sinusoidal road input of frequency f.

\left(K + i\omega C - \omega^2 M\right)\mathbf Z = \begin{bmatrix}0\\ k_t\end{bmatrix} Z_r

Inputs

  • m_s sprung mass (a quarter of the body) [kg]
  • m_u unsprung mass (wheel) [kg]
  • k_s suspension spring stiffness [N/m]
  • c_s suspension damping coefficient [kg/s]
  • k_t tyre vertical stiffness [N/m]
  • f road input frequency [Hz]

Returns

  • T_body body displacement / road displacement
  • T_wheel wheel displacement / road displacement

Applies when

  • masses and stiffnesses positive
  • c_s >= 0

Example

m.ask("Quarter car transmissibility with sprung mass = 400 kg, unsprung mass = 45 kg, spring stiffness = 25 kN/m, damping = 1800 N*s/m, tyre stiffness = 200 kN/m and frequency = 1.2 Hz.")
→ T_body = 2.39633, T_wheel = 1.15904
Rollover threshold: static stability factor and rollover speed on a curvetransport_rollover_threshold

Static stability factor SSF = t / (2h) of a rigid vehicle and the speed at which it would tip over on a curve of radius R with superelevation e (enough friction assumed for the tyres not to slide).

SSF = \frac{t}{2h},\quad \frac{v^2}{gR} = \frac{SSF + e}{1 - SSF\,e}

Inputs

  • t_w track width [m]
  • h height of the centre of gravity [m]
  • R curve radius [m]
  • e superelevation rate, decimal optional

Returns

  • SSF static stability factor t / (2h) (rollover threshold in g)
  • v_roll rollover speed on the curve (m/s) [m/s]
  • v_roll_kmh rollover speed (km/h) [km/h]

Applies when

  • SSF e < 1
  • tyre friction sufficient (sliding is not checked)

Example

m.ask("Rollover threshold with track width = 1.55 m, cg height = 0.6 m and radius = 100 m.")
→ SSF = 1.29167, v_roll = 35.5967 m/s, v_roll_kmh = 128.148 km/h
Steady-state cornering: yaw rate, lateral acceleration, radius, sidesliptransport_steady_state_cornering

Steady turning response of the linear bicycle model at speed u to a front-wheel steer angle delta: yaw rate, lateral acceleration, turn radius and the sideslip angle at the centre of gravity (small angles).

\frac{r}{\delta} = \frac{u}{L + K u^2}

Inputs

  • m vehicle mass [kg]
  • L wheelbase [m]
  • l_f distance from the front axle to the centre of gravity [m]
  • C_f cornering stiffness of the front axle [N/rad]
  • C_r cornering stiffness of the rear axle [N/rad]
  • u forward speed [m/s]
  • delta front-wheel steer angle (degrees in questions; rad in solve(), or '2 deg') [rad]

Returns

  • r yaw rate (rad/s) [rad/s]
  • a_y lateral acceleration (m/s^2) [m/s^2]
  • R turn radius (m) [m]
  • beta sideslip angle at the centre of gravity (degrees) [deg]

Applies when

  • below the critical speed
  • delta != 0

Example

m.ask("Steady state cornering with mass = 1500 kg, wheelbase = 2.7 m, cg to front axle = 1.2 m, front cornering stiffness = 90000 N/rad, rear cornering stiffness = 85000 N/rad, speed = 72 km/h and steer angle = 2 deg.")
→ r = 0.213728 rad/s, a_y = 4.27456 m/s^2, R = 93.5769 m, beta = -1.00247 deg
Steer angle needed for a turn of given radius (bicycle model)transport_steer_angle_for_radius

Front-wheel steer angle the linear bicycle model needs to hold a turn of radius R at speed u (Ackermann angle L/R plus the understeer term K u^2 / R).

\delta = \frac{L}{R} + K\frac{u^2}{R}

Inputs

  • m vehicle mass [kg]
  • L wheelbase [m]
  • l_f distance from the front axle to the centre of gravity [m]
  • C_f cornering stiffness of the front axle [N/rad]
  • C_r cornering stiffness of the rear axle [N/rad]
  • u forward speed [m/s]
  • R turn radius [m]

Returns

  • delta front-wheel steer angle (degrees) [deg]

Applies when

  • below the critical speed

Example

m.ask("Steer angle for a turn with mass = 1500 kg, wheelbase = 2.7 m, cg to front axle = 1.2 m, front cornering stiffness = 90000 N/rad, rear cornering stiffness = 85000 N/rad, speed = 72 km/h and radius = 150 m.")
→ delta = 1.24769 deg
Understeer gradient and characteristic or critical speed (bicycle model)transport_understeer_gradient

Understeer gradient K of the linear single-track model from axle cornering stiffnesses and the centre-of-gravity position, in rad/(m/s^2) and deg/g, whether the vehicle understeers or oversteers, and its characteristic speed (understeer: the steer angle is twice the Ackermann angle) or critical speed (oversteer: it becomes unstable).

K = \frac{m}{L}\left(\frac{l_r}{C_f} - \frac{l_f}{C_r}\right),\quad v_{ch} = \sqrt{L/K}

Inputs

  • m vehicle mass [kg]
  • L wheelbase [m]
  • l_f distance from the front axle to the centre of gravity [m]
  • C_f cornering stiffness of the front axle [N/rad]
  • C_r cornering stiffness of the rear axle [N/rad]

Returns

  • K understeer gradient (rad s^2/m) [rad*s^2/m]
  • K_deg_per_g understeer gradient (deg/g) [deg]
  • behaviour understeer or oversteer
  • v_c characteristic or critical speed (m/s) [m/s]
  • v_c_kmh characteristic or critical speed (km/h) [km/h]

Applies when

  • 0 < l_f < L
  • positive cornering stiffnesses
  • not exactly neutral steer

Example

m.ask("Understeer gradient with mass = 1500 kg, wheelbase = 2.7 m, cg to front axle = 1.2 m, front cornering stiffness = 90000 N/rad and rear cornering stiffness = 85000 N/rad.")
→ K = 0.00141612 rad*s^2/m, K_deg_per_g = 0.795962 deg, behaviour = understeer, v_c = 43.6648 m/s, v_c_kmh = 157.193 km/h
Yaw natural frequency and damping of the bicycle modeltransport_yaw_natural_frequency

Undamped natural frequency and damping ratio of the lateral-yaw motion of the linear bicycle model at speed u (from the characteristic equation of its two states), below the critical speed.

\omega_n^2 = \frac{C_f C_r L^2}{m I_z u^2}\left(1 + \frac{K u^2}{L}\right)

Inputs

  • m vehicle mass [kg]
  • Iz yaw moment of inertia [kg*m^2]
  • L wheelbase [m]
  • l_f distance from the front axle to the centre of gravity [m]
  • C_f cornering stiffness of the front axle [N/rad]
  • C_r cornering stiffness of the rear axle [N/rad]
  • u forward speed [m/s]

Returns

  • wn undamped natural frequency (rad/s) [rad/s]
  • zeta damping ratio
  • f_n undamped natural frequency (Hz) [Hz]

Applies when

  • below the critical speed

Example

m.ask("Yaw natural frequency with mass = 1500 kg, yaw inertia = 2500 kg*m^2, wheelbase = 2.7 m, cg to front axle = 1.2 m, front cornering stiffness = 90000 N/rad, rear cornering stiffness = 85000 N/rad and speed = 72 km/h.")
→ wn = 6.70664 rad/s, zeta = 0.913299 1, f_n = 1.06739 Hz

Vehicle performance 8

Acceleration time and distance under constant engine powertransport_acceleration_under_power

Time and distance for a vehicle of mass m to change speed from v1 to v2 with constant power P at the wheels (tractive force eta P / v) against rolling, aerodynamic and grade resistance. A truck slowing on an upgrade towards its crawl speed is covered too (v2 < v1); both speeds must lie on the same side of the speed at which the power balances the resistance.

t = \int_{v_1}^{v_2} \frac{\gamma m\, dv}{\eta P / v - F_0 - K v^2}

Inputs

  • m vehicle mass [kg]
  • P engine power [W]
  • v1 initial speed [m/s]
  • v2 final speed [m/s]
  • C_D drag coefficient
  • A frontal area [m^2]
  • rho air density (default 1.2 kg/m^3) [kg/m^3] optional
  • f_r rolling resistance coefficient (default 0.015) optional
  • G grade, decimal (positive uphill) optional
  • eta drivetrain efficiency (default 1) optional
  • gamma mass factor for rotating parts (default 1) optional

Returns

  • t time to change speed (s) [s]
  • d distance travelled (m) [m]

Applies when

  • v1, v2 > 0 on the same side of the equilibrium speed
  • eta <= 1

Example

m.ask("Acceleration under constant power with mass = 1500 kg, power = 75 kW, initial speed = 20 km/h, final speed = 100 km/h, drag coefficient = 0.32 and frontal area = 2.2 m^2.")
→ t = 8.32025 s, d = 162.054 m
Coast-down time and distance (rolling and aerodynamic resistance)transport_coast_down

Time and distance for a vehicle coasting in neutral to slow from v1 to v2 under rolling resistance f_r, the grade and aerodynamic drag rho C_D A v^2 / 2.

t = \frac{\gamma m}{\sqrt{K F_0}}\left[\arctan\!\left(v_1\sqrt{K/F_0}\right) - \arctan\!\left(v_2\sqrt{K/F_0}\right)\right]

Inputs

  • m vehicle mass [kg]
  • v1 initial speed [m/s]
  • v2 final speed [m/s]
  • C_D drag coefficient
  • A frontal area [m^2]
  • rho air density (default 1.2 kg/m^3) [kg/m^3] optional
  • f_r rolling resistance coefficient (default 0.012) optional
  • G grade, decimal (positive uphill) optional
  • gamma mass factor (default 1) optional

Returns

  • t coast-down time (s) [s]
  • d coast-down distance (m) [m]

Applies when

  • v2 < v1
  • F0 = W (f_r cos(theta) + sin(theta)) > 0

Example

m.ask("Coast down time with mass = 1400 kg, initial speed = 100 km/h, final speed = 60 km/h, drag coefficient = 0.32 and frontal area = 2.2 m^2.")
→ t = 42.2501 s, d = 917.248 m
Distance and time to accelerate (acceleration lane length)transport_acceleration_distance

Distance and time for a vehicle to accelerate from v1 to v2 at a constant acceleration a (for example the length of an acceleration lane).

d = \frac{v_2^2 - v_1^2}{2a}

Inputs

  • v1 initial speed [m/s]
  • v2 final speed [m/s]
  • a acceleration [m/s^2]

Returns

  • d distance travelled while accelerating (m) [m]
  • t time taken (s) [s]

Applies when

  • v2 > v1 >= 0
  • a > 0

Example

m.ask("Acceleration distance with initial speed = 40 km/h, final speed = 100 km/h and acceleration = 1.2 m/s^2.")
→ d = 270.062 m, t = 13.8889 s
Maximum tractive force and acceleration limited by tyre frictiontransport_traction_limited_acceleration

The largest tractive force the road can transmit (rear-, front- or all-wheel drive), the resulting maximum acceleration and the dynamic axle loads, with weight transfer from a centre of gravity at height h and rolling resistance f_r (aerodynamic drag neglected, level road).

F_{max} = \frac{\mu W (l_f - f_{rl} h)/L}{1 - \mu h / L}

Inputs

  • m vehicle mass [kg]
  • L wheelbase [m]
  • l_f distance from the front axle to the centre of gravity [m]
  • h height of the centre of gravity [m]
  • mu tyre-road friction coefficient
  • f_r rolling resistance coefficient (default 0) optional
  • drive driven axles: rear, front or all choice optional

Returns

  • F_max maximum tractive force (N) [N]
  • a_max maximum acceleration (m/s^2) [m/s^2]
  • W_f front axle load (N) [N]
  • W_r rear axle load (N) [N]

Applies when

  • 0 < l_f < L
  • mu h < L for rear-wheel drive
  • both axles keep contact

Example

m.ask("Traction limited acceleration with mass = 1500 kg, wheelbase = 2.7 m, cg to front axle = 1.1 m, cg height = 0.55 m, friction = 0.8, rolling resistance = 0.012 and drive = rear.")
→ F_max = 5695.36 N, a_max = 3.67918 m/s^2, W_f = 7595.8 N, W_r = 7119.2 N
Minimum safe following gap when the leader brakestransport_safe_following_gap

Smallest initial gap that avoids a rear-end collision when a leader brakes at a_l and the follower, at the same initial speed, reacts after t_r and brakes at a_f (the closest approach can happen while both still move).

g_{min} = \max_t\left[x_f(t) - x_l(t)\right]

Inputs

  • v initial speed of both vehicles [m/s]
  • t_r follower reaction time [s]
  • a_l deceleration of the leader [m/s^2]
  • a_f deceleration of the follower [m/s^2]

Returns

  • gap minimum safe initial gap (m) [m]

Applies when

  • all inputs positive

Example

m.ask("Safe following gap with speed = 100 km/h, reaction time = 1 s, leader deceleration = 8 m/s^2 and follower deceleration = 6 m/s^2.")
→ gap = 43.8529 m
Overtaking manoeuvre: time and distance with constant accelerationtransport_overtaking_manoeuvre

A vehicle that starts at the speed v of the vehicle it passes accelerates at a until it has gained the relative distance s (initial gap + both lengths + final gap): the time, its distance travelled and its final speed.

t = \sqrt{\frac{2s}{a}},\quad d = v t + \tfrac{1}{2} a t^2

Inputs

  • v speed of the overtaken vehicle (and initial speed of the passing vehicle) [m/s]
  • a acceleration of the passing vehicle [m/s^2]
  • s relative distance to gain [m]

Returns

  • t time to complete the overtaking (s) [s]
  • d distance travelled by the passing vehicle (m) [m]
  • v_f final speed of the passing vehicle (m/s) [m/s]

Applies when

  • v >= 0
  • a > 0
  • s > 0

Example

m.ask("Overtaking manoeuvre with speed = 70 km/h, acceleration = 1.5 m/s^2 and relative distance = 60 m.")
→ t = 8.94427 s, d = 233.916 m, v_f = 32.8609 m/s
Top speed of a road vehicletransport_top_speed

The steady top speed at which the power at the wheels eta P equals the power absorbed by rolling, aerodynamic and grade resistance: rho C_D A v^3/2 + m g (f_r cos(theta) + sin(theta)) v = eta P.

\tfrac12\rho C_D A v^3 + m g\left(f_r\cos\theta + \sin\theta\right)v = \eta P

Inputs

  • m vehicle mass [kg]
  • P engine power [W]
  • C_D drag coefficient
  • A frontal area [m^2]
  • rho air density (default 1.2 kg/m^3) [kg/m^3] optional
  • f_r rolling resistance coefficient (default 0.015) optional
  • G grade, decimal (positive uphill) optional
  • eta drivetrain efficiency (default 1) optional

Returns

  • v_max top speed (m/s) [m/s]
  • v_max_kmh top speed (km/h)

Applies when

  • m, P, C_D, A, rho > 0
  • 0 <= f_r <= 0.1
  • |G| <= 0.3
  • 0 < eta <= 1
  • power-limited (no gearing or traction limit)

Example

m.ask("Top speed of a road vehicle with mass = 1500 kg, power = 100 kW, drag coefficient = 0.3 and frontal area = 2.2 m^2.")
→ v_max = 60.2702 m/s, v_max_kmh = 216.973
Vehicle resistance forces and power at a speedtransport_vehicle_resistance

Rolling resistance f_r m g cos(theta), aerodynamic drag rho C_D A v^2/2 and grade resistance m g sin(theta) (tan theta = G) of a road vehicle at a speed, their sum and the power needed to overcome them.

F = f_r m g\cos\theta + \tfrac12\rho C_D A v^2 + m g\sin\theta,\quad P = F v

Inputs

  • m vehicle mass [kg]
  • v speed [m/s]
  • C_D drag coefficient
  • A frontal area [m^2]
  • rho air density (default 1.2 kg/m^3) [kg/m^3] optional
  • f_r rolling resistance coefficient (default 0.015) optional
  • G grade, decimal (positive uphill) optional

Returns

  • F_roll rolling resistance (N) [N]
  • F_aero aerodynamic drag (N) [N]
  • F_grade grade resistance (N) [N]
  • F_total total resistance (N) [N]
  • P power to overcome the resistance (W) [W]
  • P_kW power (kW)

Applies when

  • m, C_D, A, rho > 0
  • v >= 0
  • 0 <= f_r <= 0.1
  • |G| <= 0.3
  • still air

Example

m.ask("Vehicle resistance forces with mass = 1500 kg, speed = 100 km/h, drag coefficient = 0.3 and frontal area = 2.2 m^2.")
→ F_roll = 220.725 N, F_aero = 305.556 N, F_grade = 0 N, F_total = 526.281 N, P = 14618.9 W, P_kW = 14.6189
Questions

Frequently asked

What does transportation-ai999x do?

Transportation answers questions in transportation: vehicle dynamics, braking and stopping distances, traffic flow, highway geometry, railway operations, route planning and transit capacity. Each answer gives the value with its unit, the steps and the formula in LaTeX.

How do I install transportation-ai999x?

With pip: pip install transportation-ai999x. The same files are on Hugging Face (hf download AI999X/transportation-ai999x --local-dir transportation-ai999x) and GitHub.

Does it run offline?

Yes. It is a Python package that runs on an ordinary CPU without a network connection (Python >=3.10); no GPU and no API key are needed.

How many capabilities does transportation-ai999x have?

77 capabilities in 13 topics, including Traffic flow, Highway geometry, Vehicle dynamics, Vehicle performance, Braking and stopping.

Which field and tasks does it cover?

Field: Engineering. Tasks: Question Answering, Token Classification, Text Classification, Sentence Similarity, Feature Extraction.

What does an answer look like?

Asked "Stopping sight distance with speed = 100 km/h, reaction time = 2.5 s and deceleration = 3.4 m/s^2.", it answers: SSD = 182.916 m, d_r = 69.4444 m, d_b = 113.471 m.

What happens when a question cannot be answered?

It says so and names what is missing or out of range, instead of guessing a number.

More from AI999X

Explore every model.