Skip to content

transitlos.scoring.speed

Speed score V(speed): converts a stop's average operating speed into a score.

V(v) = M * v^n / (v^n + K^n),    K = anchor * (M - 1)^(1/n)

a smooth increasing curve with V(anchor) = 1 and V -> M = 1 + bonus as v -> infinity (no hard cap). With the defaults (anchor 30 km/h, bonus 0.15, n = 2): K ~= 11.62, V(30) = 1, V(100) ~= 1.135.

The speed is the commercial (operating) speed, dwell time at stops included, not the cruising speed between stops.

speed_score(avg_speed_kmh, region='global', anchor_kmh=None, ceiling_bonus=None, shape_n=None)

Compute V(speed) from average operating speed.

Parameters:

Name Type Description Default
avg_speed_kmh float

Average operating (commercial) speed in km/h -- i.e. distance/time averaged over the whole route, INCLUDING dwell time at stops, not pure between-stops cruising speed. Must be >= 0.

required
region str

Region key into parameters.REGIONS. Kept for backward compatibility -- every region now shares identical, universal parameters (see parameters.py's module docstring).

'global'
anchor_kmh float | None

Speed at which V reaches exactly 1.0. Defaults to the region's v_anchor_kmh (30.0).

None
ceiling_bonus float | None

The curve's asymptotic ceiling above 1.0, approached as avg_speed_kmh -> infinity, never hit at any specific finite speed and NOT pinned to any named high-speed benchmark (an earlier same-day revision tried pinning it to German Regional-Express's speed and was reverted -- see module docstring, Revision 4). Defaults to the region's v_ceiling_bonus (0.15), an explicit design-judgment choice.

None
shape_n float | None

Hill-function exponent controlling how quickly the curve rises below the anchor (higher n => lower scores at low speed). Defaults to the region's v_shape_n (2.0).

None

Returns:

Type Description
float

A float, strictly increasing in avg_speed_kmh, exactly 0.0 only at

float

avg_speed_kmh == 0, asymptotically approaching (but never reaching)

float

1 + ceiling_bonus as avg_speed_kmh -> infinity.

Raises:

Type Description
ValueError

If avg_speed_kmh is negative.