transitlos.scoring.mrc¶
MRC: the combined mode / reliability / comfort axis.
Mode, reliability and comfort are one axis, not three separately weighted terms:
(a) MR_mode(mode) categorical default from the GTFS route_type (the path the pipeline uses)
(b) MR_CV(headway_cv) optional, used instead of (a) when the scheduled-headway CV is known: 1 / (1 + CV^2)
(c) C(occupancy_status) optional comfort factor on top of (a) / (b) from GTFS-realtime OccupancyStatus (not used by default)
MRC = MR_component * C_component
Defaults: parameters.RegionParameters (mr_mode, comfort_scores).
mode_category(route_type)
¶
Classify a GTFS route_type into "rail", "tram", or "bus".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route_type
|
Optional[int]
|
Standard GTFS |
required |
Returns:
| Type | Description |
|---|---|
str
|
|
MR_mode(mode, region='global')
¶
Compute the mode-based categorical default MR_mode(mode).
Rail / subway / metro / commuter rail = 1.000; tram / light rail / BRT = 0.894 (geometric mean of rail and bus); local bus = 0.800.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
One of |
required |
region
|
str
|
Region key into |
'global'
|
Returns:
| Type | Description |
|---|---|
float
|
A float in (0, 1]. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If mode is not one of "rail", "tram", "bus". |
mode_score(route_type, region='global')
¶
Compute MR_mode(mode_category(route_type)) directly from a GTFS route_type.
Convenience wrapper combining mode_category + MR_mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route_type
|
Optional[int]
|
GTFS route type. |
required |
region
|
str
|
Scoring region. |
'global'
|
Returns:
| Type | Description |
|---|---|
float
|
The mode value. |
MR_CV(headway_cv)
¶
Compute the optional CV-of-scheduled-headway reliability refinement.
MR_CV(CV) = 1 / (1 + CV^2), the inverse of the average-wait inflation factor (1 + CV^2). MR_CV(0)=1.0, MR_CV(1)=0.5, MR_CV(2)~=0.2. Mode-agnostic by
construction; preferred over MR_mode whenever scheduled-headway CV data
exists, since it reflects the stop's own actual pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headway_cv
|
float
|
Coefficient of variation of scheduled headways (stddev / mean), a unitless non-negative number. |
required |
Returns:
| Type | Description |
|---|---|
float
|
A float in (0, 1]. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If headway_cv is negative. |
comfort_score(occupancy_status, region='global')
¶
Compute the optional comfort/crowding refinement C(occupancy_status).
A categorical lookup keyed to the standardized
GTFS-realtime VehiclePosition.OccupancyStatus enum. Defaults to 1.0
(comfort-neutral) when occupancy data is unavailable -- the common case,
since this refinement needs GTFS-realtime data this project's pipeline
typically does not have.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
occupancy_status
|
Optional[str]
|
One of the GTFS-realtime |
required |
region
|
str
|
Region key into |
'global'
|
Returns:
| Type | Description |
|---|---|
float
|
A float in [0, 1]. Exactly 1.0 if |
Raises:
| Type | Description |
|---|---|
ValueError
|
If occupancy_status is a string not in the known enum. |
mrc_score(route_type=None, headway_cv=None, occupancy_status=None, region='global')
¶
Compute the combined MRC(mode/reliability/comfort) sub-score.
MRC = MR_component * C_component, where
MR_component is MR_CV(headway_cv) if headway_cv is supplied
(preferred, richer data), else MR_mode(mode_category(route_type))
(the primary, load-bearing GTFS-static-only default); C_component is
comfort_score(occupancy_status), defaulting to 1.0 (comfort-neutral)
when occupancy_status is None -- the common case, so
mrc_score(route_type) == MR_mode(mode_category(route_type)) exactly
when no other data is supplied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route_type
|
Optional[int]
|
Standard GTFS |
None
|
headway_cv
|
Optional[float]
|
Coefficient of variation of scheduled headways, or
|
None
|
occupancy_status
|
Optional[str]
|
GTFS-realtime |
None
|
region
|
str
|
Region key into |
'global'
|
Returns:
| Type | Description |
|---|---|
float
|
A float in [0, 1] (or up to (0, 1] * (0, 1] -- always <= 1.0 since |
float
|
both components are individually <= 1.0). |