iduedu.TransportSpec¶
- class iduedu.TransportSpec(name, vmax_tech_kmh, accel_dist_m, brake_dist_m, base_speed_kmh, avg_wait_time_min=1.0, dwell_min=0.0, long_speed_kmh=None, speed_half_length_m=None)[source]¶
Configuration of a public-transport mode or service used to estimate travel time on graph edges.
Each transport specification defines technical and operational characteristics of a mode (e.g. bus, tram, subway) that are used to compute per-edge travel time based on segment length, road speed limits, acceleration/braking behavior, and traffic conditions.
- Parameters:
- name¶
Registry key, either a mode (e.g.
"train") or"<mode>:<service>"for a variant matching the OSM route relation’sservicetag.- Type:
- accel_dist_m¶
Typical distance (meters) required to accelerate from standstill to cruising speed.
- Type:
- brake_dist_m¶
Typical distance (meters) required to decelerate from cruising speed to standstill.
- Type:
- base_speed_kmh¶
Free-flow speed of the mode in kilometers per hour: the speed it holds between stops once it is up to speed.
A road speed limit does not scale this value. Earlier versions made free speed affine in the limit,
base + traffic_coef * limit, and fitting that form against published timetables showed the two terms are not separately identifiable: for buses, a fast base with a weak coefficient and a slow base with a strong one differ by less than a percent in error. Dropping the term outright improved accuracy for every mode measured (bus, tram, trolleybus, subway, commuter rail), because OSM’smaxspeeddescribes what a car may do, not what a bus with passengers, stops and traffic actually does.The limit is still honoured where it binds: a vehicle is not modelled faster than the road allows.
- Type:
- dwell_min¶
Time lost standing at a stop, in minutes. Added once per segment. Defaults to
0.- Type:
- long_speed_kmh¶
Free speed approached on long segments, in km/h. With
speed_half_length_mthe free speed grows with the segment lengthLfrombase_speed_kmhtowards it:v(L) = base_speed_kmh + (long_speed_kmh - base_speed_kmh) * L / (L + speed_half_length_m)
Timetables show it for every mode: a long stretch between stops runs on roads and tracks built for speed, which a single free speed cannot express – buses make about 22 km/h over 500-950 m and 36 km/h over 5-10 km, of which acceleration and dwell explain only part. Both
None(default): one free speed,base_speed_kmh, on every segment.- Type:
float | None
- speed_half_length_m¶
Segment length at which the free speed is halfway from
base_speed_kmhtolong_speed_kmh, in metres. Set together withlong_speed_kmh.- Type:
float | None
- avg_wait_time_min¶
Average passenger waiting time in minutes. It is assigned to directed
boardingedges built from OSM data using the plain mode specification.- Type:
Methods
Free speed on a segment of this length:
base_speed_kmh, or growing with the length towardslong_speed_kmhwhen that is set.Compute travel time (minutes) for a single graph segment.
Validate transport specification fields.
- validate()[source]¶
Validate transport specification fields.
- Raises:
ValueError – If a required field is missing or outside the supported
range. –
- Return type:
- free_speed_kmh(segment_len_m)[source]¶
Free speed on a segment of this length:
base_speed_kmh, or growing with the length towardslong_speed_kmhwhen that is set.
- travel_time_min(segment_len_m, *, speed_limit_mpm=None, min_speed_mpm=60.0)[source]¶
Compute travel time (minutes) for a single graph segment.
The method estimates traversal time using a simplified kinematic model that accounts for: - the transport mode technical maximum speed; - a free speed that may grow with the segment length (
long_speed_kmh); - an optional road speed limit, entering the free-flow speed affinely; - time lost standing at a stop (dwell_min); - time lost on acceleration and braking.For short segments where the vehicle cannot reach cruising speed, a reduced peak speed is assumed and the segment is traversed using an acceleration-deceleration profile without a cruising phase. The peak speed scales as
sqrt(L / span)because under constant acceleration the distance covered grows with the square of the speed reached; the two branches meet continuously atL == span.- Parameters:
segment_len_m (
float) – Segment length in meters. Must be positive.speed_limit_mpm (
float | None) – Optional road speed limit in meters per minute. If provided, the effective speed will not exceed this value.min_speed_mpm (
float) – Lower bound for effective speed (meters per minute), used to avoid unrealistically large travel times on very short segments.
- Returns:
Estimated travel time for the segment in minutes.
- Return type: