Skip to content

transitlos.scoring.walk_access

Walk-access decay D(t; stop_score): discounts a stop's score by the walking time to it.

D(t; stop_score) = 1                                              for 0 <= t <= t_plateau
D(t; stop_score) = (1 + (t - t_plateau) / t0(stop_score))^(-p)    for t > t_plateau
t0(stop_score)   = t0_base(mode) * (1 + k * stop_score)

A better stop decays more slowly (riders walk further to it), so PTLOS = stop_score * D(t; stop_score) is one joint function of walk time and stop quality. t0_base depends on the mode (bus, rail, tram; see mrc.mode_category); the plateau (200 m, ~2.56 min at 1.3 m/s) and p = 1 are the same for every mode. Defaults: parameters.RegionParameters.

t0_of_stop_score(mode, stop_score, region='global', t0_base_minutes=None, k=None)

Compute t0(stop_score) = t0_base(mode) * (1 + k * stop_score).

Parameters:

Name Type Description Default
mode str

One of "bus", "rail", "tram" (see mrc.mode_category).

required
stop_score float

The stop-level quality score. Must be >= 0 (may exceed 1.0 up to ~1.048, see stop_score.py's module docstring).

required
region str

Region key into parameters.REGIONS. Kept for backward compatibility -- every region shares identical, universal parameters.

'global'
t0_base_minutes float | None

Per-mode base scale override. If None, looked up from the region's t0_base_minutes[mode].

None
k float | None

Quality-coupling constant override. If None, defaults to the region's k_quality (2.5).

None

Returns:

Type Description
float

t0, in minutes.

Raises:

Type Description
ValueError

If stop_score is negative, or mode is not recognized and no explicit t0_base_minutes override is given.

walk_decay(walk_time_minutes, stop_score, mode, region='global', t_plateau_minutes=None, p=None, t0_base_minutes=None, k=None)

Compute the walk-access decay factor D(t; stop_score).

Flat at 1.0 up to t_plateau_minutes, then (1 + (t - t_plateau) / t0(stop_score)) ^ (-p) beyond it, where t0(stop_score) = t0_base(mode) * (1 + k * stop_score) -- see module docstring. PTLOS = stop_score * walk_decay(...) (accessibility_score.accessibility_score computes this product).

Parameters:

Name Type Description Default
walk_time_minutes float

Walking time to the stop, in minutes. Must be

= 0.

required
stop_score float

The stop-level quality score (from stop_score.stop_score). Must be >= 0.

required
mode str

One of "bus", "rail", "tram" -- selects t0_base (see mrc.mode_category). Ignored if t0_base_minutes is passed explicitly.

required
region str

Region key into parameters.REGIONS. Kept for backward compatibility -- every region shares identical, universal parameters.

'global'
t_plateau_minutes float | None

Walk time at/below which D(t)=1.0 exactly. If None, derived from the region's t_plateau_distance_m and walking_speed_mps (200 m -> ~2.56 min at 1.3 m/s).

None
p float | None

Shape parameter. If None, defaults to the region's p_shape (1.0).

None
t0_base_minutes float | None

Per-mode base scale override, forwarded to t0_of_stop_score.

None
k float | None

Quality-coupling constant override, forwarded to t0_of_stop_score.

None

Returns:

Type Description
float

A float in (0, 1]: exactly 1.0 for walk_time_minutes <=

float

t_plateau_minutes, monotonically decreasing and asymptotically

float

approaching (but never reaching) 0 as walk_time_minutes grows

float

beyond it.

Raises:

Type Description
ValueError

If walk_time_minutes or stop_score is negative.

walk_time_for_decay(target_decay, stop_score, mode, region='global', t_plateau_minutes=None, p=None, t0_base_minutes=None, k=None)

Invert walk_decay: the walk time at which D(t; stop_score) == target_decay.

Since p is fixed at 1.0 by default, this remains a closed-form inverse for the default shape parameter (and any other p, since the offset-power form (1+x)^(-p) inverts in closed form for any p != 0); t0 itself already depends on stop_score/mode, which are required inputs here rather than something to additionally solve for. Kept alongside walk_decay so the two never drift out of sync. Used by distance_matrix.build_intelligent_distance_matrix to choose distance thresholds that land exactly on desired output access-score values.

Parameters:

Name Type Description Default
target_decay float

Desired D(t; stop_score) value, in (0, 1]. 1.0 returns t_plateau_minutes (the start of the plateau).

required
stop_score float

The stop-level quality score this curve is being inverted for (must match the walk_decay call being inverted).

required
mode str

One of "bus", "rail", "tram" (must match the walk_decay call being inverted).

required
region str

Same meaning as in walk_decay -- must match the call whose curve is being inverted.

'global'
t_plateau_minutes float | None

Same meaning as in walk_decay -- must match the call whose curve is being inverted.

None
p float | None

Same meaning as in walk_decay -- must match the call whose curve is being inverted.

None
t0_base_minutes float | None

Same meaning as in walk_decay -- must match the call whose curve is being inverted.

None
k float | None

Same meaning as in walk_decay -- must match the call whose curve is being inverted.

None

Returns:

Type Description
float

The walk time (minutes) at which

float

walk_decay(t, stop_score, mode) == target_decay.

Raises:

Type Description
ValueError

If target_decay is not in (0, 1], or stop_score is negative.