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 |
required |
stop_score
|
float
|
The stop-level quality score. Must be >= 0 (may exceed
1.0 up to ~1.048, see |
required |
region
|
str
|
Region key into |
'global'
|
t0_base_minutes
|
float | None
|
Per-mode base scale override. If None, looked up
from the region's |
None
|
k
|
float | None
|
Quality-coupling constant override. If None, defaults to the
region's |
None
|
Returns:
| Type | Description |
|---|---|
float
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If stop_score is negative, or mode is not recognized
and no explicit |
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
|
required |
stop_score
|
float
|
The stop-level quality score (from |
required |
mode
|
str
|
One of |
required |
region
|
str
|
Region key into |
'global'
|
t_plateau_minutes
|
float | None
|
Walk time at/below which D(t)=1.0 exactly. If
None, derived from the region's |
None
|
p
|
float | None
|
Shape parameter. If None, defaults to the region's |
None
|
t0_base_minutes
|
float | None
|
Per-mode base scale override, forwarded to
|
None
|
k
|
float | None
|
Quality-coupling constant override, forwarded to
|
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 |
required |
stop_score
|
float
|
The stop-level quality score this curve is being
inverted for (must match the |
required |
mode
|
str
|
One of |
required |
region
|
str
|
Same meaning as in |
'global'
|
t_plateau_minutes
|
float | None
|
Same meaning as in |
None
|
p
|
float | None
|
Same meaning as in |
None
|
t0_base_minutes
|
float | None
|
Same meaning as in |
None
|
k
|
float | None
|
Same meaning as in |
None
|
Returns:
| Type | Description |
|---|---|
float
|
The walk time (minutes) at which |
float
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If target_decay is not in (0, 1], or stop_score is negative. |