openmobisim#
openmobisim — an agent-based multimodal mobility simulator.
The public Python surface. Most of it is a thin re-export of the compiled
core (openmobisim._core), which is private: its shape is free to change behind
this module, whereas this module is a semver contract. Scenario, Run
and Table (openmobisim.scenario) and the fixture helpers in
openmobisim.examples are where the core becomes ergonomic: behaviour in
Python, physics in Rust.
Figures live in openmobisim.viz (pip install 'openmobisim[viz]'); it is
imported on demand, so import openmobisim never needs matplotlib.
New here? openmobisim.notebooks() copies the tutorial notebooks into a folder and links the
first, 00_getting_started.ipynb, which lists the others (openmobisim notebooks in a
terminal also opens it in JupyterLab).
Documentation: https://openmobisim.github.io
The scenario surface is intentionally narrow: a network, a trips table, one
run, its output artifacts, route choice among each trip’s alternatives
(openmobisim.choice says how to add your own choice model) and, by default,
iteration towards an equilibrium
(equilibration="msa"), during which the route sets may grow
(route_update="least_cost"). Trips may also cycle, walk, take scheduled
public transport (transit_read_gtfs, Scenario(transit=...)), whose buses
ride the roads among the cars, or drive or cycle to a parking and go on by
transit (parking_read_osm, parking_read_table, Scenario(parkings=...)),
the station chosen by the choice model. demand_sample simulates one traveller for
every few people, for faster screening runs. Roads and lines can be disrupted at a time of day
(Scenario.from_parts(..., disruptions=...)).
Networks and demand may come from files in standard formats: GMNS networks
(network_read_gmns, network_write_gmns), checked before a run by network_check;
zones, OD matrices and trips as CSV (demand_read_zones, demand_read_zone_points,
demand_read_od, demand_read_trips, demand_write_trips), an OD matrix made trips by
demand_from_od;
traveller classes, each with its own modes and coefficients, from a class table
(demand_read_classes), drawn for each traveller by demand_assign_classes.
Submodules#
Attributes#
Exceptions#
The run's engine does not have something the scenario asks for. |
|
Trips with no alternative at all travelled by car instead. |
|
Trips had no alternative at all and were not simulated. |
|
Trips of the demand departed outside the simulation window and were left out. |
Classes#
The old name of |
|
A table held as columns: a |
|
A run's parameters, as a |
|
What one fleet day did ( |
|
|
|
|
|
|
|
One road class's parameters, for |
|
|
|
The loading's parameters: |
|
|
|
The modes' parameters: |
|
The old name of |
|
|
|
|
|
The network readers' parameters: |
|
The parkings' parameters: |
|
A scenario's parkings: park-and-ride car parks and bike parkings. |
|
The old name of |
|
The prices: |
|
What one run produced. |
|
A network, demand, and the settings of a run. |
|
|
|
|
|
|
|
A results table backed by a Parquet file. |
|
The timetable of one service day: stops, lines and every run that day. |
|
Public transport's parameters: |
|
One trip: a row of the demand |
Functions#
Return facts about the compiled core. |
|
|
Chargers from a table: one row per charger. |
|
Return one uniform draw in |
|
Make a Python choice model usable by name, like the built-in ones. |
The choice models that can be selected by name. |
|
|
Read a |
|
Write the complete |
|
Trip ends moved to their zone's or their grid cell's point: the demand aggregated over space. |
|
Every departure set to one instant, |
|
Give every traveller a class, drawn by the classes' shares. |
|
Turn an OD matrix into the trips a |
|
Read a class table ( |
|
Read |
|
Read |
|
Read |
|
Read |
|
Keep one traveller in every |
|
Write trips rows as |
|
Docks from a bike-sharing system's GBFS feed (General Bikeshare Feed Specification). |
|
Docks from a table: one row per dock. |
The equilibration strategies that can be selected by name, the default first. |
|
|
Sum |
|
Run every service's day together on the fleet engine, from a table of trips. |
|
A fleet day to step through: |
|
Check a network before running it: what would make trips fail, and what to look at. |
|
The same network with a scenario's changes made, for a study to compare. |
|
Every network parameter by name, at its shipped value, or at network's. |
|
Read a road network |
|
Read a network from GMNS files. |
|
Read a road network from an OpenStreetMap |
|
Read a road network from a plain table of links. |
|
Write a road network to a cache file, read back by |
|
Write |
|
Copy the tutorial notebooks into |
Every parameter openmobisim assumes, at the defaults a |
|
|
Read parkings |
|
Park-and-ride car parks and bike parkings from an OpenStreetMap extract. |
|
Parkings from a table: one row per parking. |
|
Write parkings to a cache file, read back by |
|
Make a policy usable by name, like the built-in ones. |
|
The road times of an earlier run, from its |
Forget every route set the cache holds (the counters of |
|
What the route-set cache has done: |
|
The route-set methods that can be selected, the default ( |
|
|
Make route sets for origin-destination pairs given as coordinates. |
The route updates that can be selected by name, the default ( |
|
|
A docked bike-sharing service: bikes counted per dock. |
|
An electric taxi fleet: vehicles tracked one by one, with a battery. |
|
Return the loading step containing |
|
The same service day with a scenario's changes made. |
|
Read one service day of a GTFS feed. |
|
An electric fleet's vehicles from a table: one row per vehicle. |
Package Contents#
- exception openmobisim.EngineNotSupportedError#
The run’s engine does not have something the scenario asks for.
The message names every such part of the scenario and the engine that has it.
- exception openmobisim.FallbackWarning#
Trips with no alternative at all travelled by car instead.
Only with
mode_options={"fallback_car": 1}(experimental, off by default). They are counted under the car;Run.fallback_carlists them.
- exception openmobisim.NoAlternativeWarning#
Trips had no alternative at all and were not simulated.
No mode they may use reached their destination within the limits. The warning says how many, of which classes, why each mode gave them none and what to change;
Run.report_no_alternative()lists every one.
- exception openmobisim.WindowWarning#
Trips of the demand departed outside the simulation window and were left out.
They are not simulated and not counted in any result.
- class openmobisim.BestResponseOptions(**options)#
The old name of
LeastCostOptions, still accepted with aDeprecationWarning.- Parameters:
options (Any)
- class openmobisim.Columns#
A table held as columns: a
dictfrom each column’s name to its values, in order.Every result given “as columns” is one (
Run.trip_modes(),Run.itinerary_choices(),Run.transit_calls(),parameters()…): read a column by name as from any dict (columns["mode"]), or hand the whole table to a data-frame library withto_pandas(),to_polars()orto_arrow(). Each column is a list or a NumPy array, all of one length.- to_arrow()#
The columns as a
pyarrow.Table.- Raises:
ImportError – If pyarrow is not installed — install
openmobisim[all].- Return type:
Any
- to_pandas()#
The columns as a
pandas.DataFrame.- Raises:
ImportError – If pandas is not installed — install
openmobisim[all].- Return type:
Any
- to_polars()#
The columns as a
polars.DataFrame.- Raises:
ImportError – If polars is not installed — install
openmobisim[all].- Return type:
Any
- property row_count: int#
How many rows the columns hold (0 without columns).
- Return type:
int
- class openmobisim.Config#
A run’s parameters, as a
run.tomlstates them (config_read) or a run was given.valuesholds what is stated, by table (values["choice"]["beta_time_min"]; a service’s undervalues["services"][name]); every parameter not stated keeps its default.write(path)writes the complete file,text()returns it,differences()lists what differs from the defaults,scenario()reads its[inputs]into aScenarioandrun()runs it.- differences()#
The stated parameters that differ from their defaults, as
table.key.A service or a policy is listed as a whole (
services.taxi,policy); the inputs are not parameters.- Return type:
list[str]
- classmethod from_arguments(run_id=None, **arguments)#
The configuration of a run with these arguments, to write as a file.
The keyword arguments of
Scenario.from_partsandScenario.runthat are parameters (numbers, names, lists of modes, options dicts, services, a policy by name or a built-in one), andnetwork_options;run_idis the file’sname. What a file cannot hold (link values, disruptions, a Python choice model or policy) is listed inabsentand the file’s header.- Raises:
TypeError – For an argument that is not one of these, with the list of them.
- Parameters:
run_id (str | None)
arguments (Any)
- Return type:
- inputs()#
The
[inputs]table’s paths, resolved against the file’s folder (dates as given).- Return type:
dict[str, Any]
- run(output_dir=None, *, overwrite=False, quiet=False)#
Run the file:
scenario(), thenScenario.run(config=self).- Parameters:
output_dir (str | None)
overwrite (bool)
quiet (bool)
- Return type:
openmobisim.run.Run
- scenario()#
A
Scenarioof the file’s[inputs](read by the package’s readers) and values.networkis read by its kind: a starter case’s folder (itscase.json), a GMNS folder, an OpenStreetMap.osm.pbf(both with the file’s[network]) or a filenetwork_write_cachewrote;demand(required),personsandzonesare given toScenario.from_partsas paths;classesbydemand_read_classes;transitbytransit_read_gtfs(ontransit_date);parkingsbyparking_read_table(a.csv),parking_read_osm(a.pbf) orparking_read_cache; a service’s tables bydock_read_table,vehicle_read_tableandcharger_read_table.- Raises:
ValueError – If
networkordemandis missing, or a value is not valid.- Return type:
openmobisim.scenario.Scenario
- text()#
The complete file: every parameter, stated or at its default, with its comment.
- Return type:
str
- write(path)#
Write the complete file to
pathand return the path.- Parameters:
path (str | pathlib.Path)
- Return type:
pathlib.Path
- absent: list[str] = []#
- folder: pathlib.Path | None = None#
- name: str | None = None#
- resolved: dict[str, Any]#
- values: dict[str, Any]#
- class openmobisim.FleetDay#
What one fleet day did (
fleet_day).- decisions()#
Every decision the policy took, in the order taken, accepted or refused.
Columns:
step(the policy step’s index, 0 at the window’s start),t_s(its second),service,kind(move,target,relocate,charge), the parameters by id (from_dock,to_dock,n,dock,level,vehicle,node,charger,to_soc;Noneor NaN where a kind has none),accepted,reason(why it was refused,Noneif accepted),executed_s(the second it started),finished_s(the van’s or vehicle’s arrival, the charge’s end; NaN if refused or not finished by the window’s end),moved(a move’s bikes in the van),metres(the drive’s),from_target(a move the solver made for the step’s targets).- Return type:
openmobisim.table.Columns
- trip_results()#
What became of each trip given, in the order given.
Columns:
trip_id,service,outcome(completed;cancelled: no taxi within the cancel limit, or no bike at any dock tried;unfinished: still waiting or riding when the window ended;not_requested: asking after the window;not_planned: no leg could be planned),requested_s,pickup_s(a taxi at the pickup; the bike taken),dropoff_s(a taxi’s drop-off at the destination; the bike returned),arrived_s(at the destination, a shared bike’s walk on included; after a bike trip that found no bike, on foot from the last dock tried; NaN after a cancelled taxi request),waiting_s(a taxi’s, from the request to the pickup, the dispatch delay included; NaN if never picked up; 0 for a bike),dock_from,dock_to,vehicle_id,extra_walk_s,redirections,overflow.- Return type:
openmobisim.table.Columns
- counts: dict[str, float]#
- decision_rows: openmobisim.table.Columns#
- dock_bins: dict[str, openmobisim.table.Columns]#
- fidelity: str#
- frozen: dict[str, Any] | None = None#
- plan: dict[str, int]#
- policy: dict[str, Any] | None#
- seconds: dict[str, float]#
- services: list[str]#
- trips: openmobisim.table.Columns#
- class openmobisim.FrankWolfeOptions(*, gap_tolerance=0.0001, iterations=1000)#
equilibration="frank_wolfe"(flow_level=1only):equilibration_options.- Parameters:
gap_tolerance (float)
iterations (int)
- gap_tolerance#
—;
0.0001.
- iterations#
count;
1000.
- class openmobisim.FreeFlowOptions(*, increments=None, warmup=1)#
equilibration="free_flow":equilibration_options.- Parameters:
increments (int | None)
warmup (int)
- increments#
count; by default
None: 1 at flow_level 0 whatever is set.
- warmup#
count;
1.
- class openmobisim.LeastCostOptions(*, max_routes=10, searches=1, slack=0.02, tree_step_s=300.0, until_iteration=0.0)#
route_update="least_cost":route_update_options.Column generation: after each loading, each pair’s least-cost route at that loading’s link times is added to its set when the set lacks it and it costs no more than the set’s best.
- Parameters:
max_routes (int)
searches (int)
slack (float)
tree_step_s (float)
until_iteration (float)
- max_routes#
count;
10.
- searches#
count;
1.
- slack#
—;
0.02.
- tree_step_s#
s;
300.0.
- until_iteration#
—;
0.0.
- class openmobisim.LinkClassOptions(*, free_flow_km_h=None, jam_density_veh_km_lane=None, lanes=None, saturation_flow_veh_h_lane=None)#
One road class’s parameters, for
NetworkOptions(motorway=LinkClassOptions(lanes=3)).Each is
Noneby default: the class’s own shipped value, whichparameters()lists (asmotorway.lanes…). A class without one of them refuses it when the network is read.- Parameters:
free_flow_km_h (float | None)
jam_density_veh_km_lane (float | None)
lanes (int | None)
saturation_flow_veh_h_lane (float | None)
- free_flow_km_h#
km/h.
- jam_density_veh_km_lane#
veh/km per lane.
- lanes#
count.
- saturation_flow_veh_h_lane#
veh/h per lane.
- class openmobisim.LinkPenaltyOptions(*, max_attempts=15, max_detour=1.3, max_overlap=0.75, max_paths=5, penalty=1.5)#
route_method="link_penalty":route_options.The link penalty method (de la Barra, Pérez & Añez 1993): after each least-cost route, the costs of its links are multiplied by
penaltyand the search is repeated.- Parameters:
max_attempts (int)
max_detour (float)
max_overlap (float)
max_paths (int)
penalty (float)
- max_attempts#
count;
15.
- max_detour#
—;
1.3.
- max_overlap#
—;
0.75.
- max_paths#
count;
5.
- penalty#
—;
1.5.
- class openmobisim.LoadingOptions(*, bpr_alpha=0.15, bpr_beta=4.0, node_inflow=0, origin_inflow=0, period_s=0.0, pocket_length_m=50.0, priority=0, reroute=None, reroute_after_s=300.0, reroute_max=3, reroute_min_gain=0.1, reroute_tree_s=60.0)#
The loading’s parameters:
loading_options.- Parameters:
bpr_alpha (float)
bpr_beta (float)
node_inflow (int)
origin_inflow (int)
period_s (float)
pocket_length_m (float)
priority (int)
reroute (int | None)
reroute_after_s (float)
reroute_max (int)
reroute_min_gain (float)
reroute_tree_s (float)
- bpr_alpha#
—;
0.15.
- bpr_beta#
—;
4.0.
- node_inflow#
0 or 1;
0.
- origin_inflow#
0 or 1;
0.
- period_s#
s;
0.0.
- pocket_length_m#
m;
50.0.
- priority#
0 or 1;
0.
- reroute#
0 or 1; by default
None: on at flow_level 3 and 4; off at 2 unless asked for (1).
- reroute_after_s#
s;
300.0.
- reroute_max#
count;
3.
- reroute_min_gain#
—;
0.1.
- reroute_tree_s#
s;
60.0.
- class openmobisim.LogitOptions(*, beta_bike_lane_km=0.0, beta_bike_min=0.0, beta_bike_mixed_km=-0.16, beta_bike_separated_km=0.0, beta_car_min=0.0, beta_cost_eur=-1.2, beta_cost_fare_eur=0.0, beta_cost_parking_eur=0.0, beta_cost_running_eur=0.0, beta_cost_toll_eur=0.0, beta_detour=0.0, beta_length_km=0.0, beta_ln_path_size=1.0, beta_mode_bike=0.0, beta_mode_bike_transit=0.0, beta_mode_car=0.0, beta_mode_car_transit=0.0, beta_mode_transit=0.0, beta_mode_walk=0.0, beta_n_links=0.0, beta_overlap=0.0, beta_parking_min=0.0, beta_ride_bus_min=0.0, beta_ride_ferry_min=0.0, beta_ride_metro_min=0.0, beta_ride_min=0.0, beta_ride_other_min=0.0, beta_ride_rail_min=0.0, beta_ride_tram_min=0.0, beta_time_min=-0.2, beta_transfers=-1.0, beta_trip_departure_h=0.0, beta_wait_first_min=0.0, beta_wait_min=-0.09, beta_wait_transfer_min=0.0, beta_walk_access_min=0.0, beta_walk_egress_min=0.0, beta_walk_min=-0.13, beta_walk_transfer_min=0.0)#
choice_model="logit":choice_options.- Parameters:
beta_bike_lane_km (float)
beta_bike_min (float)
beta_bike_mixed_km (float)
beta_bike_separated_km (float)
beta_car_min (float)
beta_cost_eur (float)
beta_cost_fare_eur (float)
beta_cost_parking_eur (float)
beta_cost_running_eur (float)
beta_cost_toll_eur (float)
beta_detour (float)
beta_length_km (float)
beta_ln_path_size (float)
beta_mode_bike (float)
beta_mode_bike_transit (float)
beta_mode_car (float)
beta_mode_car_transit (float)
beta_mode_transit (float)
beta_mode_walk (float)
beta_n_links (float)
beta_overlap (float)
beta_parking_min (float)
beta_ride_bus_min (float)
beta_ride_ferry_min (float)
beta_ride_metro_min (float)
beta_ride_min (float)
beta_ride_other_min (float)
beta_ride_rail_min (float)
beta_ride_tram_min (float)
beta_time_min (float)
beta_transfers (float)
beta_trip_departure_h (float)
beta_wait_first_min (float)
beta_wait_min (float)
beta_wait_transfer_min (float)
beta_walk_access_min (float)
beta_walk_egress_min (float)
beta_walk_min (float)
beta_walk_transfer_min (float)
- beta_bike_lane_km#
per km;
0.0.
- beta_bike_min#
per min;
0.0.
- beta_bike_mixed_km#
per km;
-0.16.
- beta_bike_separated_km#
per km;
0.0.
- beta_car_min#
per min;
0.0.
- beta_cost_eur#
per EUR;
-1.2.
- beta_cost_fare_eur#
per EUR;
0.0.
- beta_cost_parking_eur#
per EUR;
0.0.
- beta_cost_running_eur#
per EUR;
0.0.
- beta_cost_toll_eur#
per EUR;
0.0.
- beta_detour#
per unit of the attribute;
0.0.
- beta_length_km#
per km;
0.0.
- beta_ln_path_size#
per unit of the attribute;
1.0.
- beta_mode_bike#
per unit of the attribute;
0.0.
- beta_mode_bike_transit#
per unit of the attribute;
0.0.
- beta_mode_car#
per unit of the attribute;
0.0.
- beta_mode_car_transit#
per unit of the attribute;
0.0.
- beta_mode_transit#
per unit of the attribute;
0.0.
- beta_mode_walk#
per unit of the attribute;
0.0.
- beta_n_links#
per unit of the attribute;
0.0.
- beta_overlap#
per unit of the attribute;
0.0.
- beta_parking_min#
per min;
0.0.
- beta_ride_bus_min#
per min;
0.0.
- beta_ride_ferry_min#
per min;
0.0.
- beta_ride_metro_min#
per min;
0.0.
- beta_ride_min#
per min;
0.0.
- beta_ride_other_min#
per min;
0.0.
- beta_ride_rail_min#
per min;
0.0.
- beta_ride_tram_min#
per min;
0.0.
- beta_time_min#
per min;
-0.2.
- beta_transfers#
per unit of the attribute;
-1.0.
- beta_trip_departure_h#
per unit of the attribute;
0.0.
- beta_wait_first_min#
per min;
0.0.
- beta_wait_min#
per min;
-0.09.
- beta_wait_transfer_min#
per min;
0.0.
- beta_walk_access_min#
per min;
0.0.
- beta_walk_egress_min#
per min;
0.0.
- beta_walk_min#
per min;
-0.13.
- beta_walk_transfer_min#
per min;
0.0.
- class openmobisim.ModeOptions(*, bike_access_s=60.0, bike_egress_s=60.0, bike_max_s=3600.0, car_access_s=120.0, car_egress_s=300.0, car_snap_motorway_m=50.0, fallback_car=0, walk_max_s=1800.0)#
The modes’ parameters:
mode_options.- Parameters:
bike_access_s (float)
bike_egress_s (float)
bike_max_s (float)
car_access_s (float)
car_egress_s (float)
car_snap_motorway_m (float)
fallback_car (int)
walk_max_s (float)
- bike_access_s#
s;
60.0.
- bike_egress_s#
s;
60.0.
- bike_max_s#
s;
3600.0.
- car_access_s#
s;
120.0.
- car_egress_s#
s;
300.0.
- car_snap_motorway_m#
m;
50.0.
- fallback_car#
0 or 1;
0.
- walk_max_s#
s;
1800.0.
- class openmobisim.MonteCarloOptions(**options)#
The old name of
SimulationOptions, still accepted with aDeprecationWarning.- Parameters:
options (Any)
- class openmobisim.MsaOptions(*, cost_bin_s=300.0, gap_every=0.0, gap_sample=300, gap_tolerance=0.05, increments=None, iterations=15, itinerary_gap_sample=100000000, route_growth_tolerance=1.0, step_offset=0.0, warmup=1)#
equilibration="msa":equilibration_options.- Parameters:
cost_bin_s (float)
gap_every (float)
gap_sample (int)
gap_tolerance (float)
increments (int | None)
iterations (int)
itinerary_gap_sample (int)
route_growth_tolerance (float)
step_offset (float)
warmup (int)
- cost_bin_s#
s;
300.0.
- gap_every#
—;
0.0.
- gap_sample#
count;
300.
- gap_tolerance#
—;
0.05.
- increments#
count; by default
None: 1 at flow_level 0 whatever is set.
- iterations#
count;
15.
- itinerary_gap_sample#
count;
100000000.
- route_growth_tolerance#
—;
1.0.
- step_offset#
—;
0.0.
- warmup#
count;
1.
- class openmobisim.NestedLogitOptions(*, beta_bike_lane_km=0.0, beta_bike_min=0.0, beta_bike_mixed_km=-0.16, beta_bike_separated_km=0.0, beta_car_min=0.0, beta_cost_eur=-1.2, beta_cost_fare_eur=0.0, beta_cost_parking_eur=0.0, beta_cost_running_eur=0.0, beta_cost_toll_eur=0.0, beta_detour=0.0, beta_length_km=0.0, beta_ln_path_size=1.0, beta_mode_bike=0.0, beta_mode_bike_transit=0.0, beta_mode_car=0.0, beta_mode_car_transit=0.0, beta_mode_transit=0.0, beta_mode_walk=0.0, beta_n_links=0.0, beta_overlap=0.0, beta_parking_min=0.0, beta_ride_bus_min=0.0, beta_ride_ferry_min=0.0, beta_ride_metro_min=0.0, beta_ride_min=0.0, beta_ride_other_min=0.0, beta_ride_rail_min=0.0, beta_ride_tram_min=0.0, beta_time_min=-0.2, beta_transfers=-1.0, beta_trip_departure_h=0.0, beta_wait_first_min=0.0, beta_wait_min=-0.09, beta_wait_transfer_min=0.0, beta_walk_access_min=0.0, beta_walk_egress_min=0.0, beta_walk_min=-0.13, beta_walk_transfer_min=0.0, mu=0.5)#
choice_model="nested_logit":choice_options.- Parameters:
beta_bike_lane_km (float)
beta_bike_min (float)
beta_bike_mixed_km (float)
beta_bike_separated_km (float)
beta_car_min (float)
beta_cost_eur (float)
beta_cost_fare_eur (float)
beta_cost_parking_eur (float)
beta_cost_running_eur (float)
beta_cost_toll_eur (float)
beta_detour (float)
beta_length_km (float)
beta_ln_path_size (float)
beta_mode_bike (float)
beta_mode_bike_transit (float)
beta_mode_car (float)
beta_mode_car_transit (float)
beta_mode_transit (float)
beta_mode_walk (float)
beta_n_links (float)
beta_overlap (float)
beta_parking_min (float)
beta_ride_bus_min (float)
beta_ride_ferry_min (float)
beta_ride_metro_min (float)
beta_ride_min (float)
beta_ride_other_min (float)
beta_ride_rail_min (float)
beta_ride_tram_min (float)
beta_time_min (float)
beta_transfers (float)
beta_trip_departure_h (float)
beta_wait_first_min (float)
beta_wait_min (float)
beta_wait_transfer_min (float)
beta_walk_access_min (float)
beta_walk_egress_min (float)
beta_walk_min (float)
beta_walk_transfer_min (float)
mu (float)
- beta_bike_lane_km#
per km;
0.0.
- beta_bike_min#
per min;
0.0.
- beta_bike_mixed_km#
per km;
-0.16.
- beta_bike_separated_km#
per km;
0.0.
- beta_car_min#
per min;
0.0.
- beta_cost_eur#
per EUR;
-1.2.
- beta_cost_fare_eur#
per EUR;
0.0.
- beta_cost_parking_eur#
per EUR;
0.0.
- beta_cost_running_eur#
per EUR;
0.0.
- beta_cost_toll_eur#
per EUR;
0.0.
- beta_detour#
per unit of the attribute;
0.0.
- beta_length_km#
per km;
0.0.
- beta_ln_path_size#
per unit of the attribute;
1.0.
- beta_mode_bike#
per unit of the attribute;
0.0.
- beta_mode_bike_transit#
per unit of the attribute;
0.0.
- beta_mode_car#
per unit of the attribute;
0.0.
- beta_mode_car_transit#
per unit of the attribute;
0.0.
- beta_mode_transit#
per unit of the attribute;
0.0.
- beta_mode_walk#
per unit of the attribute;
0.0.
- beta_n_links#
per unit of the attribute;
0.0.
- beta_overlap#
per unit of the attribute;
0.0.
- beta_parking_min#
per min;
0.0.
- beta_ride_bus_min#
per min;
0.0.
- beta_ride_ferry_min#
per min;
0.0.
- beta_ride_metro_min#
per min;
0.0.
- beta_ride_min#
per min;
0.0.
- beta_ride_other_min#
per min;
0.0.
- beta_ride_rail_min#
per min;
0.0.
- beta_ride_tram_min#
per min;
0.0.
- beta_time_min#
per min;
-0.2.
- beta_transfers#
per unit of the attribute;
-1.0.
- beta_trip_departure_h#
per unit of the attribute;
0.0.
- beta_wait_first_min#
per min;
0.0.
- beta_wait_min#
per min;
-0.09.
- beta_wait_transfer_min#
per min;
0.0.
- beta_walk_access_min#
per min;
0.0.
- beta_walk_egress_min#
per min;
0.0.
- beta_walk_min#
per min;
-0.13.
- beta_walk_transfer_min#
per min;
0.0.
- mu#
—;
0.5.
- class openmobisim.NetworkOptions(*, bike_dedicated_km_h=18.0, bike_lane_cost_factor=1.0, bike_mixed_cost_factor=1.2, bike_mixed_km_h=15.0, capacity_factor=1.0, control_delay_factor=1.0, ferry_km_h=10.0, ferry_wait_s=300.0, free_flow_speed_factor=1.0, green_fraction_factor=1.0, jam_density_factor=1.0, signal_cycle_s=90.0, signal_degree_of_saturation=0.85, signal_green_fraction=0.48, signal_merge_m=25.0, walk_km_h=4.8, busway=None, cycleway=None, ferry=None, footway=None, living_street=None, motorway=None, motorway_link=None, pedestrian=None, primary=None, primary_link=None, residential=None, secondary=None, secondary_link=None, service=None, street_30=None, street_50=None, street_70=None, tertiary=None, tertiary_link=None, trunk=None, trunk_link=None, unclassified=None)#
The network readers’ parameters:
network_options.- Parameters:
bike_dedicated_km_h (float)
bike_lane_cost_factor (float)
bike_mixed_cost_factor (float)
bike_mixed_km_h (float)
capacity_factor (float)
control_delay_factor (float)
ferry_km_h (float)
ferry_wait_s (float)
free_flow_speed_factor (float)
green_fraction_factor (float)
jam_density_factor (float)
signal_cycle_s (float)
signal_degree_of_saturation (float)
signal_green_fraction (float)
signal_merge_m (float)
walk_km_h (float)
busway (LinkClassOptions | None)
cycleway (LinkClassOptions | None)
ferry (LinkClassOptions | None)
footway (LinkClassOptions | None)
living_street (LinkClassOptions | None)
motorway (LinkClassOptions | None)
motorway_link (LinkClassOptions | None)
pedestrian (LinkClassOptions | None)
primary (LinkClassOptions | None)
primary_link (LinkClassOptions | None)
residential (LinkClassOptions | None)
secondary (LinkClassOptions | None)
secondary_link (LinkClassOptions | None)
service (LinkClassOptions | None)
street_30 (LinkClassOptions | None)
street_50 (LinkClassOptions | None)
street_70 (LinkClassOptions | None)
tertiary (LinkClassOptions | None)
tertiary_link (LinkClassOptions | None)
trunk (LinkClassOptions | None)
trunk_link (LinkClassOptions | None)
unclassified (LinkClassOptions | None)
- bike_dedicated_km_h#
km/h;
18.0.
- bike_lane_cost_factor#
—;
1.0.
- bike_mixed_cost_factor#
—;
1.2.
- bike_mixed_km_h#
km/h;
15.0.
- capacity_factor#
—;
1.0.
- control_delay_factor#
—;
1.0.
- ferry_km_h#
km/h;
10.0.
- ferry_wait_s#
s;
300.0.
- free_flow_speed_factor#
—;
1.0.
- green_fraction_factor#
—;
1.0.
- jam_density_factor#
—;
1.0.
- signal_cycle_s#
s;
90.0.
- signal_degree_of_saturation#
—;
0.85.
- signal_green_fraction#
—;
0.48.
- signal_merge_m#
m;
25.0.
- walk_km_h#
km/h;
4.8.
- busway#
the class’s
LinkClassOptions; its own values by default.
- cycleway#
the class’s
LinkClassOptions; its own values by default.
- ferry#
the class’s
LinkClassOptions; its own values by default.
- footway#
the class’s
LinkClassOptions; its own values by default.
- living_street#
the class’s
LinkClassOptions; its own values by default.
- motorway#
the class’s
LinkClassOptions; its own values by default.
- motorway_link#
the class’s
LinkClassOptions; its own values by default.
- pedestrian#
the class’s
LinkClassOptions; its own values by default.
- primary#
the class’s
LinkClassOptions; its own values by default.
- primary_link#
the class’s
LinkClassOptions; its own values by default.
- residential#
the class’s
LinkClassOptions; its own values by default.
- secondary#
the class’s
LinkClassOptions; its own values by default.
- secondary_link#
the class’s
LinkClassOptions; its own values by default.
- service#
the class’s
LinkClassOptions; its own values by default.
- street_30#
the class’s
LinkClassOptions; its own values by default.
- street_50#
the class’s
LinkClassOptions; its own values by default.
- street_70#
the class’s
LinkClassOptions; its own values by default.
- tertiary#
the class’s
LinkClassOptions; its own values by default.
- tertiary_link#
the class’s
LinkClassOptions; its own values by default.
- trunk#
the class’s
LinkClassOptions; its own values by default.
- trunk_link#
the class’s
LinkClassOptions; its own values by default.
- unclassified#
the class’s
LinkClassOptions; its own values by default.
- class openmobisim.ParkingOptions(*, bin_s=900.0, candidates=3, pr_min_km=3.0, rank_speed_km_h=30.0, reach_bike_s=1200.0, reach_car_s=1800.0, reach_car_step_s=0.0, slope_bike_s=180.0, slope_car_s=600.0, snap_m=300.0, walk_max_s=300.0)#
The parkings’ parameters:
parking_options.- Parameters:
bin_s (float)
candidates (int)
pr_min_km (float)
rank_speed_km_h (float)
reach_bike_s (float)
reach_car_s (float)
reach_car_step_s (float)
slope_bike_s (float)
slope_car_s (float)
snap_m (float)
walk_max_s (float)
- bin_s#
s;
900.0.
- candidates#
count;
3.
- pr_min_km#
km;
3.0.
- rank_speed_km_h#
km/h;
30.0.
- reach_bike_s#
s;
1200.0.
- reach_car_s#
s;
1800.0.
- reach_car_step_s#
s;
0.0.
- slope_bike_s#
s;
180.0.
- slope_car_s#
s;
600.0.
- snap_m#
m;
300.0.
- walk_max_s#
s;
300.0.
- class openmobisim.Parkings#
A scenario’s parkings: park-and-ride car parks and bike parkings.
Read them with
parking_read_osm()oropenmobisim.parking_read_table; give them to aScenario(parkings=) for its"car_transit"and"bike_transit"trips.- by_vehicle()#
Parkings and spaces by vehicle:
{"car": (parkings, spaces), "bike": ...}.- Return type:
dict[str, tuple[int, int]]
- read_report()#
What reading OpenStreetMap found, kept and merged (
Noneif not read from it).- Return type:
dict[str, int] | None
- rows()#
Every parking, as columns.
parking_id,name,hub_id,lon,lat,vehicle,capacity,initial_occupancy,fee_eur(Nonewhere the table gave none: the run’s price for the kind applies).- Return type:
dict[str, Any]
- count: int#
- read_s: float | None#
- class openmobisim.PenaltyOptions(**options)#
The old name of
LinkPenaltyOptions, still accepted with aDeprecationWarning.- Parameters:
options (Any)
- class openmobisim.PriceOptions(*, bike_eur_km=0.0, car_eur_km=0.0, fare_base_eur=0.0, fare_km_eur=0.0, fare_transfer_eur=0.0, parking_bike_eur=0.0, parking_car_eur=0.0)#
The prices:
price_options.- Parameters:
bike_eur_km (float)
car_eur_km (float)
fare_base_eur (float)
fare_km_eur (float)
fare_transfer_eur (float)
parking_bike_eur (float)
parking_car_eur (float)
- bike_eur_km#
EUR/km;
0.0.
- car_eur_km#
EUR/km;
0.0.
- fare_base_eur#
EUR;
0.0.
- fare_km_eur#
EUR/km;
0.0.
- fare_transfer_eur#
EUR;
0.0.
- parking_bike_eur#
EUR;
0.0.
- parking_car_eur#
EUR;
0.0.
- class openmobisim.Run(summary, *, network=None, run_id='run', flow_level=0, flow_step_s=300, transit=None, parkings=None, car_snap_motorway_m=None)#
What one run produced.
- Parameters:
summary (openmobisim._core.RunSummary)
network (openmobisim._core.Network | None)
run_id (str)
flow_level (int)
flow_step_s (int)
transit (openmobisim._core.Transit | None)
parkings (openmobisim._core.Parkings | None)
car_snap_motorway_m (float | None)
- bike_route_choices()#
Which route each stated bike trip took among its set;
Nonewithout bike sets.The same arrays as
route_choices(), one entry per trip of the demand;-1marks a trip that is not a stated bike trip or has no bike route. A trip that chose its mode and took the bike is initinerary_choices()instead (inchains()on the one-loop engine, whosealternativescount the routes in the trip’s own choice set).- Return type:
openmobisim._core.RouteChoices | None
- bike_route_sets()#
The bike route sets, with
bike_route_choice="doubly_stochastic";Noneotherwise.One set per pair of bike-layer nodes, made once per run on the layer’s static costs by the doubly stochastic method (its internal name, the sets’
method, is"sampled"); the first route of a set is the least-cost one. Both engines make them with the same method; on the one-loop engine each route is also a bike chain of its trips’ choice sets (chains()), and a run read back withRun.opengivesNone.- Return type:
openmobisim._core.RouteSets | None
Every dock of the docked bike service, for maps;
Nonewithout a service.dock,hub_id,hub_kind("stop"or"declared"),service,slots,bikes_start(bikes at the start of the day),lonandlat.- Return type:
openmobisim.table.Columns | None
Every dock of the docked bike service over the service day, bin by bin.
Nonewithout a service. One row per dock and time bin (the service’sbin_s, 900 s by default):service,dock,hub_id(its hub: a stop’s withinhub_join_m, or its own),bin_startandbin_end("08:00:00"),bin_start_sandbin_end_s. Its state:slots,bikes_at_start,bikes_at_end,bikes_min,bikes_mean(time-weighted),seconds_empty,seconds_full. Its flows:bikes_taken,bikes_returned. The travellers in trouble there (people):people_found_empty_went_on(found it empty and went on to another dock),people_found_empty_gave_up(found no bike here nor at the docks near, and walked to their destination),people_found_full_went_on(found it full and rode on),people_left_bike_over_capacity,people_sent_here(from another dock, counted in the bin they were sent). An operator’s:bikes_brought_by_van,bikes_taken_by_van(0 without an operator,Scenario.run(policy=...)). The same table is written tobike_share_docks.parquet: read it withbike_share_docks_table().- Return type:
openmobisim.table.Columns | None
bike_share_docks.parquet:bike_share_docks()afterrun_id.Nonewithout a service.- Return type:
openmobisim.table.Table | None
The docked bike service’s logbook over its service day;
Nonewithout a service.The service day: the last loading’s shared-bike and taxi trips, played once after the run had stopped, on its road times, the demand fixed (
Run.service_actual()).One row per event, in time order (one second’s events in the order the simulation handled them), so each traveller’s sequence and each dock’s state after each event can be followed:
service,time_s(seconds from midnight) andtime(the same as"08:03:20"),traveller_idandtrip_seq(as intrip_results();Nonefor an operator’s van),travellers(the people the traveller stands for, each taking a bike; a van’s event: the bikes it moved),event,dock(Noneforreached_destination),bikes_at_dock_afterandfree_slots_after(the dock’s state just after the event;Nonewithout a dock),next_dockandto_next_m(the dock walked or ridden on to, and how far in metres as the crow flies;NoneandNaNotherwise),transit_stop(forreached_transit_stop, the stop’s hub).eventis one of:arrived_for_bike(at the planned dock, or one tried after it),took_bike,found_no_bike,walking_to_next_dock,gave_up_walking_to_destination(no dock left to try within the service’sredirect_maxandredirect_max_m),arrived_to_return,returned_bike,found_no_free_slot,riding_to_next_dock,left_bike_over_capacity(every dock near full: the bike is docked above capacity),reached_destination(abike_sharetrip at its destination),reached_transit_stop(abike_share_transittrip at its stop’s hub, named intransit_stop;dockNone); and for an operator’s vanvan_took_bikesandvan_brought_bikes. A service withoptions={"log_events": 0}keeps no log (for very large runs): no rows. The same table is written tobike_share_events.parquet: read it withbike_share_events_table().- Return type:
openmobisim.table.Columns | None
bike_share_events.parquet:bike_share_events()afterrun_id.Nonewithout a service.- Return type:
openmobisim.table.Table | None
Every trip that chose a shared bike, over the service day;
Nonewithout a service.One row per trip, in trip order. Who:
service,traveller_id,trip_seq,travellers(the people the traveller stands for: the bikes taken),mode("bike_share", or"bike_share_transit": a shared bike to a stop’s hub, transit on). The plan, as the trip’s choice made it:planned_pickup_dock,planned_return_dock,planned_at_pickup_dock_s(when it was to reach that dock),planned_leg_end_s(when it was to arrive had the planned docks had a bike and a free slot). What happened:pickup_dockandpickup_s(NoneandNaN: no bike),docks_tried_for_bike,return_dockandreturn_s,docks_tried_for_slot,leg_end_s(at the destination, or forbike_share_transitthe dock at the stop’s hub; riding, or on foot after finding no bike). The extra time at the docks:extra_s(leg_end_slessplanned_leg_end_s), split intoextra_walk_at_pickup_sandextra_walk_at_return_s(the return’s part: the rides between return docks after a full one, plus the walk from the dock the bike was left at less the planned walk from the planned return dock; the pickup’s: the rest),extra_walk_m(walked between docks looking for a bike, metres as the crow flies);docks_found_emptyanddocks_found_full(docks found empty, and full; the last one included when it found no bike at all or left the bike above capacity).outcome:"completed"(got a bike and returned it),"cancelled"(no bike at any dock tried: walked to the destination),"unfinished"(still looking for a bike or riding when the window ended),"not_requested"(its time at the dock came after the window’s end). The same table is written tobike_share_trips.parquet: read it withbike_share_trips_table().- Return type:
openmobisim.table.Columns | None
bike_share_trips.parquet:bike_share_trips()afterrun_id.What did not happen is null.
Nonewithout a service.- Return type:
openmobisim.table.Table | None
- chains()#
Every chain of every trip’s choice set, one row each (the one-loop engine only).
Columns:
trip(its index in the run),chain(its place in the trip’s set, in the order found),taken(the chain the trip took in the last iteration),probability(what the choice model gave it at the trip’s last choice),cost(its cost in utility units, minus the systematic utility of the trip’s user class, its mode’s constant included) andtravel_time_sat the link travel times of the last loading (door to door: the car’s or the bike’s fixed times included),mode("car","bike"or"walk": a trip whose mode is stated as the bike or walking has one chain on its layer, or withbike_route_choice="doubly_stochastic"a bike trip one per route of its pair’s set; a trip choosing its mode has its car chains, its bike chains and its walk),links(its links in travel order, as the link ids of its mode’s layer: the road network’s for a car, aslink_bins_table()’slink;network.layer("bike")’s or"walk"’s, aslink_bins_table("bike")’s) andlink_index(the same links as indices into that layer’s links; for a car, asroute_sets()holds them). A run with transit trips (their mode stated as"transit", with a timetable) also has, for every chain,in_vehicle_s(seconds in a vehicle: driving, riding a bike, riding transit),walk_s,wait_s(waiting for a transit run, the boarding slack included) andtransfers; and, for a transit chain (mode"transit": one per journey of the timetable kept for its trip), its rides in travel order, one entry per ride in each list:ride_line(the line’s short name),ride_run(the GTFStrip_idof the run ridden),ride_board_stopandride_alight_stop(GTFSstop_id),ride_board_sandride_alight_s(when the run leaves the one and reaches the other, seconds after midnight). Read fromchains.parquet; needs pyarrow.- Return type:
openmobisim.table.Columns
- config()#
The run’s
run.toml, the complete configuration it ran with, as aConfig.Written by every run beside its
manifest.json: every parameter at the value the run used.scenario.run(config=run.config()), on the scenario it ran, repeats it with the same fingerprint;openmobisim run --config <folder>/run.tomltoo when the file names its inputs (a scenario built from files byConfig.scenario), else its header lists what the run had in memory.- Raises:
FileNotFoundError – If the run’s folder holds no
run.toml(a run of an earlier version).- Return type:
- convergence()#
What each iteration showed: how far the run is from an equilibrium.
NumPy arrays, one entry per iteration (a
"free_flow"run has one).nanmarks a number that was not measured. On the one-loop engine the columns are its own, every share weighted by the people a trip stands for and every cost in utility units (minus the systematic utility of the trip’s user class), read on the link travel times the iteration’s loading produced. The stopping shares count only the trips that could change their choice, the car trips and the trips choosing their mode (choosing: their travellers’ weights, summed); a trip whose mode is stated as the bike or walking keeps its one chain and is left out of them.iteration;foundandfound_share(the trips the route search found a chain for that was not yet in their choice set and is cheaper than the cheapest chain of the set by more than the indifference band,indifference_band: how many, and their share; the stopping rule reads the share);addedandadded_share(the trips that had a chain added to their set, within the band or beyond it);switch_share(the share of trips whose chain after the choice differs from the one before) andswitch_floor(what it would be by the choice model’s randomness alone at a stationary state; under the deterministic choice, the chance that the even split moves a trip facing a tie within the band to another of the tied chains) andswitch_excess(of the trips that reconsidered, the share that moved beyond that chance: a noisy estimate, reported only),switch_excess_expected(before the choice, the share of all trips that would change chain beyond the stationary chance if everyone reconsidered,Σ w (Σ P² − P of the chain held) / Σ w: 0 at a stationary state, the stopping rule’s stability measure; the loop stops when its mean over the last three iterations is in absolute value at mostswitch_tolerance, 0.05 by default) andswitch_above_floor(switch_share − switch_floor: the share of all trips that changed chain beyond chance, reported only);departed,arrived,unfinished(people) andunfinished_share;without_chain(people whose trip had no chain: no car, or no route);gap(the relative duality gap within the choice sets, over the trips that could change their choice, as aregap_deterministicandspread,(Σ w·paid − Σ w·least) / Σ w·least, paid the cost of the chain taken and least the least cost in the set);gap_deterministic(the deterministic part of the duality gap,(Σ w·paid − Σ w·expected) / Σ w·least, expected the cost the choice model expects over the set: the gap less the part the model’s own dispersion produces; equal togapunder the deterministic choice);spread(the share of trips on a chain of least cost in their set);mean_trip_s(the mean travel time of the trips that arrived, in seconds); each mode’s shares:found_share_car,found_share_bike,found_share_walk,switch_share_car,switch_share_bikeandswitch_share_walk(the same share over the trips counted in it that held a chain of that mode at the start of the iteration, before its search and choice:switch_share_bikeis the share of the trips on a bike chain that took another chain, of any mode;nanwhen no such trip, as in iteration 0, when no trip has a chain yet; they describe who moved and are not measures of stationarity, since grouping by the chain held conditions on the last choice’s outcome);mode_share_change_expected_car,mode_share_change_expected_bikeandmode_share_change_expected_walk(the stationarity measure by mode: before the choice, how much the mode’s share of the trips counted would change in expectation if everyone reconsidered,Σ w (P_mode − 1[the chain held is of the mode]) / Σ w,P_modethe choice model’s probability of the trip’s chains of that mode; 0 in expectation at a stationary state, positive for a mode still gaining trips; the three sum to 0);mode_change_share(of the trips choosing their mode that held a chain before the choice, the share whose chain after it is of another mode: a change of mode, not of route alone;nanwithout such trips);mode_share_car,mode_share_bikeandmode_share_walk(the modal split of the trips choosing their mode after the choice, over those with a chain;nanwhen no trip chooses its mode); when a trip choosing its mode is offered transit, each of these also for transit (found_share_transit,switch_share_transit,mode_share_change_expected_transit,mode_share_transit), and the fourmode_share_change_expected_columns sum to 0; and each stage’s wall-clock seconds,search_s,choose_s,load_s,measure_sandassess_s. It has no verdict. The columns below are the current engine’s.The result of the run (
completion,total_travel_time_s,link_bins(),route_choices()) is that of the last iteration; with disruptions travellers did not know of, it is that of the one more loading made with them, which no row here describes.iteration— 0 is the free-flow loading: everyone’s first choice, in groups each on the congestion of those before it (increments), loaded with the point queue.reselected_share,changed_share— the share of trips (by weight) that chose again on the way to this iteration, and the share whose route changed.route_changed_floor— whatchanged_sharewould be from the choice model’s own randomness alone at a stationary state, where every trip already stands on a route drawn from the model’s probabilities: over the same trips, the sum over those that chose again of1 − Σ q²(qthe model’s probability of each route offered, at the times they chose on: the chance that two independent draws differ), over the weight of all of them. At a logit equilibriumchanged_sharesits near it; travellers still moving towards better routes put the share above it.nanat the first iteration, without trips given the car, and for a model that gives no probabilities. Not inkpis.parquet.total_travel_time_s,completed,truncated— this loading’s;completed_people, the people its completed trips stand for (their travellers’ weights, summed), so its mean trip istotal_travel_time_s / completed_people.time_change— how much the link times moved since the last loading, as a share of it, weighted by traffic. The stability of the pattern.gap— the usual measure of how far an assignment is from equilibrium: how much more travel time the routes chosen cost than the cheapest route of the same choice set at the times this loading produced,Σ w (t_chosen − t_least) / Σ w t_least, over the trips that finished (the times of trips still under way when the window ended are lower bounds, not measurements),tthe seconds driven from where the car enters the roads. Every car trip counts: those given the car, against their route set, and those choosing their mode (modes) that drove, against the car routes of their choice set (a route no longer in it re-timed at these times), so a run whose trips all choose their mode stops on its car routes too. A stochastic choice model does not reach 0 by design: a logit at −0.2 per minute has a gap of about 7% at equilibrium.gap_expected— the gap the choice model itself expects at these times: the same sum with each traveller’s expected travel time under the model’s probabilities. 0 for the all-or-nothing"deterministic"model;nanfor a model that gives no probabilities.gap_excess— the disequilibrium,gap − gap_expected: what the choice model does not explain (it also holds the sampling noise of a finite population). Below 0.05 is good, below 0.15 acceptable; it is whatgap_tolerancestops on and whatconvergence_verdictjudges (gap_generalised_excessinstead where that is measured). Equal togapfor"deterministic".incomplete_share— the share of the travellers given the car (by weight) whose trip had not finished when the window ended, who are left out of the gaps (as are the trips choosing their mode that had not).gap_network— the same measure against the whole network: the least time over any route at the current times (read off the run’s shared search trees, one time-dependent search per origin and departure bin), for every trip that finished, at the last iteration only,nanelsewhere (gap_sample0 switches it off). It shows whether the choice set was missing a route that traffic has made worthwhile.gap_network_excess— its disequilibrium:gap_networkless what the model explains inside the set, so a route the set was missing counts in full.gap_flow,gap_flow_floor,gap_flow_excess— a check of the stochastic choice model with itself, needing its probabilities: the share of travellers whose route differs from where the probabilities at the current times would put them (half the total variation between observed and expected route flows, by origin-destination pair), what that would be by chance alone (the same measure for a fresh sample from the same probabilities), and the difference. Not a gap to the shortest path.
gap_flow*need a model that can give probabilities ("logit"and"deterministic"do; a Python model may have aprobabilities(batch)method) and arenanwithout one;gapdoes not.routes_added,route_searches— under a route update (route_update="least_cost"), how many routes it added to the route sets after this loading, for the next iteration to choose among, and how many searches that took; 0 without one, and at the last iteration, which no choice follows. ``gap`` is measured against the sets as grown: the routes the travellers may choose from next. Iteration 0’s also counts what the update found while the free-flow loading was built up in groups.reroutes,reroute_searches— en-route rerouting in this loading: how many times a vehicle took a new route, and how many searches for one were made (one per offer to a vehicle stuck at the end of its link, taken or not). Iteration 0’s searches include those of the free-flow loading’s groups.gap_transit,gap_car_transit,gap_bike_transit— the same relative gap for the itineraries of transit, park-and-ride and bike-and-ride trips: each itinerary kept against the least door-to-door time of its choice set at the costs this loading produced;nanfor a mode without such trips.gapabove is the car routes’. With mode choice (modes), a trip’s itinerary is measured against the best of its own mode (with mode constants, the fastest mode need not be the best), andgap_car,gap_bikeandgap_walkare the same for the trips that chose those modes, door to door against the best of their mode (gapabove covers every car trip’s route: given the car, or choosing it). Withitinerary_gap_sampleset below the number of such trips, it is measured on a sample before the last iteration: the trips choosing again and that many others plan their whole choice set; the rest that keep an itinerary out through a parking are re-costed there. The last iteration’s is always exact.itinerary_recosted— how many trips were re-costed that way rather than re-planned; 0 at the last iteration.hub_mismatch_s— the hub expectation mismatch: per traveller who parked, the mean difference between the parking time expected when they chose and the one they paid, in seconds;nanwithout parkings.gap_transit_plan_s— the planned-against-realised difference of transit: over the trips with a transit part that ended in this loading (by traveller weight), the mean of the second the transit part ended (at the destination, or at the parking for a trip back to its vehicle) less the second it would have ended had every vehicle kept to the timetable the trip planned on, followed the same way from the same moment at its first stop, in seconds (negative: earlier). Travellers plan on the timetable, so the gaps above never see it: 0 when the buses keep to the timetable (the default); withtransit_optionsbuses_on_roads1, what traffic did to the buses.nanwhen no trip rode.gap_transit_plan_share— its share of the itineraries’ gap with transit: that mean over itself plus the mean seconds the transit, park-and-ride and bike-and-ride trips measured ingap_transit,gap_car_transitandgap_bike_transitpaid above the best of their mode. 0 when the difference is 0;nanwhen it is, or when no such trip was measured (a run of one loading). Neither is inkpis.parquet.mode_changed_share— withmodes: of the trips choosing their mode that had chosen before, the share (by traveller weight) whose mode changed on the way to this loading;nanat the first iteration and withoutmodes. How the mode split is settling.mode_changed_floor— what that share would be from the choice model’s own randomness alone (among the trips that chose again, the probability of a mode other than the one they had); the settling is done when the share is near its floor.itinerary_gap_excess— the itineraries’ disequilibrium: over the transit, park-and-ride, bike-and-ride and mode-choosing trips, the gap to the best alternative of the mode each kept, less what the choice model itself expects. Part ofconvergence_gapand of whatgap_tolerancestops on.gap_generalised_excess— the disequilibrium in generalised minutes: over the car trips that finished (by traveller weight) and whose route taken was offered to them,(Σ w g_chosen − Σ w g_expected) / Σ w g_least,ga route’s generalised minutes at this loading’s times (defined under the full gaps below),g_expectedits expectation under the model’s probabilities over the routes offered andg_leastthe least of them:gap_excesswith money, length and the user’s link values counted beside time, over the same car trips (a trip choosing its mode costed door to door, as its choice sees its car routes). A ratio, not minutes. Where the choice model weighs more than time on a car route (a price per kilometre, a toll, a user link value), it is whatgap_tolerancestops on in place ofgap_excess, together withitinerary_gap_excess, and whatconvergence_gapandconvergence_verdictread.nanwhere the route cost is travel time alone (the defaults:gap_excessis then its counterpart in travel time), for a model that gives no probabilities, and for a run of one loading.
The full gaps, measured over every trip after the last loading (after every loading with
equilibration_optionsgap_every1, elsenanbefore the last), in the choice model’s own currency (gap_currency).g, an alternative’s generalised minutes, is its utility under the choice model (without the path-size term, which only corrects for routes that overlap) divided by the traveller’s time coefficient: a minute of travel counts one, a eurobeta_cost_eur / beta_time_minminutes. Nothing stops or judges the run on them (gap_tolerance,convergence_gapandconvergence_verdictread the gaps above);nanfor a run of one loading.gap_trips()gives each trip’s numbers.gap_route— the full route gap: over every trip that drove a car route in this loading (given the car, or choosing its mode and keeping a car alternative), how much more the route taken costs than the best route the trip was offered,Σ w (g_chosen − g_best) / Σ w g_best. A trip still under way when the window ended counts: as the time it had travelled plus the time of the links it had not yet left, at their last recorded times held, so trips left on the road weigh in the gap instead of being left out of it. (Where the queue is still growing at the end, those times are below what the rest of it will take.)gap_route_expected— what the choice model itself expectsgap_routeto be at these costs: the same sum with each trip’s expectedgunder the model’s probabilities over the routes it was offered;nanwithout probabilities.gap_route_excess—gap_route − gap_route_expected: the deterministic part of the duality gap (the relative duality gap of the route choice less the part the logit’s own dispersion produces), what the model does not explain.gap_route_network—gap_routeagainst the whole network: the best of the routes offered or the fastest route a time-dependent search finds for the trip, every trip (gap_network: the trips that finished). The search looks for the fastest route, not the cheapest ing, so where money weighs this gap can read low.gap_route_network_excess— its disequilibrium:gap_route_networkless what the model expects inside the set, so a route the set was missing counts in full.gap_mode— the full mode gap: over every trip choosing its mode (modes), how much more the alternative taken costs than the best of its whole choice set, every mode, planned on this loading’s costs;nanwithout mode choice.gap_mode_expected— what the choice model expectsgap_modeto be, from its probabilities over the whole choice set.gap_mode_excess—gap_mode − gap_mode_expected.spread_route— the spread of the route choice, a measure built on the choice model’s probabilities rather than on costs: for each car trip ofgap_routethat arrived on a route it was offered,pis the probability the model gives the route it took andp*the highest probability among the routes it was offered, both at this loading’s costs; the spread isΣ w (1 − p / p*) / Σ w,wthe trip’s people. It is 0 only when every trip is on its most probable route, and below 1. It is not a convergence measure: a logit spreads travellers over routes that are not the best on purpose (each traveller’s unobserved preferences), so at an exact logit equilibrium the spread is above 0 and stays there however long the run iterates; it says how dispersed the choice is, whilegap_route_excesssays how far the run is from equilibrium.nanfor a model that gives no probabilities.spread_mode— the same for the trips choosing their mode,p*the highest probability over the whole choice set, every mode;nanwithout mode choice.excess_min_route— the deterministic part of the route gap as minutes per traveller: what the average traveller pays, ing, above what the model expects of them.excess_min_mode— the same over the trips choosing their mode.unfinished_cost_share— of what the route gap’s trips paid (theirg, summed), the share that trips still under way at the end had still to pay; 0 when every trip arrived.
The numbers up to
gap_flow_excessare also inkpis.parquet, a row per metric per iteration, and so are the itinerary gaps (under their modes, asgap),hub_mismatch_s,mode_changed_share,itinerary_gap_excess,gap_generalised_excessand the full gaps.- Return type:
openmobisim.table.Columns
- diagnostics()#
diagnostics.parquet: aggregated counters, one row per issue.- Return type:
openmobisim.table.Table
- events()#
events.parquet: sampled per-trip events.- Return type:
openmobisim.table.Table
- freeze(folder, *, overwrite=False)#
Write the run’s service day to
folder: a frozen day to replay.A run with a service (
services=[service_bike_docked(...), service_taxi(...)]) plays, once it has stopped, its last loading’s service trips on the fleet engine in one day (the service day). This writes that day’s legs exactly as the run played them, with the road times its taxis drove on and what the run was, so thatfleet_day(network, services, frozen=folder)andfleet_environment(network, services, frozen=folder)play the same day with the travellers’ choices held fixed: an operator’s policy is trained and tested on it. A replay with no policy gives the run’s own service day, leg by leg, bikes and taxis.The folder holds three files:
legs.parquet: one row per leg, in the order the run played them:trip(the trip’s index in the run, as intrip_results()),traveller_id,trip_seq,service(its name),weight(people),request_s(the second it asks for a bike at its pickup dock, or for a taxi at its departure, from midnight),origin_nodeanddestination_node(the trip’s ends as nodes of the network’s walk layer for a shared bike, of the road network for a taxi),dock_fromanddock_to(the docks it chose; empty for a taxi),ride_s(the planned ride between them, the service’sride_factorincluded),egress_s(the walk from the return dock to the destination) andassumed_extra_walk_s(the extra walk at the docks its choice assumed, in seconds;NaNfor a taxi); every number as the run held it, bit for bit; the shared bikes’ legs first, then the taxis’;road_times.bin: the road times the service day’s taxis drove on, per link and time bin the seconds to cross it when entered in that bin (the last loading’s link times; free flow where it recorded none), in the network cache’s binary form; what a policy’s vans and taxis drive on;setup.json:formatandversion, therun_id, the run’s, its network’s and its services’ fingerprints (run_fingerprint,network_fingerprint,services_fingerprint), thewindow(seconds from midnight), theseed(the run’s master seed, the engine’s), theservices(name, kind, docks, options), thelegsandpeople, and the road times’ bin length and rows.
A replay is refused with a network or services other than the run’s.
- Parameters:
folder (str | pathlib.Path) – Where to write; made if missing.
overwrite (bool) – Replace a frozen day already in the folder (
False: refuse).
- Returns:
The folder.
- Raises:
ValueError – For a run without a service, or a folder holding a frozen day already (without
overwrite).RuntimeError – For a run read back with
Run.open: only a run in memory holds its service day.
- Return type:
pathlib.Path
- gap_pairs(departure_bin_s=300)#
The gap per origin, destination and departure bin, on the costs the trips paid.
The trips of
gap_trips()(the last loading’s) grouped by their origin point, their destination point (their coordinates as given, rounded to 1e-6 degrees so that equal points group) and their departure bin,floor((departure_s − start_s) / departure_bin_s)counted from the window’s start (window["start_s"]). A group’s best,g_best_min, is the leastg_chosen_minof its trips: the best cost a trip of the group paid, at the last loading’s costs. Every trip of the group is measured against it. This is the literature’s dynamic relative gap per origin, destination and departure interval, read on the costs paid rather than against a shortest route (Boyles, Lownes & Unnikrishnan 2025, Transportation Network Analysis, the dynamic relative gap): at a dynamic user equilibrium the trips that leave one place for another at about the same time pay the same, and what a trip paid above the best of its group is what it could have saved by doing as that one did. It needs no search.It is meaningful when the trips of a pair share their two points: the benchmark networks’ nodes,
demand_from_od’spoints_per_zone,Case.demand’sone_point_per_zone. With trip ends spread over their zones nearly every group holds one trip, and the gap reads 0. Within a bin the trips leave at different seconds, so where the costs move within it (a queue growing) a trip leaving late reads a gap it could not have closed: the wider the bin, the more it overstates. Trips choosing their mode are grouped the same way, theirg_chosen_minthe alternative they took, so a group may hold them beside trips given the car, and travellers of other classes, whose generalised minutes count money differently. The units aregap_currency’s. Under a stochastic choice model (the logit) it holds the model’s own spread over routes as well as the disequilibrium, so it compares withconvergence()’sgap_route, not withgap_route_excess.One row per group, sorted by origin, destination and bin:
origin_lon,origin_lat,destination_lon,destination_lat(the rounded points),bin_start_s(the bin’s start, seconds after midnight),trips,people(their weights summed),g_best_min,g_mean_min(the mean ofg_chosen_minover the group’s people),excess_min(Σ w (g_chosen − g_best), minutes summed over the group’s people),gap(excess_min / Σ w g_best;nanwhere that is 0) andunfinished(the group’s trips still under way when the window ended).gap_pairs_relativesums it over every group.- Parameters:
departure_bin_s (int) – The bins’ width, in seconds: a whole number of at least 1. A bin as wide as the window gives one group per pair.
- Returns:
The columns, or
Nonefor a run of one loading (gap_trips()isNone).- Raises:
ValueError – If
departure_bin_sis not a whole number of at least 1.RuntimeError – For a run read back with
Run.open, which has nogap_trips().
- Return type:
openmobisim.table.Columns | None
- gap_pairs_relative(departure_bin_s=300)#
The gap per origin, destination and departure bin, as one number for the run.
gap_pairs’ excess summed over every group, over what the groups’ people would have paid at their groups’ best:Σ excess_min / Σ people × g_best_min, a share like the run’s other gaps (0.01 is 1 %). Where every group’s trips are the same trip (one point each end, one second of departure, one class, each given the car and arrived), each group’s best is no lower than the best route its trips were offered, so this is at mostgap_route; trips leaving at other seconds of a bin can make it read higher.- Parameters:
departure_bin_s (int) – The bins’ width, in seconds (
gap_pairs’).- Returns:
The share, or
nanfor a run of one loading (gap_trips()isNone).- Raises:
ValueError – If
departure_bin_sis not a whole number of at least 1.RuntimeError – For a run read back with
Run.open, which has nogap_trips().
- Return type:
float
- gap_trips()#
Each trip’s numbers in the full gaps of the last loading, in generalised minutes.
One row per trip measured, in the order of the demand: a trip that drove a car route, and a trip choosing its mode.
tripis its index in the demand;g_chosen_minthe alternative it took, at the last loading’s costs (a car trip still under way when the window ended: the time it had travelled plus what it still had to drive);g_best_set_minthe best of the car routes it was offered;g_best_network_minthe best over the whole network (the fastest route a time-dependent search finds, if better);g_expected_minwhat the choice model expects of it (over every mode for a trip choosing its mode, over its car routes for the others);g_best_all_minthe best of its whole choice set, every mode (nanfor a trip given its mode);p_ratio_routethe choice model’s probability of the car route it took over the highest probability among the car routes it was offered, andp_ratio_modethe same for the alternative it took over its whole choice set (a trip choosing its mode), eachnanwhere the alternative taken was not offered, the trip was still under way at the end, or the model gives no probabilities;unfinishedwhether it was still under way at the end. The units aregap_currency’s; the sums areconvergence()’sgap_routeandgap_mode, and1 − p_ratio_routeand1 − p_ratio_modeaveraged by traveller weight itsspread_routeandspread_mode, at its last row.In memory, from the run that produced it:
Nonefor a run of one loading, and a run read back withRun.openhas none.- Return type:
openmobisim.table.Columns | None
- itinerary_choices()#
Each itinerary trip’s choice, and each choice of mode;
Nonewithout any.One row per transit, park-and-ride and bike-and-ride trip, and per trip choosing its mode (
modes), by traveller and then by the order of their day. Columns:trip(its index in the run, where trips are grouped by traveller),traveller_idandtrip_seq(its place in that traveller’s day, from 0),user_class(the traveller’s class),mode(the mode taken;Nonefor a trip choosing its mode that had nothing to choose from),mode_choice(whether the trip chose its mode),parking_id(the parking used;Nonefor plain transit or a trip that did not travel),direction("out": vehicle first;"back": transit first, to where the vehicle is;""otherwise),alternatives(how many it chose among when it last chose; 0: it did not travel),probability(what the model gave its choice),expected_s(the chosen itinerary’s door-to-door time expected at the choice),rides(vehicles boarded) andlogsum(the logsum of the trip’s choice set when it was last planned in full — its first choice and each time it chose again; a trip that kept its alternative keeps it — the expected utility of its best alternative,ln Σ exp(utility)for the logit and its nested form for the nested logit;nanfor a model that gives none; a model of one’s own may give one with alogsum(batch)method, one number per situation). In the utility’s units: divided by-beta_time_minit reads in minutes. It is the standard utility-based accessibility measure: compare a trip’s logsum between two scenarios, or average it by class or by origin zone.- Return type:
openmobisim.table.Columns | None
- itinerary_journeys()#
Each itinerary trip’s chosen journey, leg by leg;
Nonewithout any.The journey each row of
itinerary_choices()planned at its last choice, in the same order (tripis the same column), as NumPy arrays; a list per trip (its links, its rides) is given flat with offsets, one more entry than trips: tripi’s links arelinks[link_offsets[i]:link_offsets[i + 1]]. Kept in memory:Nonefor a run opened from its folder.Columns:
road_originandroad_destination(the trip’s origin and destination nodes on the road layer, the pair ofroute_sets();2**32 - 1for none),shape(0 walk, ride(s), walk; 1 vehicle then transit; 2 transit then vehicle; 3 one leg: a car, a bike or a walk; 4 a shared bike; 5 a shared bike then transit; 6 a taxi; 255 no journey),mode(the mode taken,Nonefor no journey),linksandlink_offsets(the vehicle leg’s links, or a walk’s, on its mode’s layer: the road layer for a car or a taxi,network.layer("bike")for a bike or a shared bike,network.layer("walk")for a walk),first_stopandlast_stop(indices intotransit.stops();2**32 - 1without transit), the ridesride_line(an index intotransit.lines()),ride_boardandride_alight(stop indices),ride_s(expected seconds on board) andride_transfer_walk_s(the walk before it from the stop last left, 0 for the first ride), byride_offsets;access_walk_sandegress_walk_s(the walks to the first stop and from the last); the expected secondswalk_s,wait_s,ride_total_s(on board),vehicle_s(driving or cycling) andparking_s(parking, or reaching the parked vehicle), andexpected_s(door to door);dock_pickupanddock_return(a shared bike’s docks, by the docked service’s dock index;2**32 - 1otherwise).viz.map_interactivedraws them, by origin-destination pair.- Return type:
dict[str, Any] | None
- kpis()#
kpis.parquet: long format, one row per metric.Columns
run_id, design_id, replication, iteration, mode, metric, value.modeis"all"for the whole run; the trip metrics of the last loading (trips,total_travel_time_s,completed_trips,truncated_trips,no_vehicle_available_trips,no_feasible_path_trips,mode_not_available_trips,completion_rate) are also given for each mode that has trips ("car","bike","walk", …). Transit addsboardingsand the buses’ numbers under"transit"; the parkings addparking_arrivals,parking_overflow_arrivals,parking_full_share,hub_mismatch_sandvehicles_left_at_parkings— car parkings under"car_transit", bike parkings under"bike_transit"— and the itinerariesitinerary_replanned_tripsandreturn_mismatch_sunder"all". With mode choice (modes) each trip counts under the mode it took, each mode adds itsmode_share(of the trips, weighted by the travellers), and every iteration addsmode_changed_shareunder"all".In a run with a service (
services=), the trips that took it in the last loading count in the last iteration’s"all"rows and under their mode ("bike_share","bike_share_transit","taxi") as the service day gave them, ascompletiondoes:completed_trips,completed_peopleandtotal_travel_time_sby the second each arrived,truncated_tripsthose still under way at the window’s end, andcancelled_trips(written in a run with a service only) the cancelled taxi requests; a shared bike to transit’s transit part is shifted by the day’s difference at the hub’s dock from the planned second. The earlier iterations, which no service day followed, count them as planned. What the day was like is in the rows under the service’s name (requests,rides,cancelled,no_bike,unfinished, the waiting times and the like).- Return type:
openmobisim.table.Table
- link_bins(layer='road')#
Per-link, per-time-bin results, or
Noneif the run did not ask.Ask with
Scenario.run(...)on a scenario built withlink_bin_s. One row per (bin, link) that saw traffic: how much traffic left the link in that bin, and how long it took. Every traversal that finished inside the window counts, including those of trips still under way when it ended. The same table is written tolink_bins.parquet: read it withRun.link_bins_table().layeris"road"(the default),"bike"or"walk": the bike and walk layers’ results are indexed by their own links (run.network.layer("bike")), and theirpcucounts travellers. They areNonewhen no trip of that mode ran.- Parameters:
layer (str)
- Return type:
openmobisim._core.LinkBins | None
- link_bins_table(layer='road')#
link_bins.parquet: the per-link results as a table, orNone.layer="bike"or"walk"readslink_bins_bike.parquetorlink_bins_walk.parquetinstead: the same columns, except that the weighted count istravellersand its timetraveller_seconds.Noneunless the scenario was built withlink_bin_s. One row per (bin, link) that saw traffic, sorted by bin then link, with columnsrun_id, bin, start_s, link, link_index, crossings, pcu, pcu_seconds:linkis the link’s external id (an OSM way and direction, say), the id that survives a rebuilt network;link_indexis its row in the network’s arrays, meaningful only next to this run’s network fingerprint, which the file’s metadata carries.crossingscounts traversals that finished in the bin;pcuis the traffic that left the link (traveller weight and vehicle size included);pcu_secondsis the PCU-weighted time they took. Mean traversal time ispcu_seconds / pcuand the flow in PCU per hour ispcu * 3600 / bin_seconds.
- Parameters:
layer (str)
- Return type:
openmobisim.table.Table | None
- link_select(links, layer='road', *, zones=None, departure_s=None, bin_s=None)#
The select-link analysis: the origin-destination pairs whose trips cross links.
A trip is counted once if the route it travelled crosses at least one of the links. On the road layer that is the route of its car: a car trip’s chosen route, the car leg of a park-and-ride trip, a taxi’s ride with its passenger; for a vehicle that re-routed on the way and arrived, the links it actually took (
route_realised); for a trip still under way when the window ended, its route up to the link it was on (trip_results’link_at_end). On the bike and walk layers, every leg the run put there and their per-link results count: bike rides (one’s own or a shared bike, the bike leg of bike-and-ride), walk trips, and the walks to, from and between transit stops. A transit rider uses no road link (buses are not trips of the demand), so the road layer counts cars and taxis only.- Parameters:
links (int | collections.abc.Sequence[int]) – One link or several, as indices into the layer’s links (the road network’s, or
network.layer("bike")’s or"walk"’s).layer (str) –
"road"(the default),"bike"or"walk". The bike and walk layers need a run with per-link results (link_bin_s).zones (collections.abc.Mapping[str, tuple[float, float]] | None) –
{zone: (lon, lat)}(Case.zones(),demand_read_zones): each trip’s origin and destination go to the nearest zone point.None(the default): the road nodes the trip is routed from and to (the pair ofroute_sets()), for every mode.departure_s (tuple[float, float] | None) –
(start, end)in seconds after midnight: only the trips departing in[start, end). The time is the trip’s departure, not the moment it reaches the link: the run does not keep when each vehicle entered each link.bin_s (int | None) – Rows by departure time too, in bins of this many seconds from midnight.
- Returns:
Columns by name, one row per pair and mode (and departure bin), the most people first:
departure_s(with bin_s: the start of the bin, seconds after midnight),originanddestination(zone names, or road node indices),mode(the mode the trip took),trips(simulated trips that cross the links),people(the people they stand for),share_link(their share of all the people crossing the links, in the same bin) andshare_pair(their share of all the people of the pair, by every mode, departing in the window or the bin: how much the pair depends on the links). The shares are fractions from 0 to 1.- Raises:
ValueError – If a link is not one of the layer’s, the layer is unknown, or the run does not keep what the layer needs (a run read from its folder keeps neither its journeys nor its bike and walk legs).
- Return type:
openmobisim.table.Columns
- logsum_od(trips, zones=None, *, by_class=False)#
The trips’ logsums by origin-destination pair: utility-based accessibility.
The logsum of a trip’s choice set (
itinerary_choices()["logsum"]) averaged over the trips of each pair, weighted by the people they stand for. Trips with a logsum are those that chose their mode or an itinerary (transit, park-and-ride, bike-and-ride); a trip given another mode has none and is left out. Compare a pair’s logsum between two runs (two designs): the change, divided by-beta_time_min(0.2 by default), is what the change is worth in minutes per trip; the level alone means nothing (a logsum is defined up to a constant).- Parameters:
trips (Any) – The trips the run was given: rows of
Scenario.from_parts’demand, or atrips.csvpath.zones (collections.abc.Mapping[str, tuple[float, float]] | None) –
{zone: (lon, lat)}(demand_read_zones): each trip’s origin and destination go to the nearest zone point.None: the pair of drivable nodes nearest them (the nodes the trip starts and ends at).by_class (bool) – Also by the traveller’s class.
- Returns:
origin,destination(zone names, or node indices),user_class(withby_class),trips(simulated),people(their weights) andlogsum(the people-weighted mean, in the utility’s units).- Return type:
Columns by name, one row per pair (and class) with at least one logsum, sorted
- Raises:
ValueError – If the run made no itinerary choice, or a trip with a logsum is not in
trips.
- manifest()#
manifest.json: the file that makes this run reproducible.- Return type:
dict[str, Any]
- classmethod open(folder)#
A finished run, read back from the folder it wrote, without running it again.
It gives what the files hold:
fingerprint,master_seed,choice_model,equilibration,route_update,convergedandmanifest()(frommanifest.json);completion,completion_by_mode,total_travel_time_s,mean_travel_time_s,convergence(),convergence_gapandconvergence_verdict(fromkpis.parquet);timings();trip_results()andtrip_modes()(fromtrip_results.parquet);operator_decisions()(fromoperator_tasks.parquet); and every table (kpis(),diagnostics(),events(),link_bins_table(),parking_bins_table(),transit_calls_table(), thebike_share_*_table()andtaxi_*_table(),operator_tasks_table()). What only the run in memory holds (the network, the route sets and choices, the per-link arrays, the itinerary choices) raises aRuntimeErrorthat says so. Needs pyarrow.- Parameters:
folder (str | pathlib.Path) – The run’s
output_dir, holding itsmanifest.json.- Raises:
FileNotFoundError – If the folder holds no
manifest.json.- Return type:
- operator_decisions()#
Every decision the run’s operator took in its service day, in the order taken.
Accepted or refused, as
FleetDay.decisions()gives them;Nonewithout an operator. The same table is written tooperator_tasks.parquet(read it withoperator_tasks_table()); a run opened from its folder reads it from there.Columns:
step(the policy step’s index, 0 at the window’s start),t_s(its second),service,kind(move,target,relocate,charge), the parameters by id (from_dock,to_dock,n,dock,level,vehicle,node,charger,to_soc;Noneor NaN where a kind has none),accepted,reason(why it was refused,Noneif accepted),executed_s(the second it started),finished_s(the van’s or vehicle’s arrival, the charge’s end; NaN if refused or not finished by the window’s end),moved(a move’s bikes in the van),metres(the drive’s),from_target(a move the solver made for the step’s targets).- Return type:
openmobisim.table.Columns | None
- operator_tasks_table()#
operator_tasks.parquet:operator_decisions()afterrun_id.Nonewithout an operator. A number a decision does not have is null in the file.- Return type:
openmobisim.table.Table | None
- parking_bins()#
How full each parking was over the day, bin by bin;
Nonewithout parkings.Columns, one row per parking and bin:
bin(counted from midnight, like the link bins’:bin = start_s // bin_s, so a window starting at 07:30 in 15-minute bins starts at bin 30),start_s,parking(its index in the run),parking_id,hub_id,vehicle("car"or"bike"),capacity,arrivalsanddepartures(vehicles parked and fetched in the bin, weighted by traveller weight),occupancy_mean,occupancy_max,full_s(seconds of the bin the parking was full) andoverflow_max(the most vehicles above capacity at once: a full parking refuses nobody; it costs more, and the overflow is counted). The same table is written toparking_bins.parquet: read it withparking_bins_table().- Return type:
openmobisim.table.Columns | None
- parking_bins_table()#
parking_bins.parquet:parking_bins()afterrun_id;Nonewithout parkings.The file’s metadata carries the run’s fingerprint and its master seed.
- Return type:
openmobisim.table.Table | None
- parking_places()#
Each parking the run kept, as columns;
Nonewithout parkings.parking_id,hub_id,vehicle,capacity,lon,latandname.parkinginparking_bins()indexes these.- Return type:
openmobisim.table.Columns | None
- report_gridlock()#
What stood still when the last loading’s window ended;
Noneat level 0.vehicles_on_network(still on a link),vehicles_outside(still waiting to enter, at an origin or a stop line),links_waiting(links whose front vehicle was waiting),loops(closed loops of links whose front vehicles wait on one another — gridlock — each a list of link indices in waiting order),loop_count,loop_links, androom_waits_with_room: front vehicles waiting for room on their next link while it had room. The loading lets traffic stop only at jam density, so that is always 0; anything else is a defect to report. A run that ends with loops also records agridlockdiagnostic per loop.- Return type:
dict[str, Any] | None
- report_no_alternative()#
The trips the last choice left with no alternative, and why, as columns.
No mode they may use reached their destination within the limits, so they were not simulated (unless
mode_options={"fallback_car": 1}, when they went by car). One row per trip, in trip order:traveller_id,trip_seq,user_class,departure_s,weight(people),origin_lon,origin_lat,destination_lon,destination_lat,mode_stated(None: the trip chose its mode; else its stated transit, park-and-ride or bike-and-ride, the only mode it was offered),fallback_car(whether it then went by car), and per mode,reason_car,reason_bike,reason_walk,reason_transit,reason_car_transit,reason_bike_transit:""if the mode was not offered (not among the run’smodes, not one the class may use, or not the stated mode), else why it gave nothing:walk_too_long: no walk within the walk limit (walk_max_s);ride_too_long: no ride within the ride limit (bike_max_s);no_vehicle: the traveller has no such vehicle, or left it elsewhere that day;no_road_route: no road route between origin and destination;no_stop_in_reach: no stop within the walk to a stop (access_walk_max_s) of the origin or of the destination;no_transit_journey: stops in reach, but no journey within the longest offered (journey_max_s) on the window’s timetable;too_short: shorter than park-and-ride’s and bike-and-ride’s shortest trip (pr_min_km);unexplained: none of these; a defect to report.
changenames, for each row, what to change: the options behind its reasons (NO_ALTERNATIVE_CHANGES).- Return type:
openmobisim.table.Columns
- report_spillback(min_excess_pcu=5.0)#
The links where a queue outgrew the road in the last loading.
Under the point queue (
flow_level=2, the default) a queue takes no road space; a link whose peak occupancy (the most PCU on it at once) exceeded its storage (jam density x length x lanes) by more thanmin_excess_pcuis where the real queue would have backed up into the links upstream, so the run’s delays around it are optimistic. The minimum (uncalibrated: five cars) leaves out the very short links of an OpenStreetMap network, where a queue of a few cars overflows a few metres of road without consequence.- Parameters:
min_excess_pcu (float) – How many PCU past its storage a link’s peak must be to be listed.
- Returns:
link(internal link id),peak_pcuandstorage_pcu;Noneat level 0. The full model (level 4) keeps queues within storage, so its list is about empty.viz.map_interactivecan show them.- Return type:
NumPy arrays, worst first (by the PCU that did not fit)
- route_changes()#
Every reroute of the last loading, as columns (empty without rerouting).
A vehicle whose next link is closed by a road disruption may re-route where it meets it, at the downstream end of its link (or at its origin, if the closed link is its first); at flow levels 3 and 4, so may one blocked at the downstream end of its link for
reroute_after_s(loading_options). One row per reroute, in the order they happened:trip(its index in the run),traveller_id,trip_seq,second,link(the link at whose downstream end it re-routed; for a trip re-routed at its origin, the closed first link it did not take),next_planned(the next link of its route until then),next_taken(of its new route) andreason("closed_ahead": its next link closed;"stuck": blocked forreroute_after_s). Its planned route is its route choice (route_choices); what it actually took is inroute_realised.- Return type:
openmobisim.table.Columns
- route_choices()#
Which route each trip took, out of how many, and how likely.
NumPy arrays with one entry per trip, in the order of the demand:
route(an index intoroute_sets()),rank(0 is the pair’s best route),pair,alternatives(how many it could choose from),probability(what the model gave the route taken;nanif it gave none) andweight(how many people the trip stands for).-1marks a trip with no route, and every trip that chose its mode (itinerary_choices()has its mode; the car route of such a trip is not reported): the routes are those of the trips of a stated mode.np.bincount(rc.route[rc.route >= 0], rc.weight[rc.route >= 0], minlength=route_sets.route_count)is each route’s number of travellers.- Return type:
openmobisim._core.RouteChoices
- route_realised()#
The realised routes of the trips that re-routed in the last loading and arrived.
trip(their indices) andlinks(for each, the link indices it took, in order). Every other trip followed its planned route, which nothing stores twice.- Return type:
openmobisim.table.Columns
- route_set_summary()#
What the car route sets held and how they were used;
Nonewithout car route sets.Read from
route_sets(),route_choices()andconvergence(); every number is afloat,nanwhere it has nothing to count. A share is weighted by the people a trip stands for (weight) where it is about trips, and unweighted where it is about routes.pairs— how many origin-destination pairs have a route set.routes— how many routes the sets hold in all, the route update’s included.routes_per_pair_mean,routes_per_pair_max— the mean and the largest number of routes in one pair’s set.routes_added— how many routes the route update added over the run (the sum ofconvergence()["routes_added"]); 0 without one. A route added to a full set takes the place of one nobody chose, soroutescan grow by less.route_searches— how many searches the route update made over the run (the sum ofconvergence()["route_searches"]).share_on_best— of the car trips with a route, the share whose route is its pair’s free-flow shortest (the first route of the set,route_choices().rank0).share_routes_unchosen— the share of the routes held that no trip took at the last choice.alternatives_mean,alternatives_p95— the mean and the 95th percentile of the number of routes a car trip could choose from (route_choices().alternatives), over the trips with a route, each trip counted once.
- Return type:
dict[str, float] | None
- route_sets()#
The route sets the trips were routed from.
Every alternative the method found for every origin-destination pair the demand asked for, and, if the run had a route update, the routes it added while iterating (
stamps()says in which iteration each was added; 0 for the method’s own). Draw one pair’s alternatives withopenmobisim.viz.map_route.- Return type:
openmobisim._core.RouteSets
- service_actual()#
What the service day actually gave, as
service_assumptions();Nonewithout one.The service day is the last loading’s service trips played once after the run had stopped (
kpis.parquet’s rows under each service’s name hold all of it). Here, the actual value of each assumption, so a next run can assume it:assumed_wait_s, the actual mean waiting time of the taxi rides, in seconds (from the request to the pickup, the dispatch delay included;waiting_mean_s);assumed_no_taxi_share, the actual cancelled share of the taxi requests, by people (cancelledoverrequests); for a docked service,assumed_extra_walk_at_pickup_sandassumed_extra_walk_at_return_s, the actual mean extra walks at the pickup and at the return over the shared-bike rides, by people (extra_walk_at_pickup_mean_sandextra_walk_at_return_mean_s; per trip,bike_share_trips()’sextra_walk_at_pickup_sandextra_walk_at_return_s). A name nothing measured is left out (no request of that service, or no ride).scenario.run(..., service_assumptions=run.service_actual())runs again with travellers assuming what this run’s service day gave (the names left out keep their shipped values): one step of the travellers learning the services’ level of service, under the study’s control.- Return type:
dict[str, float] | None
- service_assumptions()#
What the run’s travellers assumed about the services, by name;
Nonewithout one.Fixed for the whole run: the values
Scenario.run(service_assumptions=...)set, the shipped ones where it named none:assumed_wait_s,assumed_no_taxi_share,assumed_extra_walk_at_pickup_s,assumed_extra_walk_at_return_s(None: from the docks’ start-of-day bikes, dock by dock). The same asmanifest.json’sservice_assumptions(nullthere forNone), and accepted as it is byScenario.run(service_assumptions=...).- Return type:
dict[str, float | None] | None
- service_policy()#
The operator that steered the run’s service day;
Nonewithout one.{"name", "parameters"}, asScenario.run(policy=...)gave it andmanifest.json’sservice_policyrecords it.- Return type:
dict[str, Any] | None
- skim(mode, origins, destinations=None, *, departure_s=8 * 3600, max_s=3 * 3600)#
A skim: seconds from each origin to each destination by
mode, after this run.The door-to-door time leaving at
departure_s(seconds after midnight), by"car"— the earliest arrival on the last loading’s link times, congestion by time bin included (free flow after a run of one loading; atflow_level=1the static equilibrium’s times, the same all day), nearest drivable node to nearest —"bike"or"walk"— the time of the fastest route on the layer (withbike_cost="utility", the default, a bike trip rides the route of least generalised cost, which may take longer than this time; withbike_cost="time"the two coincide) — or"transit"— the earliest arrival with at least one vehicle, on the times the runs kept, walking to and from stops withintransit_options’access_walk_max_s. Classes’ own limits do not apply. The same point (one node) takes 0;nanwhere nothing arrives withinmax_s.What accessibility measures are made of: the opportunities within 30 minutes by bike from each zone (cumulative), or weighed by a decaying function of time (gravity), by mode and by time of day.
- Parameters:
mode (str) –
"car","bike","walk"or"transit".origins (Any) – The points to leave from:
(lon, lat)pairs, or a dict of them by name (demand_read_zones’ zones).destinations (Any) – The points to arrive at, likewise;
None: the origins.departure_s (float) – When to leave.
max_s (float) – The longest trip looked for.
- Returns:
A
(len(origins), len(destinations))float64 array of seconds.- Raises:
ValueError – For another mode, a transit skim of a run without a timetable, or a departure or limit out of range.
- Return type:
Any
- taxi_events()#
The taxi fleet’s logbook over the service day;
Nonewithout a taxi fleet.One row per event, in time order (one second’s events in the order the simulation handled them), so each traveller’s and each vehicle’s sequence can be followed:
service,time_s(seconds from midnight) andtime(the same as"08:03:20"),event,traveller_idandtrip_seq(as intrip_results();Nonefor a vehicle’s own event),travellers(1: a trip standing for several people asks for that many taxis, each with its own events;Nonefor a vehicle’s own event),vehicle,vehicle_state_after(idle,to_pickup,occupied,relocating,to_charger,chargingorqueued_at_charger),charge_after(its battery’s charge just after, a share; a drive’s energy is taken as it starts),charger, anddrive_km(the kilometres of the drive the event starts;NaNotherwise).eventis one of:asked_for_taxi(at the departure),waiting_for_taxi(no idle vehicle could take it at once: it waits, offered to each vehicle freed),taxi_assigned(a taxi matched; its drive to the pickup starts after the dispatch delay),taxi_arrived_at_pickup,picked_up(boarded, the drive starts),dropped_off(at the destination),request_cancelled(no taxi could pick it up within the fleet’s cancel limitrequest_cancel_s: the trip’s last event, with no walk on),still_waiting_at_window_end,still_riding_at_window_end; and a vehicle’s ownvehicle_went_to_charge(below the fleet’scharge_belowafter a drop-off),queued_for_plug,started_chargingandcharged. A fleet withoptions={"log_events": 0}keeps no log (for very large runs): no rows. The same table is written totaxi_events.parquet: read it withtaxi_events_table().- Return type:
openmobisim.table.Columns | None
- taxi_events_table()#
taxi_events.parquet:taxi_events()afterrun_id.Nonewithout a taxi fleet.- Return type:
openmobisim.table.Table | None
- taxi_trips()#
Every taxi request, over the service day;
Nonewithout a taxi fleet.One row per request (a trip that chose a taxi), in trip order:
service,traveller_id,trip_seq,travellers(the people, each asking for a seat),requested_s(the departure),assumed_wait_s(the waiting time the traveller assumed when choosing),outcome("completed": picked up and dropped off;"cancelled": no taxi could pick it up within the fleet’s cancel limitrequest_cancel_s, and the trip ends there;"unfinished": still waiting or riding when the window ended;"not_requested": a departure after the window),vehicle(the taxi matched),pickup_s(the taxi at the pickup),dropoff_s,waiting_s(from the request to the pickup, the fleet’s dispatch delaydispatch_delay_sincluded),in_vehicle_s(from the pickup to the drop-off, boarding included),ride_km(with the passenger on board) andempty_km(the taxi’s drive to the pickup). Seconds count from midnight; what did not happen isNaN(Nonefor a vehicle). The same table is written totaxi_trips.parquet: read it withtaxi_trips_table().- Return type:
openmobisim.table.Columns | None
- taxi_trips_table()#
taxi_trips.parquet:taxi_trips()afterrun_id.Nonewithout a taxi fleet.- Return type:
openmobisim.table.Table | None
- taxi_vehicles()#
Each taxi of the fleet bin by bin (15 minutes), over the service day;
Nonewithout.service,vehicle,bin_startandbin_end("08:00:00"),bin_start_sandbin_end_s; the seconds of the bin in each state (seconds_idle,seconds_to_pickup,seconds_occupied(boarding included),seconds_relocating,seconds_to_charger,seconds_charging,seconds_queued_at_charger: they add up to the bin’s length);km_occupiedandkm_empty(a drive’s kilometres spread over its seconds),charge_at_startandcharge_at_end(shares of the battery),kwh_chargedandpassengers_dropped_off. The same table is written totaxi_vehicles.parquet: read it withtaxi_vehicles_table().- Return type:
openmobisim.table.Columns | None
- taxi_vehicles_table()#
taxi_vehicles.parquet:taxi_vehicles()afterrun_id.Nonewithout a taxi fleet.- Return type:
openmobisim.table.Table | None
- timings()#
Wall-clock time by stage, measured on this machine’s clock.
Columns by name, one row per stage in the order the stages ended:
stage,iteration(Nonefor a stage outside the iterations) andseconds. Before the iterations:network_read(if the network recorded how long its reading took; it was read before the run, and is not in the total),demand_read,setup(the bike and walk layers, the timetable and the parkings prepared, the fingerprint),static_routes,itineraries_setup,route_sets. Per iteration:route_choiceanditinerary_choice,partial_loadingandroute_update(iteration 0’s: the free-flow loading’s groups, one row each),loading, then after a loading what prepares the next (route_update,route_choice,itinerary_choice),gap(the full gaps ofconvergence(), after the last, or after each withgap_every1) andnetwork_gapafter the last. After them:results_assembled,results_writtenandtotal(the run alone). Also intimings.csvnext to the other files. Times differ between runs, so they are in no result and not in the fingerprint.- Return type:
openmobisim.table.Columns
- transit_calls()#
Every call of the timetable in this run, as columns;
Nonewithout one.One row per call (a run at a stop, in order):
run(the GTFStrip_id),line(its short name),kind("bus","tram","metro","rail","ferry","other"),stop_id,sequence(the call’s place in its run, from 0),scheduled_arrival_s,scheduled_departure_s, andarrival_s,departure_s— the times in the run: a bus that rode the roads keeps the loading’s, the rest the schedule’s;NaN(null intransit_calls.parquet) where a bus had not got there by the end of the window — thenboardings,alightingsandon_board(as the vehicle leaves), weighted by traveller weight. Seconds count from the service day’s midnight.- Return type:
openmobisim.table.Columns | None
- transit_calls_table()#
transit_calls.parquet: every call of the timetable, orNonewithout one.The columns of
transit_calls(), afterrun_id; a time a bus had not reached by the end of the window is null. The file’s metadata carries the run’s fingerprint, its master seed and the service date.- Return type:
openmobisim.table.Table | None
- transit_lines()#
The boardings on each line of the timetable, as columns (the one-loop engine only).
One row per line:
line(its short name),kind("bus","tram","metro","rail","ferry","other") andboardings(the travellers who boarded its runs in the window, weighted by traveller weight).Nonefor a run without transit trips. Read fromtransit_lines.parquet; needs pyarrow.- Return type:
openmobisim.table.Columns | None
- trip_fastest_routes(departure_bin_s=None)#
Each trip’s fastest route by car, at free flow and on the last loading’s link times.
For every trip, from its origin to its destination as its car travels them (the road nodes of its car pair; for a trip choosing its mode, those of its car alternative), leaving when its car enters the roads (its departure plus
mode_options’car_access_s): the fastest route at free flow, and the fastest route time-dependent on the last loading’s link times (each link’s mean travel time by the time bin of entry, as the route choice reads them; free flow after a run of one loading), found as the run’s own searches find them: one search per origin node and departure bin, at the bin’s middle, the route then costed at the trip’s own second (the wait to get onto the first link, then each link at the moment it is entered). Turn restrictions and closures known to travellers apply. A route fastest at the bin’s middle can be beaten at the trip’s own second by at most what the link times change within a bin.The car’s drive (
trip_results()’vehicle_s) set againstfinal_sgives each trip’s relative gap,(vehicle_s − final_s) / final_s; againstfree_flow_s, its congestion ratio,vehicle_s / free_flow_s, which is never below 1 under the point queue.- Parameters:
departure_bin_s (float | None) – The departure bin of the searches, in seconds;
None: the bin of the run’s own search trees (route_update_options’tree_step_s, else the equilibration’s cost bin).- Returns:
trip(its index in the run),origin_nodeanddestination_node(indices into the network’s nodes),car_departure_s(when the car enters the roads, seconds after midnight),free_flow_sandfree_flow_links(the route at free flow: its seconds and its links, indices into the network’s links in driving order),final_sandfinal_links(the route on the last loading’s link times). Every trip has a row, whatever its mode: a trip not by car gets the route its car pair would take, where the run made car routes for that pair. Secondsnanand links empty where no route is found (no car route for the pair, or a destination the roads do not reach); 0 s and no link for a trip whose origin and destination are one node. In memory, from the run that produced it: a run read back withRun.openhas none.- Return type:
Columns, one row per trip in the order of the demand
- Raises:
ValueError – If
departure_bin_sis not above 0.
- trip_modes()#
Every trip’s departure and the mode it took, as columns.
One row per trip, by traveller and then by the order of their day:
traveller_id,trip_seq(its place in that traveller’s day, from 0),departure_s,mode(the stated mode, a trip without one counting as a car trip; withmodes, the mode taken,Nonefor a trip that had nothing to choose from),mode_choice(whether the trip chose its mode) andweight(the people its traveller stands for). A trip that could not travel keeps its mode.viz.chart_mode_sharedraws it.- Return type:
openmobisim.table.Columns
- trip_results()#
Every trip and what became of it, as columns: one row per trip, in trip order.
The table to find the trips that did not finish, or to follow any trip: filter on
outcome(t = run.trip_results().to_pandas(); t[t.outcome == "truncated"]). Also written astrip_results.parquet(withrun_id), whichRun.openreads back. Columns:trip(its index in the run, as inroute_changes),traveller_id,trip_seq(its place in its traveller’s day, from 0),user_class,weight(the people its traveller stands for);origin_lon,origin_lat,destination_lon,destination_lat(as given),departure_s(seconds after midnight);mode(the mode taken, as intrip_modes;Nonefor a trip that chose and had none to choose) andmode_choice(whether it chose its mode);outcome:"completed","truncated"(still travelling when the window ended),"no_vehicle_available","no_feasible_path","mode_not_available"or"no_alternative"(the tripsreport_no_alternativelists, but for those that then went by car: a trip that chose its mode hasmodeNone, one given transit, park-and-ride or bike-and-ride keeps it;completioncounts them under the outcome they had, most oftenno_feasible_path);arrival_sandtravel_time_s:NaNunless the trip completed.travel_time_sis door to door: the fixed times of the trip’s own vehicle (mode_optionscar_access_s,car_egress_s,bike_access_s,bike_egress_s; set to 0, the drive alone), its walks, waits and rides included;vehicle_s: the completed trip’s seconds in a vehicle of its own (the car’s drive, the bike’s ride, in a direct trip or one through a parking; 0 without one), andaccess_egress_s: its fixed seconds around that vehicle (reaching it, leaving it, its parking’s time; 0 without one).NaNunless the trip completed; sotravel_time_s - vehicle_s - access_egress_sis the trip’s walking, waiting and riding in transit;link_at_end: for a trip still travelling when the window ended whose car was on the roads, the road link it was on (driving, or at the stop line) or waited at its origin to enter, an index into the network’s links (aslink_bins’);NaNfor every other trip, and for one on foot, on a bike, in a transit vehicle or at a stop at the end;in a run with a service (
services=), last:service_outcome, what the run’s service day actually gave the trip (the last loading’s service trips played once after the run had stopped, on its road times, the demand fixed):"completed","cancelled"(a taxi: no taxi could pick it up within the fleet’s cancel limit, and the trip ends there; a shared bike: no bike at any dock tried, the traveller walked on) or"unfinished"(still waiting or riding when the window ended),""for a trip that took no service; andservice_arrival_s, the second the traveller actually reached the destination (forbike_share_transitthe hub’s dock): by the service, or on foot after finding no shared bike;NaNif not by the window’s end, after a cancelled taxi request, or for a trip without a service. The trip’s other columns show the planned trip: a service trip arrives when its choice planned.
The outcomes are the last loading’s. Counted by
outcome, the trips agree withcompletion, the no-alternative trips aside, and a service’s trips counted byservice_outcomeinstead: completed whereservice_arrival_sis a number (forbike_share_transit, a planned arrival shifted by the day’s difference at the hub’s dock), cancelled where a taxi request was, truncated otherwise.- Return type:
openmobisim.table.Columns
- property choice_model: str#
The name of the choice model that picked each trip’s route, itinerary or mode.
"nested_logit","logit"or"deterministic", or thenameof a model written in Python.- Return type:
str
- property completion: dict[str, int]#
How many trips completed, and why the others did not, without reading any file.
Keys:
total_trips,completed,truncated,no_vehicle_available,no_feasible_path,mode_not_available(a trip whose mode this run cannot simulate: transit without a timetable, park-and-ride and bike-and-ride without parkings).In a run with a service (
services=), a trip that took the service in the last loading counts as the run’s service day gave it (trip_results’service_outcomeandservice_arrival_s):completedif carried to its destination by the window’s end (a shared-bike traveller who found no bike: if the walk on ended by then),truncatedif still under way then, and a key of its own,cancelled, if its taxi request was cancelled (the trip ends there).- Return type:
dict[str, int]
- property completion_by_mode: dict[str, dict[str, float]]#
completionfor each mode that has trips, and its travel time.{"car": {...}, "bike": {...}}: the keys ofcompletionandtotal_travel_time_s, the mode’s completed trips’ travel time weighted by traveller weight,people(the people its trips stand for: their travellers’ weights, summed) andcompleted_people(the same for its completed trips). The counts ofcompletionare of simulated trips; a mode’s mean trip istotal_travel_time_s / completed_people. They add up to the run’s. A service’s modes count their trips as the service day gave them, ascompletiondoes.- Return type:
dict[str, dict[str, float]]
- property converged: bool#
Whether the run met its stopping rule by its last loading.
On the one-loop engine: whether its stopping rule stopped the loop before the most iterations (
convergence()has fewer rows thanmax_iterations).Under
"msa"and"sra": the disequilibrium, averaged over the last three iterations, undergap_tolerancewith the route sets no longer growing, whether that stopped the run early or held at its last allowed iteration. AlwaysFalsewith agap_toleranceof 0, or under"free_flow".- Return type:
bool
- property convergence_gap: float#
How far the run ended from equilibrium.
The worst of the last iteration’s disequilibrium against the choice set (
convergence()["gap_excess"][-1];gap_generalised_excesswhere it is measured, a run whose choice model weighs more than time on a car route, as its stopping rule does), against the whole network (convergence()["gap_network_excess"][-1], a sample), so a route the choice set was missing cannot hide behind a small in-set number, and of the itineraries (convergence()["itinerary_gap_excess"][-1]: transit, park-and-ride, bike-and-ride and trips choosing their mode, each against the best of the mode it kept). The disequilibrium is the gap less what the choice model itself expects (a logit sends some travellers down a slower route by design, so its gap is never 0); where the model gives no probabilities the plain gaps are used instead.nanif no gap was measured (a"free_flow"run). Seeconvergence_verdict.- Return type:
float
- property convergence_verdict: str | None#
"good"(disequilibrium below 5%),"acceptable"(below 15%) or"poor".Noneif no gap was measured (a"free_flow"run). Judged onconvergence_gap, the disequilibrium: what the choice model does not explain.``”poor”`` whatever the gap when more than 5 % of the trips did not finish (
unfinished_share): the gap is measured over the trips that finished, so a jammed run’s few finishers can read as settled while most of its traffic is still on the road.Noneon the one-loop engine, which judges nothing: itsconvergence()gives the measures.- Return type:
str | None
- property engine: str#
"current"or"one-loop"(Scenario.run).- Type:
The engine the run ran on
- Return type:
str
- property equilibration: str#
"free_flow","msa"or"sra".- Type:
The name of the equilibration strategy
- Return type:
str
- property fallback_car: openmobisim.table.Columns#
The trips that had no alternative and travelled by car, as columns.
No mode they may use reached their destination within the limits (a walk too long, no transit journey, no vehicle), so they went by car — for a traveller without one, a lift or a taxi. They are counted under the car everywhere. Columns:
traveller_id,trip_seq,departure_s,weight(people),origin_lon,origin_lat,destination_lon,destination_lat. Empty unlessmode_options={"fallback_car": 1}(experimental, off by default, when such trips stay unsimulated).report_no_alternative()says why each had no alternative.- Return type:
openmobisim.table.Columns
- property fingerprint: str#
A hash of everything that decides this run’s results (16 hex digits).
The network’s content, the demand, every setting, the route method and its options, the master seed and the code version. Two runs with the same fingerprint were given the same inputs; on one machine they give the same results. Figures print its first eight digits, every results file carries it, so a picture or a table traces back to its run.
- Return type:
str
- flow_level = 0#
- flow_step_s = 300#
- property gap_currency: str#
What the full gaps of
convergence()andgap_trips()are measured in."utility": generalised minutes, each alternative’s utility under the choice model (without the path-size term) over the traveller’s time coefficient."time": door-to-door minutes, for a model that gives no utilities ("deterministic", or one written in Python) or a time coefficient that is not below 0. Not in the run’s files, so a run read back withRun.openhas none.- Return type:
str
- property master_seed: int#
The run’s master seed (
Scenarioargumentmaster_seed).The one number that starts every random stream. Under a sampled choice model (the defaults,
"nested_logit"and"logit") it decides who takes which route; under"deterministic"nothing draws from it and it changes only the fingerprint.- Return type:
int
- property mean_travel_time_s: float#
The mean travel time of the completed trips, in seconds, per person.
total_travel_time_sover the people the completed trips stand for (their travellers’ weights). Dividing bycompletion["completed"]instead counts simulated trips, which differs from people when travellers stand for more than one (default_weight,demand_sample).nanif no trip completed. Door to door (every trip’s fixed times, walks, waits and rides included);mean_vehicle_time_sis the part spent in the trips’ own vehicles.- Return type:
float
- property mean_vehicle_time_s: float#
The mean time in their own vehicles of the completed trips, in seconds, per person.
total_vehicle_time_sover the people the completed trips stand for, asmean_travel_time_s; the trips without a vehicle of their own count with 0.nanif no trip completed.- Return type:
float
- property network: openmobisim._core.Network | None#
The network this run loaded.
- Return type:
openmobisim._core.Network | None
- property parking_summary: dict[str, float] | None#
What the parkings did, as numbers by name;
Nonewithout parkings.parkings_given,parkings_carandparkings_bike(kept),parkings_off_layerandparkings_no_stop(left out: too far from their layers, or no stop within walking distance); and forcarandbike:*_arrivals(vehicles parked),*_overflow_arrivals(of those, the ones that found the parking full),*_mismatch_s(the hub expectation mismatch) and*_left_at_end(still parked when the window ended).- Return type:
dict[str, float] | None
- property parkings: openmobisim._core.Parkings | None#
The parkings this run’s park-and-ride and bike-and-ride trips used, if any.
- Return type:
openmobisim._core.Parkings | None
- property route_update: str#
The name of the route update that grew the route sets between iterations.
"none"(the sets stayed as the route method made them),"best_response"(the internal name of"least_cost", column generation) or"sampled"(the internal name of"doubly_stochastic").- Return type:
str
- run_id = 'run'#
- property timings_path: str#
Run.timings()as a file.- Type:
Path to
timings.csv- Return type:
str
- property total_travel_time_s: float#
Total travel time of the completed trips, in seconds, scaled by traveller weight.
Each trip counts as many times as the people it stands for (its traveller weight): the population’s total, not the sum over simulated travellers. A trip a service carried counts by the second its service day brought it to the destination (
completionsays which trips count).- Return type:
float
- property total_vehicle_time_s: float#
The completed trips’ time in their own vehicles, in seconds, scaled by traveller weight.
The car’s drive and the bike’s ride, in a direct trip or one through a parking: what
total_travel_time_sholds less the fixed times (mode_optionscar_access_sand the like, the parkings’ times), the walks, the waits and the transit rides. With the fixed times at 0, a run of car trips alone has the two equal.- Return type:
float
- property transit: openmobisim._core.Transit | None#
The timetable this run’s transit trips rode, if it had one.
- Return type:
openmobisim._core.Transit | None
- property transit_summary: dict[str, float] | None#
How transit went, as numbers by name;
Nonewithout a timetable.boardings(weighted); and, with buses on the roads (transit_optionsbuses_on_roads1), for the buses:bus_groups_on_roads(bus patterns that rode the roads),bus_groups_by_schedule_off_road,bus_groups_by_schedule_no_routeandbus_groups_by_schedule_implausible(those run by the schedule, and why),bus_runs_on_roads,bus_runs_arrived(reached their last stop within the window) andbus_delay_mean_s(their mean delay there, realised minus scheduled; negative is early). With itinerary trips, how their planning searched the timetable (RAPTOR queries over the whole run):timetable_searches_transit,timetable_searches_outandtimetable_searches_back(made, for plain transit, out of a parking and back to one),timetable_reused_transit,timetable_reused_outandtimetable_reused_back(answered from a search kept earlier in the run instead: the timetable planned on is the same in every iteration, so the same query has the same answer),timetable_kept(searches kept at the end) andtimetable_kept_bytes(the memory they hold).- Return type:
dict[str, float] | None
The share of trips still travelling when the window ended, in the last loading.
truncatedovertotal_tripsofcompletion; 0 without trips. Above 0.05 theconvergence_verdictis"poor"whatever the gap.- Return type:
float
- property window: dict[str, Any]#
The simulation window and what departed outside it, left out of the run.
Keys:
start_sandend_s(seconds after midnight),start_givenandend_given(whether the scenario gave them; else from the earliest departure, rounded down to the quarter hour, fordefault_s),tripsandpeople(the whole demand),before_trips,before_people,before_first_s,before_last_sand the sameafter_*(left out), andtimetable_runs_kept,timetable_runs_cut,timetable_runs_dropped,timetable_calls_dropped(the timetable kept only its calls inside the window;Nonewithout one).- Return type:
dict[str, Any]
- class openmobisim.Scenario(network, *, trips=None, trips_path=None, persons=None, persons_path=None, classes=None, default_weight=1, window=None, flow_level=2, flow_step_s=300, link_bin_s=None, route_method=None, route_options=None, master_seed=0, choice_model=None, choice_options=None, equilibration=None, equilibration_options=None, route_update=None, route_update_options=None, choice_detour_limit=None, choice_max_routes=None, max_cost_vectors=2, route_cache=False, bike_cost='utility', bike_route_choice='shortest', bike_route_options=None, transit=None, transit_options=None, parkings=None, parking_options=None, services=None, modes=None, mode_options=None, loading_options=None, price_options=None, link_values=None, person_values=None, trip_values=None, disruptions=None, disruptions_known=False, zones=None, preset=None)#
A network, demand, and the settings of a run.
Build with
from_partsrather than the constructor directly.- Parameters:
network (openmobisim._core.Network)
trips (list[tuple] | None)
trips_path (str | None)
persons (list[tuple] | None)
persons_path (str | None)
classes (dict[str, Any] | None)
default_weight (int)
window (tuple[str | float | None, str | float | None] | None)
flow_level (int)
flow_step_s (int)
link_bin_s (int | None)
route_method (str | None)
route_options (dict[str, float] | None)
master_seed (int)
choice_model (str | Any | None)
choice_options (dict[str, float] | None)
equilibration (str | None)
equilibration_options (dict[str, float] | None)
route_update (str | None)
route_update_options (dict[str, float] | None)
choice_detour_limit (float | None)
choice_max_routes (int | None)
max_cost_vectors (int)
route_cache (bool)
bike_cost (str)
bike_route_choice (str)
bike_route_options (dict[str, float] | None)
transit (openmobisim._core.Transit | None)
transit_options (dict[str, float] | None)
parkings (openmobisim._core.Parkings | None)
parking_options (dict[str, float] | None)
services (list[Any] | tuple[Any, ...] | None)
modes (tuple[str, ...] | list[str] | None)
mode_options (dict[str, float] | None)
loading_options (dict[str, float] | None)
price_options (dict[str, float] | None)
link_values (dict[str, dict[str, Any]] | None)
person_values (dict[str, Any] | None)
trip_values (dict[str, Any] | None)
disruptions (list[dict[str, Any]] | None)
disruptions_known (bool)
zones (collections.abc.Mapping[str, tuple[float, float]] | str | pathlib.Path | None)
preset (str | None)
- classmethod from_parts(network, demand, persons=None, classes=None, default_weight=1, window=None, flow_level=2, flow_step_s=300, link_bin_s=None, route_method=None, route_options=None, master_seed=0, choice_model=None, choice_options=None, equilibration=None, equilibration_options=None, route_update=None, route_update_options=None, choice_detour_limit=None, choice_max_routes=None, max_cost_vectors=2, route_cache=False, bike_cost='utility', bike_route_choice='shortest', bike_route_options=None, transit=None, transit_options=None, parkings=None, parking_options=None, services=None, modes=None, mode_options=None, loading_options=None, price_options=None, link_values=None, person_values=None, trip_values=None, disruptions=None, disruptions_known=False, zones=None, preset=None)#
Build a scenario from a network and demand.
- Parameters:
network (openmobisim._core.Network) – Built by, for example,
examples.manhattan_grid.demand (Any) – The trips, in the schema of
trips.parquetwhatever the form: rows (Tripnamed tuples, or plain tuples of the same fields, asexamples.fixed_car_tripsreturns), a dict of columns or a pandas or polars data frame with those columns (weightandmodeoptional), or a path to atrips.parquetfile or atrips.csv(read bydemand_read_trips). Every row in memory is checked first, and a bad one is refused with its number and the field (a latitude outside ±90, a departure that is not whole seconds …); so is a second row with a(traveller_id, trip_seq)already given, since a trip is keyed by the pair (a file read by its path is checked the same way). A row may end with a mode (themodecolumn oftrips.parquet):"car","bike","walk","transit","car_transit"(park-and-ride) or"bike_transit"(bike-and-ride; seeparkings). A trip without one is a car trip, or, withmodes, chooses one. Bike and walk trips travel on the network’s bike and walk layers (network.layer("bike")), each by its shortest route there; a bike trip needs the traveller’s bike at its origin, as a car trip needs their car. A transit trip needstransit: it walks to a stop, rides and walks on (seetransit).persons (list[tuple] | str | None) – The
persons.parquetequivalent — an in-memory table, a file path, orNoneif every traveller takes their class’s default ownership.classes (dict[str, Any] | None) – The traveller classes,
{class_name: columns}, a trip’s class being itsuser_class:demand_read_classesreads them from a CSV file, or give a dict of the same columns. A class may saymodes(the modes its travellers may use:["car", "transit", "car_transit"]; unsaid: every mode the run offers),owns_car,owns_bike,has_transit_pass(what each of them owns, unless apersonsrow says otherwise; unsaid: a car for a class that may drive or park and ride, a bike for one that may cycle, both for one whose modes are unsaid, and no pass; a traveller with a transit pass pays no fare, whatever theprice_options— the pass is money, never access: who may take transit is said by the modes, so givehas_transit_passas 1 for a class that holds one; its own price is not counted),has_bike_share(0: never offered a shared bike,services; unsaid: offered, whatever the class’smodes, which govern the ordinary modes only),has_taxi(likewise for a taxi) and anybeta_*coefficient of the choice model (its own mode constants,beta_mode_bike…, or its own value of time,beta_time_min; unsaid:choice_options’), for"logit"and"nested_logit", and its own choice-set limits in seconds:walk_max_sandbike_max_s, the longest walk and ride offered to its trips choosing their mode, andaccess_walk_max_s, the longest walk to or from a stop (unsaid:mode_options’ andtransit_options’; for example a class of keen cyclists riding up to 90 minutes,{"bike_max_s": 5400}); itsshareis read only bydemand_assign_classes. The tuple(owns_car, owns_bike, has_transit_pass)is a class that says only what it owns. When the classes say their modes and ``modes`` is not given, the run offers every mode a class names, and a trip without a stated mode chooses among those its class may use. A class not listed (all of them, withoutclasses) may use every mode, with the model’s coefficients, and owns a car, a bike and a transit pass unless apersonsrow says otherwise. A class with none of the run’s modes leaves its choosing trips without an itinerary. Every value is the user’s, not a calibration.default_weight (int) – How many people a simulated traveller stands for, for a trip whose row gives no weight. 1 simulates everyone; a larger number is faster and coarser.
window (tuple[str | float | None, str | float | None] | None) – The simulation window,
(start, end)as clock times (("07:30", "09:30")) or seconds after midnight. The run starts at the start and stops at the end: a trip still under way then is unfinished, counted and reported; a timetable keeps only each run’s calls inside the window. A trip departing outside it is left out — not simulated, not counted in any result — with aWindowWarningthat says how many, when and how to widen the window. Not given (orNonefor either end): from the earliest departure, rounded down to the quarter hour, for three hours. Leave each trip time to finish: a demand whose departures end well before the window does (an hour, say) finishes inside it.flow_level (int) – How vehicles load the network.
2(the default) is the point queue: the link transmission model with unlimited storage. A queue forms at the downstream end of a link, behind its capacity or that of the link ahead (a bottleneck in Vickrey’s sense), and delays everyone behind it on that link, but takes no road space, so it never blocks the links upstream and nothing gridlocks. Equilibrium iterations converge steadily with it, and it is the cheapest loading with congestion: the right model for planning studies.Run.report_spillback()lists the links whose queue would not have fitted on the road.4is the full triangular fundamental diagram: queues take road space and spill back to the links upstream, with turn pockets and en-route rerouting against gridlock — for studies where spillback itself matters (traffic control, incidents, evacuation); under heavy congestion its iterations can drift.3is a spatial queue.0is free flow: no vehicle affects another, so there is no congestion, and a run that iterates has nothing to settle — for debugging, or as a lower bound.1is the static assignment of planning practice, the rung between free flow and the point queue: no time inside the period, one hourly flow per link, a link’s time from its flow by the volume-delay function of the Bureau of Public Roads (loading_optionsbpr_alpha,bpr_beta), and the deterministic user equilibrium (every used route of a pair as fast as its fastest) solved byequilibration"frank_wolfe"or"msa". Before it routes, the run moves every trip end to its zone’s point (zones;demand_aggregate_space) and every departure to the window’s start (demand_aggregate_time); a link’s flow is the cars routed over it over the period the departures span, in hours (loading_optionsperiod_s: a demand departing over one hour is one hour of flow, whatever the window). Each trip is then given one of its pair’s equilibrium routes, by the routes’ shares, and takes that route’s time: every trip arrives. Bike and walk trips travel on their layers as at every level; transit, parkings, mode choice and disruptions the travellers do not know of are refused (a road disruption they know of narrows or closes its links for the whole period). Underequilibration="free_flow"(the free-flow loading alone, no iterations) every level from 2 loads as the point queue (equilibration_optionswarmup, 1 by default), so levels 2, 3 and 4 differ only in whether stuck vehicles may re-route (loading_optionsreroute: off at 2, on at 3 and 4); the level sets how"msa"’s iterations after it load.flow_step_s (int) – The loading step in seconds, for levels 2-4. It is a bookkeeping boundary: results do not depend on it.
link_bin_s (int | None) – If given, also record per-link results in time bins of this many seconds, read with
Run.link_bins()and drawn withopenmobisim.viz.map_link. It changes no result: the link times travellers choose on are binned at the equilibration’scost_bin_s.route_method (str | None) – How route sets are generated, by name (see
openmobisim.route_methods()). The default depends on the run: a run that loads once uses"link_penalty"; a run that loads more than once (anequilibrationwith more than one iteration, or a free-flow loading built up in groups, the default atflow_level2 to 4) starts from"shortest", one route per pair (two where it ties), and lets the route update find the rest (measured: as good as the alternatives of the other methods at about half the time). Naming a method, or givingroute_options, overrides this (options alone mean"link_penalty"). Every method searches by the generalised cost, read from the choice model: a link’s travel time plus the seconds-equivalent of every per-link term the utility weighs (length, running cost, tolls, user link values), each user class by its own coefficients (max_cost_vectors); with the defaults, which weigh only time on a car route, by the free-flow time."link_penalty", the link penalty method (de la Barra, Pérez & Añez 1993), finds distinct alternatives: the least-cost route, then repeatedly the least-cost route after the cost of every link of the route just found is multiplied bypenalty."shortest"makes one route per pair, the least-cost one, and beside it its equal-cost twin where it has one: a route that leaves it once and joins it again and costs at mosttwin_tolerance(0.1 %) more, so that the choice model, not the order of the network’s links, splits a tie."simulation", stochastic simulation of link costs (Ramming 2002), finds routes by searching under random link costs biased towards the links the demand is likely to congest (the busiest half-hour’s load on shortest routes over each link’s capacity, from this scenario’s trips and their weights): routes that go round what the demand will jam. It has been measured on few networks: better alternatives than"link_penalty"on one city’s heavy load, worse on another’s."doubly_stochastic", doubly stochastic choice-set generation (Bovy & Fiorenzo-Catalano 2006-2007; an option, never a default), finds routes that differ in what travellers value: first the free-flow fastest route; then, for each user class and each preference draw, the cheapest route by that class’s generalised cost (travel time plus extra seconds per link for its length, its money and the user’s link values, weighed by the choice model’s coefficients ontime_min,length_km,cost_eurand its partscost_running_eurandcost_toll_eur,bike_mixed_kmandlink_valuescolumns named<layer>_<name>_kmor<layer>_<name>_sum; a choice model written in Python gives travel time only). Draw 0 is the class’s own coefficients; each further draw multiplies every coefficient but time’s by1 + tau·v,vuniform in [-1, 1), and every link’s cost by1 + sigma·u,uuniform in [0, 1). A route is kept if it is new, its generalised cost (unperturbed, by the coefficients it was found with) is at mostmax_detourtimes the first route’s, and it shares at mostmax_overlapof that cost with each route kept before it, up tomax_pathsroutes. Which route a trip takes among its alternatives ischoice_model’s business. The old names"penalty","montecarlo"and"sampled"are still accepted, with aDeprecationWarning.route_options (dict[str, float] | None) – The method’s options, numbers by name; unknown names and out-of-range values are refused. For
"link_penalty":max_paths(5),max_detour(1.3),max_overlap(0.75),penalty(1.5),max_attempts(15). For"shortest":max_paths(2; 1 for the least-cost route alone) andtwin_tolerance(0.001). For"simulation":draws(16),sigma(4: how far a link’s cost may rise, times its bias),max_detour(2),max_overlap(0.9),max_paths(10),seed(0: another seed is another set of draws) andbiased(1; 0 for no bias, which measured worse on the one heavy load it was tried on). For"doubly_stochastic":draws(4: preference draws per user class beside its own coefficients; 0 searches each class’s own generalised cost only),sigma(0.5),tau(0.3),max_detour(1.5),max_overlap(0.9),max_paths(10) andseed(0: another seed is another set of draws). Every value is an assumption, not a calibration.master_seed (int) – The one number that starts every random stream, so a run is reproduced by giving it the same one. Under a sampled choice model (the defaults,
"nested_logit"and"logit") it decides who takes which route; under"deterministic"nothing draws from it and it changes only the run’s fingerprint. A non-negative integer below 2**64.choice_model (str | Any | None) – How each trip picks a route from its pair’s set: a name from
openmobisim.choice_models()or an object with achoose(batch)method (seeopenmobisim.choicefor how to write one). Unsaid:"nested_logit"when the run offers more than one mode (modes, or the classes name them),"logit"otherwise."logit"is the standard path-size logit, sampled per traveller;"nested_logit"is the logit with the alternatives of each mode in a nest of their own, for mode choice: a mode’s many routes do not outweigh another mode’s one (under a flat logit the car’s share grows with how many of its routes are offered), and within a nest the choice is sharper by1/mu— a stated car trip’s route choice too, in a run that offers modes;"deterministic"sends everyone down the best route, with probability 1 — useful for debugging or an upper bound, not for a result to report.choice_options (dict[str, float] | None) – A built-in model’s options, numbers by name: for
"logit"and"nested_logit"a coefficient per attribute,beta_time_min(default -0.2),beta_ln_path_size(1),beta_walk_min(-0.13) andbeta_wait_min(-0.09, on top of the time),beta_transfers(-1),beta_bike_mixed_km(-0.16, a bike leg’s kilometre in mixed traffic, on top of its time),beta_cost_eur(-1.2 per euro, 10 €/h: money, seeprice_options), and 0 for the rest, such asbeta_length_km,beta_parking_minor the mode constantsbeta_mode_bike… (openmobisim.choice.ROUTE_ATTRIBUTESlists them), and products of two attributes,beta_<a>*<b>(seetrip_values); for"nested_logit"alsomu(0.5), the nests’ scale, from above 0 to 1 (1 is the logit). Unknown names and non-numbers are refused. The defaults are an assumption, not a calibration.choice_detour_limit (float | None) – A time-dependent choice set: a traveller is offered only the routes of the pair’s set whose expected time, at the times of the last loading (free flow for the first choice), is within this share of the best route’s:
0.5offers a route only if it is at most 50% slower than the best right now. A route far slower than the best is no realistic alternative, and in a logit it only takes probability that belongs to routes that compete (the gap grows with the size of the set).0offers every route of the set;None(the default) is the library’s default, 0.5. With mode choice it applies within each mode: a walk slower than a drive is still offered. The best route is always offered; a route left out is still in the set and returns when times change. The gaps are still measured against the whole set. Theln_path_sizeattribute is computed over the routes offered, so overlap with a route nobody is offered is no overlap.choice_max_routes (int | None) – The most routes a traveller is offered: the fastest at their departure, of those within
choice_detour_limit(people consider a handful of routes, Prato 2009, https://doi.org/10.1016/S1755-5345(13)70005-8; uncalibrated).None(the default) is the library’s default, 5;0offers every route within the limit. A pair’s set may hold more (the route update’smax_routes, 10), so a route not offered now can be later.max_cost_vectors (int) – The most coefficient vectors route searches are made by. Every route search (generation, the route update, the offered set, the gaps, park-and-ride’s drives, rerouting) minimises the choice model’s link-additive utility: the travel time plus the seconds-equivalent of every per-link term the utility weighs (length, running cost, tolls, user link values, and for bikes the kilometres by facility). A user class whose coefficients on those terms differ from another’s gets its own search trees, up to this many (each costs about one more set of trees per loading); beyond it, a class is searched by the kept class’s nearest by value of time, and the run records a
cost_vectors_groupeddiagnostic. Where the utility weighs time alone (cars at the defaults: every price 0) every search is by time and this changes nothing.2by default (uncalibrated: a bound on run time).bike_cost (str) – How bike trips choose their route on the bike layer:
"utility"(the default) is the least-cost route by the choice model’s bike coefficients: the travel time plus the seconds-equivalent of every per-link term the utility weighs (beta_bike_mixed_km, each kilometre in mixed traffic, by default; a ferry crossing is not mixed traffic), so the route and the mode are chosen on one utility; a model without coefficients rides the fastest route. Bike routes are one per pair, shared by every class: the coefficients of the class serving the most people are used, and a class with other coefficients is recorded as acost_vectors_groupeddiagnostic."dedicated"is the fastest route with every minute in mixed traffic counting a little more (1.2 times);"time"is the fastest route. Bikes ride at 15 km/h in mixed traffic and 18 km/h on dedicated infrastructure; these values and the 1.2 are defaults, not a calibration.bike_route_choice (str) – Whether a bike trip has a choice of routes (an option, never a default).
"shortest"(the default): one route per pair, the least-cost route underbike_cost."doubly_stochastic": the"doubly_stochastic"route method (seeroute_method) makes a set of routes per pair on the bike layer, the generalised cost of each class including its coefficients onbike_mixed_km,length_kmand money; every bike trip with a stated mode then chooses its route once, on the layer’s times, throughchoice_model(with the path size over the routes offered,choice_detour_limitandchoice_max_routesas for car routes), and a trip choosing its mode is offered every bike route as an alternative. The run’s fingerprint names the option;Run.bike_route_sets()andRun.bike_route_choices()show the sets and the choices. Onengine="one-loop"the same method makes the sets, its generalised cost underbike_cost="utility"reading each class’s coefficients onlength_km,bike_mixed_km,bike_lane_kmandbike_separated_km(under"time"or"dedicated", that cost alone); each route is a bike chain of the trip’s choice set, a bike trip with a stated mode chooses among them in every iteration in which it reconsiders, always on the same static times, and the whole set is offered (nochoice_detour_limitorchoice_max_routes).bike_route_options (dict[str, float] | None) – The
"doubly_stochastic"method’s options for the bike layer, numbers by name (draws,sigma,tau,max_detour,max_overlap,max_paths,seed; the same defaults as for car routes). Only withbike_route_choice="doubly_stochastic". The old name"sampled"is still accepted, with aDeprecationWarning.route_cache (bool) – Keep the generated route sets in memory for the next run of this process that asks for the same: the same network, the same origin-destination pairs, the same route method and options and, for a method that reads the demand (
"simulation"), the same trips. Generating them is the largest single cost of a run that iterates, so a study that runs one scenario many times, changing only the equilibration, the choice model, the flow level or a seed, pays it once. Results do not depend on whether the cache was used. Holds at most four sets (about 17 MB at the scale of a country’s network each);openmobisim.route_cache_clear()forgets them,openmobisim.route_cache_info()says(hits, misses, held).equilibration (str | None) – How choice and loading are repeated (see
openmobisim.equilibration_strategies())."msa"(the default) is the method of successive averages in traveller form: load the network, read the link times it produced, let a share1/(i + 1)of travellers choose again on those times at iterationi, load again."sra"is self-regulated averaging:"msa"with a share that regulates itself,1/ηat each iteration, where η is 2 at the first and grows byeta_fellafter a loading whose disequilibrium fell and byeta_roseafter one where it rose, so the share shrinks slowly while the run improves and fast when it does not (with both 1 it is"msa"); the share at iterationireacts to the loadings up toi - 2, the last assessed when its travellers choose."free_flow"makes only the free-flow loading: a quick estimate of the day without iterating. At ``flow_level=1`` (the static assignment) the strategy is its solver, iterating inside the run’s one loading:"frank_wolfe"(only there), the step that minimises the Beckmann objective;"msa", the method of successive averages, step1/(k + 1);"free_flow", one all-or-nothing assignment on free-flow times;"sra"is refused. Each stops at itsiterationsor once the relative gap of the flows (how much more they cost than everyone on the fastest route, as a share of that) is below itsgap_tolerance;convergence()has one row per solver iteration (reselected_sharethe step,gapthe relative gap). Atmsa’s defaults (10 iterations, a gap of 0.05) the equilibrium is coarse: raiseiterationsand lowergap_tolerance, or use"frank_wolfe". The choice model,master_seed,route_method,route_updateandlink_valuesshape nothing at level 1 (they stay in the fingerprint as given). The free-flow loading is how every run starts (iteration 0). The travellers are split into groups of about equal size (increments, 5 by default); the first group chooses on free-flow costs, then the network is loaded with the groups so far and the next group chooses on the times that produced (its pairs searched for routes on those times first), until everyone has chosen and the whole demand is loaded. Each group sees the congestion of those before it, so routes spread before the first full loading (incremental assignment). It uses the point-queue model (warmup): queues delay traffic but take no space, so nothing spills back and nothing locks; the iterations that follow useflow_level. Atflow_level=0there are no groups, since nothing congests. Either way, equilibration only changes anything when vehicles interact (flow_level2 to 4, the default 2) and a choice model gives travellers something to choose between ("logit"): atflow_level=0(free flow, no interaction),"msa"still runs but has nothing to disagree with itself about, so it settles immediately at the choice model’s own floor.Run.convergence()says how the iterations went, andRun.convergence_verdictjudges the disequilibrium the last iteration ended at.equilibration_options (dict[str, float] | None) – The strategy’s options, numbers by name: for
"msa",iterations(15; the most loadings),gap_tolerance(0.05: stop once the disequilibrium, averaged over the last three iterations, is below this, the verdict’s “good”; 0.15 is acceptable; 0 never stops early),route_growth_tolerance(1: and only while the last route update added routes for at most this share of the pairs it searched; 1 lets the gap alone decide, since it is measured against the sets as grown),step_offset(0: at iteration i a share 1/(i + 1 + step_offset) of the travellers chooses again; a larger offset makes the first steps smaller, so the first choices after the free-flow loading overshoot less),gap_sample(300; whether the trips are tested against the whole network at the last iteration: 0 for none, any other value every finished trip, read off the run’s shared search trees),itinerary_gap_sample(100 000 000, that is every trip: how many transit, park-and-ride and bike-and-ride trips, besides those choosing again, plan their whole choice set after each loading to measure their gap; with fewer, the others that keep an itinerary out through a parking are re-costed at that parking, which is faster but makes the gap before the last iteration read low; the last iteration always plans every trip) andcost_bin_s(300: the length of the time bins the link times are read in); for"sra", all of"msa"’s andeta_fell(0.2, from 0 to 1: how much η grows after a loading whose disequilibrium fell) andeta_rose(1.5, from 1 to 10: after one where it rose or stayed); for"frank_wolfe"(flow_level=1only)iterations(1000, up to 100 000) andgap_tolerance(0.0001: stop once the relative gap of the flows is below this; 0 never stops early). For the first three:increments(5 atflow_level2 to 4, else 1: in how many groups the free-flow loading is built up; 1 lets everyone choose at once on free-flow costs) andwarmup(1 atflow_level2 to 4 or for a run that iterates, else 0: how many of the first loadings, the free-flow loading’s groups included, use the point-queue model, which cannot gridlock; the last loading of a run that iterates, its result, always usesflow_level, while a run of one loading is its free-flow loading."free_flow"withincrements1 andwarmup0 is a single loading atflow_levelon free-flow choices).route_update (str | None) – How the route sets grow between iterations (see
openmobisim.route_update_methods()). The default depends on the run:"least_cost"when the run loads more than once (it iterates, or builds its free-flow loading in groups; orroute_update_optionsis given),"none"when it loads once."none"leaves the sets as the route method made them, at free-flow costs."least_cost", column generation, is for a run that loads more than once: after each loading, each pair’s least-cost route at that loading’s link times (the time-dependent least-cost route by each user class’s generalised cost; the fastest where the utility weighs only time) is added to the pair’s set if the set lacks it and it costs no more than the set’s best, before travellers choose again (a route is a “column” of the route-flow problem). The old name"best_response"is still accepted, with aDeprecationWarning. It closes the gap thatRun.convergence()["gap_network"]shows when traffic has made a route worthwhile that no set held. Where nothing queues it adds little or nothing. It is for congestion that is heavy but not gridlock: near gridlock it can make a run worse. The equilibrium is then over the sets the route method and the update produce, which the run’s fingerprint and manifest say."doubly_stochastic"(an option, never a default) makes the same column generation as"least_cost"and, beside it, after each loading,drawsperturbed searches per origin, departure bin and user class at the congested times, by the class’s generalised cost (asroute_method="doubly_stochastic"describes, its coefficients drawn again each iteration) with every link’s cost multiplied by1 + sigma·u,uuniform in [0, 1). The route each finds to a pair is added if it is new and its generalised cost at the middle of the departure bin is at mostmax_detourtimes the set’s best there; never to a full set. The sets then hold routes that are competitive, not only ones that were once the fastest. The old name"sampled"is still accepted, with aDeprecationWarning.route_update_options (dict[str, float] | None) – The update’s options, numbers by name: for
"least_cost",searches(1: how many searches per pair per iteration, at spread quantiles of the pair’s departures; more finds routes that pay only at some hours and makes bigger sets) andmax_routes(10: the most routes a pair’s set may hold; a full set is still searched, and a route at least a second faster than its best replaces a route nobody chose, never its free-flow shortest; if all are in use it waits) andslack(0.02: a pair is not searched while its set’s best route is within this share of free flow, since nothing is faster than free flow and so at most that much is left to gain) anduntil_iteration(0: the last iteration whose routes are added, 0 for every one; after it the sets stay as they are and the remaining loadings settle the choices among them, without the jumps a route added late causes when the few who choose again move to it). For"doubly_stochastic": those three,tree_step_s(300: the length in seconds of the departure bins its searches are shared by; it must be above 0 here), anddraws(1: perturbed searches per origin, departure bin and user class each iteration),sigma(0.5),tau(0.3),max_detour(1.5) andseed(0: another seed is another set of draws). Every value is an assumption, not a calibration. Unknown names and out-of-range values are refused.transit (openmobisim._core.Transit | None) – The timetable of a service day (
openmobisim.transit_read_gtfs), for the"transit"trips. A transit trip walks (on the walk layer, at itswalk_km_h, 4.8 km/h by default, a network option; at most 30 minutes,transit_options’access_walk_max_s) to a stop, rides one or more vehicles and walks on, boarding only if at the stop a minute before a vehicle leaves; walks between stops are at most 5 minutes. Its journey is chosen bychoice_modelamong the competitive ones: for each number of vehicles, the earliest arrival that beats every journey with fewer (the attributeswalk_min,wait_min,ride_minandtransferssay what it costs). It is chosen on the timetable, in every iteration (no traveller knows a bus’s delay in advance), and ridden on the times the run makes: the traveller boards the first vehicle of each line chosen they can catch. The run’s clock counts seconds after the service day’s midnight and starts at the window. Every vehicle keeps exactly to its timetable by default: buses are not vehicles of the loading, take no road capacity and are never delayed by traffic (the timetable is taken to hold the delays they meet). Withtransit_optionsbuses_on_roads1, buses ride the roads, 2 PCU each, among the cars: routed stop to stop at free flow, staying at a stop for the feed’s dwell there (scheduled departure less scheduled arrival) without blocking the traffic behind, never leaving a stop before their scheduled time, so congestion makes them late and their passengers with them. A bus line the roads cannot carry plausibly then runs by the schedule (Run.transit_summarycounts them). Rail, metro, trams and ferries run by the schedule. These values are defaults, not a calibration:transit_optionsoverrides them.transit_options (dict[str, float] | None) – Transit’s parameters by name, each replacing its default:
board_slack_s(60),max_rides(8),access_walk_max_s(1800),journey_max_s(7200: the longest journey with transit offered),transfer_walk_max_s(300),stop_walk_snap_m(300),stop_transfer_s(0),buses_on_roads(0: every bus keeps to its timetable; 1: buses ride the roads), and, with buses on the roads,bus_dwell_s(0: seconds added to the feed’s dwell at every stop),bus_pcu(2),bus_plausibility_ratio(1.6),bus_stop_snap_m(300). Unknown names and out-of-range values are refused.parkings (openmobisim._core.Parkings | None) – Park-and-ride car parks and bike parkings (
openmobisim.parking_read_osm,openmobisim.parking_read_table), for the"car_transit"and"bike_transit"trips; needstransit. The parking is chosen bychoice_model: a trip whose car (or bike) is at its origin drives (rides) to one of the parkings within reach, parks, walks to a stop and rides on; the alternatives are the parking × the route to it × the journey from it, andparking_minsays what parking costs. A trip whose vehicle is parked goes back by transit to where it is, fetches it and drives (rides) on. Soft capacity: a full parking refuses nobody; parking there takes longer (parking_options), the overflow is counted (Run.parking_bins()), and the choice sees how full each parking was in the iterations so far.services (list[Any] | tuple[Any, ...] | None) – Shared-mobility services: a docked bike service,
service_bike_docked(docks, options=...)(one per run for now). With"bike_share"amongmodes, a trip choosing its mode is offered shared bikes: walk to a dock, ride a shared bike on the bike layer (the bike’s routes and costs, as one’s own bike), return it at a dock and walk on. The pairs offered are of the service’scandidates(3) docks nearest the origin and the destination within itswalk_max_s(600 s) on foot, thecandidatesbest pairs; each carriesdock_min(the minutes of extra walk assumed to another dock when the pickup dock is empty or the return dock full, part ofwalk_min) andmode_bike_share, priced on what travellers assume about the docks (service_assumptions). Once the run has stopped, the service’s day is played on the fleet engine with the last loading’s trips that took a shared bike: a traveller finding an empty dock walks to another, one who finds no bike at any dock tried walks on to the destination (cancelled); what actually happened is reported, not fed back. With"bike_share_transit"amongmodesand atransittimetable, a trip is also offered a shared bike to a stop, then transit: walk to a dock, ride to a dock of a stop’s hub (a dock withinhub_join_mof a stop, or naming itshub_id), return the bike there, walk to the stop, ride, walk; the pairs are of thecandidatesdocks nearest the origin and the hubs’ docks withinparking_options’reach_bike_sby bike, as bike-and-ride picks its parkings, each withdock_minandmode_bike_share_transit; its shared bike is a leg of the same day on the fleet engine, and its transit part starts when the engine has the bike returned (or the traveller at the hub on foot). A class withhas_bike_share0 is offered neither; every other class is offered both, whatever its ownmodeslist. A taxi fleet,service_taxi(vehicles, chargers, options=...)(one per run, beside a docked bike service or alone): with"taxi"amongmodesa trip choosing its mode is offered a taxi, door to door: it requests one at its departure, waits, rides the car’s fastest route. Its alternative carrieswait_min(the assumed waiting time,service_assumptions’assumed_wait_s, whatever the fleet’s cancel limit),parking_min(the fleet’sboarding_s),car_min(the drive),fail_prob(the assumed chance of no taxi,assumed_no_taxi_share),mode_taxiandtime_min: its planned time (the three summed). With a chancepof no taxi above 0, a cancelled request is followed, after the cancel limitrequest_cancel_s, by the traveller’s best other alternative; under the random utility model that is the ride, fare in full, withrequest_cancel_s×p / (1 − p)added to itstime_minandwait_min. Once the run has stopped, the last loading’s taxi trips are played on the fleet engine (the built-in matching, the dispatch delaydispatch_delay_s, the charging rule): the vehicles drive on that loading’s link times without adding traffic, and a request no taxi can pick up withinrequest_cancel_sis cancelled and the trip ends there; what actually happened is reported, not fed back. A run offering a taxi needs a constant or a fare:beta_mode_taxi(choice_optionsor every class’s) orprice_options’taxi_eur_per_kmortaxi_eur_per_ride; it refuses to start without, since a free taxi at the door would take nearly every trip. A class withhas_taxi0 is never offered one. Without a service, nothing changes.parking_options (dict[str, float] | None) – Parking’s parameters by name, each replacing its default:
walk_max_s(300: the longest walk from a parking to a stop),reach_car_s(1800) andreach_bike_s(1200: the longest drive or ride to a parking),candidates(3: the most parkings a trip chooses among),rank_speed_km_h(30: ranks candidates before they are tried),slope_car_s(600) andslope_bike_s(180: what a parking full for a whole time bin adds to the time to leave the vehicle,mode_optionscar_egress_sandbike_egress_s; fetching it costscar_access_sorbike_access_s),snap_m(300),bin_s(900) andpr_min_km(3: the shortest trip, as the crow flies, that mode choice offers park-and-ride and bike-and-ride to). Uncalibrated defaults. For compute,reach_car_step_s(0: each park-and-ride trip searches its drive to the car parks at its own departure; above 0, the trips leaving one road node within one step of this many seconds share one search, made at the step’s middle, each trip’s drive timed at its own departure). Unknown names and out-of-range values are refused.modes (tuple[str, ...] | list[str] | None) – Mode choice. The modes a trip without a stated mode chooses among, with its route, by
choice_model: any of"walk","bike","car","transit","car_transit"and"bike_transit". Each is offered where the traveller can use it: their car or bike where the trip starts (a car left at a car park is fetched on the way back), the walk and bike layers, the timetable (transit) and the parkings (parkings); park-and-ride and bike-and-ride only for trips longer thanparking_options["pr_min_km"]. A traveller’s trips choose in order, since each may move a vehicle the next needs; a trip with a stated mode keeps it. Withchoice_model="nested_logit"the alternatives of a mode share a nest (choice_options["mu"]), andbeta_mode_<mode>is a mode’s constant (0 by default: time decides). One mode is no choice: such trips take it (("car",)is the run withoutmodes, exactly).None(the default): such trips are car trips. A walk or a ride is offered only up tomode_options’ times (30 minutes’ walk, 60 minutes’ ride), or the trip’s class’s (classes).mode_options (dict[str, float] | None) – Mode choice’s parameters by name, each replacing its default:
walk_max_s(1800) andbike_max_s(3600), the longest walk and ride offered to a trip choosing its mode (a trip given the mode takes it at any length; a class may give its own,classes);float("inf")offers every walk or ride. Uncalibrated defaults.fallback_car(0; experimental): 1 sends a trip with no alternative at all by car (a lift or a taxi for a traveller without one), counted under the car and listed byRun.fallback_car; at 0 such a trip is not simulated, and the run warns (NoAlternativeWarning) and lists it (Run.report_no_alternative()).car_access_s(120) andcar_egress_s(300): what a car trip takes before its drive (reaching the car) and after it (parking and walking from it), andbike_access_s(60) andbike_egress_s(60): the same for a bike (reaching and unlocking it; parking and locking it). Every run pays them, so every trip’s time is door to door: the choice counts them (as walk and parking time) and the loading pays them (the vehicle sets off that much after the departure, the trip ends that much after it arrives), at home and at a parking alike (a parking adds its occupancy’s time,parking_options); the results say what a time holds (trip_resultsvehicle_s,access_egress_s). A run compared with a benchmark that counts the drives alone sets them to 0. Uncalibrated, 0 switches any of them off.car_snap_motorway_m(50): a trip’s end joins the roads at the nearest street node (one with a road a car can enter from; motorways, trunk roads and their ramps are not), unless it lies within this distance of a node that has only such roads, which it then takes (through traffic placed on the motorway keeps its node; an address beside it does not start on it); uncalibrated, 0 sends every trip to a street,inftakes the nearest drivable node of any class. Unknown names and negative values are refused (the limits must be above 0).loading_options (dict[str, float] | None) – The loading’s rules by name, for
flow_level2–4 (gridlock remedies; atflow_level2, where nothing waits for room,rerouteis off unless asked for, with or without road disruptions):priority(0 or 1, off by default: without per-turn queues a vehicle giving way holds up everything behind it, which can make locks worse) — at an unsignalised merge a vehicle gives way to an approach of higher road class, or of the same class and at least 1.5 times the capacity, whose front vehicle is bound for the same link, and a departing vehicle gives way to every approach;reroute(0 or 1, on by default at levels 3 and 4) — a vehicle blocked at the downstream end of its link forreroute_after_s(300) re-routes from where it is, at mostreroute_max(3) times, if the new route is at leastreroute_min_gain(0.1) faster; atflow_level2 a vehicle waits so only behind a road closed by a disruption (or narrowed by it whennode_inflowis 1), and since a point queue has no length to spill back, a vehicle at the downstream end of its link is also offered a route, at once and once per link, when a queue ahead on its route is longer than its link and the links before it would hold: the offer reaches every junction upstream of where the queue’s back would stand, so the last one with a way round takes the traffic;pocket_length_m(50 by default; 0 turns turn pockets off) — on an approach of two lanes or more, a vehicle passes those ahead of it that wait for another movement while they fit in their turn pockets, this many metres per lane, split among the approach’s movements; on by default, because without them one queue per link locks a dense network in the full model (their known cost: an iterated run under heavy congestion misprices the waiting movements);node_inflow(0 or 1, 0 by default; the point queue only:flow_level2, and the point-queue warm-up loadings of levels 3 and 4) — at 0, the classic point queue, the next link takes every vehicle at once, a link’s outflow is bounded by its own capacity alone, and a bottleneck’s queue sits at its own downstream end; at 1 a vehicle enters the next link no sooner than that link’s inflow headway after the one before, and one held so holds up those behind it on its link, so a bottleneck’s queue forms at the downstream end of the links feeding it; either way a road closed by a disruption takes no vehicle, and those bound onto it wait at the downstream end of the road before it;origin_inflow(0 or 1, 0 by default; every level) — at 1 a departing vehicle enters its first link no faster than the link’s inflow headway allows, as from an upstream link, at 0 at any rate (departures of the same second enter together). At ``flow_level=1`` only:bpr_alpha(0.15) andbpr_beta(4), the volume-delay functiont = t0 · (1 + alpha · (v/c)^beta)of every road class (t0the link’s free-flow time,vits hourly flow,cits hourly capacity), the Bureau of Public Roads’ (1964) values that TNTP’s benchmark networks use;<class>.bpr_alphaand<class>.bpr_betaset one class’s (motorway.bpr_beta,residential.bpr_alpha…; the classes cars use), which wins over the one for every class;period_s(0: read from the departures, from the earliest rounded down to the quarter hour to the end of the quarter hour of the latest), the period in seconds the demand’s hourly flows are of. Uncalibrated defaults; unknown names and values out of range are refused.price_options (dict[str, float] | None) – What travel costs, in euros, by name:
car_eur_km(the fuel a driver pays per km),bike_eur_km, a transit journey’s farefare_base_eur(once) +fare_km_eur(per km from each boarding stop to its alighting stop as the crow flies) +fare_transfer_eur(per transfer), and the fee per stay of a car park or bike parking whose table gives none (parking_car_eur,parking_bike_eur; a parking table’sfee_eurcolumn gives each its own). Every one is 0 by default: having a car, a bike, a pass or the means to pay a fare is access, whichclassesgive, and no money is counted for it; give prices here to weigh them. A traveller whose class or person has a transit pass pays no fare (cost_fare_euris 0), whatever the fare prices. A toll is a road link value namedtoll_eur(link_values), paid at each passage. Every alternative carries what it costs:cost_eurand its partscost_running_eur,cost_toll_eur,cost_parking_eur(park-and-ride and bike-and-ride, on the trip that parks) andcost_fare_eur. With a docked bike service (services), a shared bike’s price is part of itscost_fare_eur:bike_share_eur_per_rideonce andbike_share_eur_per_minper minute ridden (0 by default; a transit pass does not cover it), and, for a shared bike to transit, the journey’s fare on top. With a taxi fleet, a taxi’s fare is itscost_fare_eur:taxi_eur_per_rideonce andtaxi_eur_per_kmper kilometre driven with the passenger (0 by default; a transit pass does not cover it; a cancelled request pays nothing, so with a chancepof no taxi the fare counts1 − ptimes). The built-in models weigh money bybeta_cost_eur(or a part’s coefficient), -1.2 per euro by default (0 drops it): a value of time ofVeuros per hour isbeta_cost_eur = beta_time_min * 60 / V, so -1.2 is 10 €/h at the default -0.2; a class’s ownbeta_cost_eur(classes) is its own value of time. Uncalibrated defaults (a city’s own, to weigh fares: a single ticket in Paris 2.55 € in 2026, https://www.iledefrance-mobilites.fr/tarifs-titre-de-transport-en-commun-2026; in Lyon 2.10 € in 2025, https://www.lebonbon.fr/lyon/news/augmentation-prix-tcl-1er-janvier-2025/; Amsterdam’s GVB 1.16 € plus 0.217 € per km in 2026, Vervoerregio Amsterdam’s note BBV/2025/15361, p. 2, https://vervoerregio.bestuurlijkeinformatie.nl/Document/View/abddeeb0-be54-4eae-9622-4ac0935df151); unknown names and values below 0 are refused. Recorded in the fingerprint and the manifest when the choice model reads money. Onengine="one-loop"only the fares:fare_base_euronce per journey and, per ride,fare_km_eurper km, or its line’s kind of service’s own price per km,fare_km_eur_rail,fare_km_eur_metro,fare_km_eur_tram,fare_km_eur_bus,fare_km_eur_ferry,fare_km_eur_other(TRANSIT_KINDS); where the kinds’ prices differ, a traveller who pays is also offered the journeys of the cheaper services, each with its exact fare, where no journey is as early, with as few vehicles and as cheap.link_values (dict[str, dict[str, Any]] | None) – The user’s own numbers per link, for choice models:
{layer: {name: values}}, the layer"road","bike"or"walk", the values either one per link of that layer in link order (an array as long asnetwork.layer("bike").link_count, aligned with its other per-link arrays) or a dict from link id (network.layer("bike").link_ids()) to value, a link not in it taking 0. Names are lower-case letters, digits and_. Each column becomes two attributes of every alternative with a leg on that layer:<layer>_<name>_km, the sum of the value times each link’s length in km (greenery along a route, divided bylength_kmfor its mean), and<layer>_<name>_sum, the plain sum (a toll, a count of crossings); 0 for an alternative with no leg there (a transit itinerary’s walks to and from stops carry none). The built-in models weigh them throughchoice_options({"beta_bike_greenery_km": 0.2}), a model of one’s own reads them from the batch. For example, the greenery around each bike link computed from OpenStreetMap, or the car flow on the road beside each bike link taken from a previous run’slink_bins(link_ids()ties a bike link to its street’s road links). Recorded in the fingerprint, and their names in the manifest.person_values (dict[str, Any] | None) – The user’s own numbers per traveller, for choice models:
{name: {traveller_id: value}}(a dict, or a pandas Series indexed by id); a traveller not in it takes 0, and an id the demand does not have is ignored (a sampled demand keeps a share of the people). Each becomes the attributeperson_<name>of every alternative of that traveller’s choices: income, age, a household’s children.trip_values (dict[str, Any] | None) – The same per trip:
{name: values}, the values one per row ofdemandin its order (a list, an array, a Series), or a dict from(traveller_id, trip_seq)to value (a trip not in it taking 0); the attributetrip_<name>: a purpose, a time budget. ``parking_eur`` is what parking a car at the trip’s destination costs, in euros: it is added tocost_parking_eurof every alternative that arrives by car (seeprice_options). Beside them every alternative carriestrip_departure_h, the trip’s departure in hours after midnight. Being the same for every alternative of a choice, such a value weighs in the built-in models in a product with another attribute, a coefficient namedbeta_<a>*<b>inchoice_optionsor a class:beta_mode_car*person_age, a car constant growing with age;beta_cost_eur*person_income_inv, money weighing less as income grows (giveincome_invas one over the income); a model of one’s own reads them from the batch. Names are lower-case letters, digits and_. Recorded in the fingerprint, and their names in the manifest.disruptions (list[dict[str, Any]] | None) – Things that happen at a time of day, a list of dicts: on roads,
{"links": [...], "capacity_factor": 0.0, "from_s": 8 * 3600, "to_s": 9 * 3600}— the links (by id,network.link_ids(), or index; each direction of a road is a link) keep that share of their capacity fromfrom_stoto_s(seconds after midnight): 0 closes them, nothing entering or leaving, 0.5 halves it; overlapping ones multiply; on lines,{"line": "T1", "delay_s": 600, "from_s": ..., "to_s": ...}or{"line": "T1", "cancel": True, ...}— the line’s runs leaving their first stop in that window are late bydelay_sat every call (a bus on the roads leaves late and drives on among the cars) or do not run. Road disruptions act through capacity, so not atflow_level0. At the point queue (flow_level2) a closure’s queue takes no road space: it delays only the vehicles in it, blocks nobody behind it and, holding them back, eases the roads beyond; with spillback (flow_level3) it backs up across the junctions behind it, as a real one does.disruptions_known (bool) – Whether travellers know of the disruptions in advance.
False(the default: an accident, a breakdown): the run reaches its equilibrium without them, then loads the day once more with them, every choice kept — only cars stuck behind a closure re-route (atflow_level3 and 4) and passengers whose run never comes plan again at the stop; that last loading is the run’s result (the convergence report stays the undisrupted one’s), so the impact is the zero-adaptation one.True(works announced, a strike): every loading has them and choices adapt over the iterations. Both are in the fingerprint and the manifest (disruptions).zones (collections.abc.Mapping[str, tuple[float, float]] | str | pathlib.Path | None) – The demand’s zones,
{zone_id: (lon, lat)}(Case.zones(),demand_read_zones) or a path to azones.csv; read atflow_level=1only, which moves every trip end to the point of the zone whose point is nearest it before it routes (demand_aggregate_space), so the trips of a zone pair share one origin-destination pair.None(the default): no move, every street node a trip starts or ends at is a zone of its own (a valid assignment, slower on a large network).Case.scenario()gives the case’s zones.preset (str | None) – Named settings for speed (
PRESETS)."fast"is what the starter cases use: the park-and-ride drives shared by origin and half hour (parking_optionsreach_car_step_s1 800), slightly approximate and faster on a city."complete"orNone(the default): the core’s defaults, every park-and-ride drive searched on its own. (The route update’s searches are shared by origin and departure bin by default,route_update_optionstree_step_s300.) An option given by name wins over the preset’s; the run’s options, not the preset’s name, are in the fingerprint.
- Returns:
A
Scenario, ready to.run().- Return type:
- replace(**changes)#
A new scenario: this one with the arguments in
changeschanged.The names are those of
from_parts; everything not named stays as it is. This scenario is not changed. For examplebase.replace(flow_level=4)orbase.replace(choice_options={"beta_time_min": -0.1})(an options dict replaces the whole dict: give every option you set).- Raises:
TypeError – If a name is not an argument of
from_parts, with the list of them.- Parameters:
changes (Any)
- Return type:
- run(run_id='run', output_dir=None, quiet=False, threads=None, overwrite=False, design_id='default', replication=0, outputs='all', hub_join_m=150.0, service_assumptions=None, policy=None, policy_options=None, config=None, engine='current', start_from=None)#
Run the scenario and write its output artifacts.
- Parameters:
run_id (str) – Recorded in every output row; also names the default output directory.
output_dir (str | None) – Where
kpis.parquetetc. are written. Defaults to./openmobisim-runs/<run_id>(the command line’s default folder), under the current directory.quiet (bool) – If true, do not print the run’s wall-clock time by stage when it ends (
Run.timings()andtimings.csvhave it either way).threads (int | None) – How many threads the run’s parallel work uses;
None(the default), every logical core. Results do not depend on it (each is the same, bit for bit, at any count), so it is recorded inmanifest.json(threads) and not in the fingerprint. The run uses a pool of its own:RAYON_NUM_THREADSdoes not change it.overwrite (bool) – Whether a folder that already holds a run (a
manifest.json) may be written into again.False(the default) refuses, so a second run with the samerun_idcannot silently replace the first one’s files.design_id (str) – The design this run belongs to, written in every row of
kpis.parquet(design_id): a study comparing designs gives each its name."default"for a single run.replication (int) – Which replication of its design this run is (
kpis.parquet’sreplication), from 0: runs of one design that differ only in theirmaster_seed. Likerun_id, both are labels, not in the fingerprint.outputs (str) – Which files the run writes in
output_dir."all"(the default):kpis.parquet,diagnostics.parquet,events.parquet,manifest.json,run.toml(the complete configuration it ran with,Run.config()),timings.csvand, as the run has them, the link bins,transit_calls.parquetandparking_bins.parquet."minimal", for mass runs (thousands of scenarios, a design space):kpis.csv(the rows ofkpis.parquet),manifest.jsonandrun.tomlonly, a few tens of kilobytes; the run’s results in memory, its fingerprint andRun.openare the same, and the files it left out are refused by name. No page or figure is ever written byrun.hub_join_m (float) – How far a parking may be from a stop, in metres in a straight line, to join the stop’s hub (
hub_idintransit_callsandparking_bins: a stop’s hub is its station, or the stop itself without one; a parking whose table names a hub is in that hub). Results do not depend on it, so it is not in the fingerprint. 150 by default, a short walk across a station’s forecourt (an assumption).service_assumptions (collections.abc.Mapping[str, float | None] | None) – What travellers assume about the scenario’s services when they choose, fixed for the whole run: a dict of values by name;
None(the default) keeps the shipped values.assumed_wait_s(600 s): the waiting time travellers assume before a taxi picks them up, whatever the fleet’s cancel limit;assumed_no_taxi_share(0): the chance of getting no taxi they assume, from 0 to 1;assumed_extra_walk_at_pickup_sandassumed_extra_walk_at_return_s: the extra walk a shared-bike user assumes if the pickup dock is empty or the return dock full, in seconds, the same at every dock and time, orNone(the default,NaNalso accepted) for the docks’ start-of-day bikes, dock by dock (an empty pickup dock costs the walk to its nearest neighbour with bikes, a full return dock the walk to its nearest with room). A misspelt name is refused with the list of names;Run.service_actual()of an earlier run is such a dict. Every value is an assumption, uncalibrated. The services are not played in the loadings: once the run has stopped, its last loading’s service trips are played in one day, and what actually happened is reported beside what was assumed (Run.service_actual(),kpis.parquet,trip_results()’sservice_outcome). Recorded in the fingerprint andmanifest.jsonof a run with a service; read only then.policy (Any) – An operator steering the scenario’s services in the run’s service day (
openmobisim.operator), asfleet_day(policy=...)takes it: a policy object (step(view)), a built-in one (policy_threshold(...)), a name (built-in or registered withpolicy_register), orNone(the default): no operator. The day is the onefleet_day(frozen=run.freeze(...), policy=...)replays: the same decisions with the same policy (a Python policy that keeps a state between steps given as a fresh object each time). Its name and parameters are in the fingerprint andmanifest.json(service_policy; a Python policy withoutdescribe()is namedpython:<its class>, and its behaviour is not in the manifest); its decisions inRun.operator_decisions(). Travellers still choose onservice_assumptions: an operator changes what the services deliver, not who asks for them. Refused without services.policy_options (collections.abc.Mapping[str, float] | None) – A named policy’s options (
{"low": 0.1}for"threshold").config (str | pathlib.Path | Any) – A run configuration file,
run.toml(its path, or aConfigfromconfig_read): its values are this run’s arguments and replace the scenario’s own of the same names, every one not in the file staying as it is. An argument given both in the file and in this call (other than at its default) is refused (one source), and so is a file whose[inputs]or[network]are not this scenario’s (a scenario runs on its own inputs).None(the default): no file is read.engine (str) – The engine the scenario runs on (
ENGINES)."current"(the default): everything this package describes."one-loop": the iterated assignment of car trips in one loop (each assignment iteration searches every trip’s cheapest route at the last loading’s link travel times and adds it to the trip’s choice set, chooses over the sets, loads, measures the link travel times and assesses the iteration), at flow level 0 (free flow) or 2 (the point queue). It reads the demand, the classes’ car ownership and coefficients, the window, the flow level and step,link_bin_s, the seed, the choice model ("deterministic","logit"or"nested_logit") and the equilibration ("free_flow": one loading;"msa": itsiterations(50 by default),step_offsetandcost_bin_s, and the loop’smin_iterations,switch_tolerance(the largest share of trips that would change chain beyond chance if everyone reconsidered at the current costs, over the last three iterations, at which the loop stops: 0.05 by default),found_tolerance(the largest share of trips for which the route search may still find a chain cheaper than their best by more than the band when the loop stops: 0.005 by default, uncalibrated; both shares count only the trips that could change their choice, the car trips and the trips choosing their mode) andindifference_band(the relative cost difference, 0.01 by default and uncalibrated, below which two chains count as equal; the deterministic choice splits the trips facing such a tie evenly over its chains, in trip order, with no random draw, and the route search counts a new chain as found only if it is cheaper than the trip’s best by more than the band),allocation(how the travellers who reconsider are chosen and spread over their chains:"draws", the default, a seeded draw per traveller and the choice model’s own choice;"choice_quota", the trips facing the same choice (the same user class, the same choice set, departing in the same cost bin) that reconsider spread over the chains in the model’s proportions, in trip order with no random draw;"quota", also who reconsiders by quota, the averaging step’s share of each such group, so no random draw enters the choice at all), andlink_times(how the route search and the pricing read the link travel times the loading measured:"fifo", the default, the exit second read on straight lines through the entry and exit seconds of the first and the last car to enter each link in each bin, which the loading then records, so that no car leaves before one that entered earlier;"bins", each link’s mean time per bin of entry time, which is not first-in-first-out where the time falls from one bin to the next, so a car entering late in a bin can leave after one entering at the next bin’s start). Every car trip pays the fixed times of reaching the car and of parking and leaving it (mode_optionscar_access_sandcar_egress_s, rounded to whole seconds): the car enters the roadscar_access_safter the departure, the trip endscar_egress_safter the car arrives (a trip ending after the window istruncated), and the choice counts them as walking and parking time (beta_walk_minandbeta_parking_min, each on top ofbeta_time_min). A trip whose mode is stated as"bike"or"walk"rides or walks its own layer (Network.layer("bike"),"walk") on the route of least cost there (a bike’s bybike_cost, a walk’s by its time), at the layer’s speeds, which no traffic changes: its route is searched once and kept, it loads nothing on the roads and never switches, so the stopping shares, the gaps and the spread leave it out (the trips’ counts and times count it). A bike trip paysmode_optionsbike_access_sandbike_egress_s(60 s each by default) around its ride, counted as walking and parking time, and needs its traveller to own a bike; the utility weighs the ride as time in a vehicle and each kilometre in mixed traffic bybeta_bike_mixed_km(−0.16 for the logit, 0 for the deterministic choice, by default), on a painted lane bybeta_bike_lane_kmand on a track or path of its own bybeta_bike_separated_km(0 by default). Mode choice (modes, and the classes’modes) among"car","bike","walk"and, with a timetable,"transit": a trip that states no mode and is offered two or more of them chooses among them through the same choice as its routes, its choice set holding its car routes (one more each iteration the search finds one) beside its bike route, its walk and its transit journeys (as a stated transit trip’s), each planned once, the ride and the walk offered when withinmode_optionswalk_max_sandbike_max_s(or its class’s: the seconds walked or ridden, the fixed times not counted); a mode its traveller has no vehicle for, no route serves or (transit) no stop in reach or no journey serves is left out, and counted. The nested logit (the default for several modes) puts each mode in a nest of scalechoice_optionsmu(0.5 by default);beta_mode_car,beta_mode_bike,beta_mode_walkandbeta_mode_transitare the modes’ constants (0 by default). A trip offered one mode takes it, at any length. The trips’ table gives each its mode (for a trip choosing its mode, that of the chain it took; none for one with no alternative,outcome"no_alternative") andmode_choice,vehicle_s(the drive or the ride) andaccess_egress_s; withlink_bin_s,link_bins_table("bike")and("walk")count bikes and walkers on their layers;convergence()gives each mode’s shares beside the totals. Transit trips: a trip whose mode is stated as"transit", with a timetable (transit), walks on the walk layer to the stops withintransit_optionsaccess_walk_max_s(1 800 s by default) of its origin, rides the timetable and walks from a stop within the same limit of its destination; its choice set holds every journey of the timetable’s Pareto set at its departure (for each number of vehicles, the earliest arrival, if earlier than with fewer vehicles), except a journey that returns to the stop it first boarded at, one longer thanjourney_max_sdoor to door, and one walking more thanwalk_total_max_s(3 600 s by default) in all, the walks between stops included. The journeys are planned once (the timetable is the same in every iteration), each run keeps to its timetable (buses_on_roads1 is refused), and the trip arrives at its journey’s arrival; the utility weighs riding as time in a vehicle, walking and waiting (the boarding slack included) bybeta_walk_minandbeta_wait_minon top ofbeta_time_min, each transfer bybeta_transfers, its fare (price_options, below) bybeta_cost_eur. The path size of a journey is over the trip’s journeys, by the share of its time on rides (a line between two stops) it shares with others. Like a stated bike trip, a transit trip never switches by anything but chance, so the stopping shares, the gaps and the spread leave it out.chains()lists each journey’s rides,transit_calls()the boardings at every call andtransit_lines()by line (transit_lines.parquet). Fares (price_options):fare_base_euronce per journey and, per ride, the price per km of its line’s kind of service (fare_km_eur_railand the otherTRANSIT_KINDS, elsefare_km_eur) times the km from its boarding stop to its alighting stop as the crow flies; 0 for a traveller whose class or person has a transit pass; every price 0 by default. Where the kinds’ prices per km differ, a traveller who pays also has, beside the timetable’s journeys, the journeys of each cheaper level of price per km on the services priced at most that much, and keeps those that no other journey beats on arrival, vehicles and fare together;chains()then has each chain’sfare_eur. Anything else the scenario asks for that it does not have (a mode other than these four, a bike route set, parkings, services, prices other than the fares, disruptions, route sets, zones, a Python choice model, …) raisesEngineNotSupportedErrornaming it; an option of"msa"that only steers how the current engine measures its gaps or stops (gap_tolerance,gap_sample,gap_every,itinerary_gap_sample,route_growth_tolerance) is not applied, with a warning, and listed inmanifest.json(options_not_applied). The run writestrip_results.parquet,convergence.parquet(one row per iteration),chains.parquet(every trip’s choice set),link_bins.parquet(withlink_bin_s),timings.csv,manifest.jsonandrun.toml.start_from (openmobisim.run.Run | None) – A run of the one-loop engine to continue from (
engine="one-loop"only): every trip starts with the choice set, the chain and the choice probabilities that run ended with (read from itschains.parquet), the link travel times its last loading measured (its current chains loaded once again), and the iteration count it reached (itsconvergence()), so the averaging goes on with the step it had reached and the iterations are numbered on. The run continued from must be of the same network and the same trips (its demand and network fingerprint,manifest.json’sdemand_network_fingerprint); its other settings may differ. Its fingerprint and iteration count are in this run’s fingerprint andmanifest.json(start_from), not inrun.toml.None(the default): every trip starts with an empty choice set at free flow.
- Returns:
the results in memory, and the output files in
output_dir.- Return type:
A
Run- Raises:
FileExistsError – If
output_diralready holds a run andoverwriteis false.EngineNotSupportedError – If
enginedoes not have something the scenario asks for.
- property parts: dict[str, Any]#
a copy.
Scenario.from_parts(**scenario.parts)builds the same scenario again (the same fingerprint);replacebuilds one with some of them changed. A demand read from a CSV file is here as the rows read.- Type:
The arguments this scenario was built from, by the names of
from_parts- Return type:
dict[str, Any]
- class openmobisim.ShortestOptions(*, max_paths=2, twin_tolerance=0.001)#
route_method="shortest":route_options.The least-cost route, and its equal-cost twin where it has one: a route that leaves it once and joins it again and costs at most
twin_tolerancemore.- Parameters:
max_paths (int)
twin_tolerance (float)
- max_paths#
count;
2.
- twin_tolerance#
—;
0.001.
- class openmobisim.SimulationOptions(*, biased=1, draws=16, max_detour=2.0, max_overlap=0.9, max_paths=10, seed=0, sigma=4.0)#
route_method="simulation":route_options.Stochastic simulation of link costs (Ramming 2002): the least-cost route under link costs drawn at random,
drawstimes, the draws biased towards the links likely to congest.- Parameters:
biased (int)
draws (int)
max_detour (float)
max_overlap (float)
max_paths (int)
seed (int)
sigma (float)
- biased#
0 or 1;
1.
- draws#
count;
16.
- max_detour#
—;
2.0.
- max_overlap#
—;
0.9.
- max_paths#
count;
10.
- seed#
count;
0.
- sigma#
—;
4.0.
- class openmobisim.SraOptions(*, cost_bin_s=300.0, eta_fell=0.2, eta_rose=1.5, gap_every=0.0, gap_sample=300, gap_tolerance=0.05, increments=None, iterations=15, itinerary_gap_sample=100000000, route_growth_tolerance=1.0, warmup=1)#
equilibration="sra":equilibration_options.- Parameters:
cost_bin_s (float)
eta_fell (float)
eta_rose (float)
gap_every (float)
gap_sample (int)
gap_tolerance (float)
increments (int | None)
iterations (int)
itinerary_gap_sample (int)
route_growth_tolerance (float)
warmup (int)
- cost_bin_s#
s;
300.0.
- eta_fell#
—;
0.2.
- eta_rose#
—;
1.5.
- gap_every#
—;
0.0.
- gap_sample#
count;
300.
- gap_tolerance#
—;
0.05.
- increments#
count; by default
None: 1 at flow_level 0 whatever is set.
- iterations#
count;
15.
- itinerary_gap_sample#
count;
100000000.
- route_growth_tolerance#
—;
1.0.
- warmup#
count;
1.
- class openmobisim.Table(path)#
A results table backed by a Parquet file.
.to_polars(),.to_pandas()and.to_arrow()read the file on demand. A later version may hand the table over without reading a file; the call shape stays the same.- Parameters:
path (str)
- to_arrow()#
Read this table with pyarrow, as a
pyarrow.Table.- Raises:
ImportError – If pyarrow is not installed — install
openmobisim[all].- Return type:
Any
- to_pandas()#
Read this table with pandas.
- Raises:
ImportError – If pandas is not installed — install
openmobisim[all].- Return type:
Any
- to_polars()#
Read this table with polars.
- Raises:
ImportError – If polars is not installed — install
openmobisim[all].- Return type:
Any
- path#
- class openmobisim.Transit#
The timetable of one service day: stops, lines and every run that day.
Read one with
transit_read_gtfs(); give it to aScenario(transit=) for its"transit"trips.- line_patterns()#
Every line’s stop patterns:
line(intolines()) andstops(stop indices).- Return type:
dict[str, Any]
- lines()#
Every line:
{"route_id", "name", "kind", "runs", "first_s", "last_s"}.- Return type:
dict[str, Any]
- read_report()#
What reading the feed found, kept and skipped (
Noneif not read from a feed).- Return type:
dict[str, int | bool] | None
- runs_by_kind()#
Runs by kind of service:
"bus","tram","metro","rail", and so on.- Return type:
dict[str, int]
- stops()#
Every stop:
stop_idandname(lists),lonandlat(arrays).- Return type:
dict[str, Any]
- call_count: int#
- date: str#
- route_count: int#
- run_count: int#
- stop_count: int#
- class openmobisim.TransitOptions(*, access_walk_max_s=1800.0, board_slack_s=60.0, bus_dwell_s=0.0, bus_pcu=2.0, bus_plausibility_ratio=1.6, bus_stop_snap_m=300.0, buses_on_roads=0, journey_max_s=7200.0, max_rides=8, stop_transfer_s=0.0, stop_walk_snap_m=300.0, transfer_walk_max_s=300.0)#
Public transport’s parameters:
transit_options.- Parameters:
access_walk_max_s (float)
board_slack_s (float)
bus_dwell_s (float)
bus_pcu (float)
bus_plausibility_ratio (float)
bus_stop_snap_m (float)
buses_on_roads (int)
journey_max_s (float)
max_rides (int)
stop_transfer_s (float)
stop_walk_snap_m (float)
transfer_walk_max_s (float)
- access_walk_max_s#
s;
1800.0.
- board_slack_s#
s;
60.0.
- bus_dwell_s#
s;
0.0.
- bus_pcu#
PCU;
2.0.
- bus_plausibility_ratio#
—;
1.6.
- bus_stop_snap_m#
m;
300.0.
- buses_on_roads#
0 or 1;
0.
- journey_max_s#
s;
7200.0.
- max_rides#
count;
8.
- stop_transfer_s#
s;
0.0.
- stop_walk_snap_m#
m;
300.0.
- transfer_walk_max_s#
s;
300.0.
- class openmobisim.Trip#
One trip: a row of the demand
Scenario.from_partstakes (trips.parquet’s columns).A plain tuple of the same nine or ten fields is the same row;
Tripnames them. Times are seconds after midnight, coordinates WGS 84 degrees;user_classnames the traveller’s class (one ofclasses, or any name for the defaults).weightis how many people the row stands for (None: the scenario’sdefault_weight);modethe stated mode (None: a car trip, or withmodesone that chooses).- departure_time_s: int#
- destination_lat: float#
- destination_lon: float#
- mode: str | None = None#
- origin_lat: float#
- origin_lon: float#
- traveller_id: str#
- trip_seq: int#
- user_class: str#
- weight: int | None = None#
- openmobisim.build_info()#
Return facts about the compiled core.
- Returns:
the 12 hex digits of the commit the build is from, or
"unknown"without a repository),code_version(int),defaults_version(int: the defaults table’s),network_format_version(int: the layout of the network and parkings cache files),rng_scheme_version(int),parallel(bool),target(str) andprofile(str). These are the fields a bug report should quote.- Return type:
A dict with keys
version(str),git_sha(str
- openmobisim.charger_read_table(source)#
Chargers from a table: one row per charger.
Columns (names in any case):
charger_id(unique),lon,lat,plugs(how many vehicles it charges at once) and, optionally,kw(its power per plug; empty: the service’scharger_kw, 50 by default) andhub_id(the hub it belongs to). Each is snapped to the road network; one farther than the service’ssnap_m, or without plugs, is left out.- Parameters:
source (str | collections.abc.Iterable[collections.abc.Mapping[str, Any]]) – A CSV/TSV file’s path or text, or rows as dicts.
- Raises:
ValueError – If a required column is missing, a value is not valid, or an id repeats.
- Return type:
openmobisim._core.Chargers
- openmobisim.choice_draw(master_seed, traveller, trip, iteration, alternative)#
Return one uniform draw in
[0, 1)from the choice stream.A pure function of its arguments: the same key always gives the same number, and changing any component changes it.
- Parameters:
master_seed (int) – The scenario’s master seed.
traveller (int) – The traveller’s id.
trip (int) – The trip’s id.
iteration (int) – The assignment iteration.
alternative (int) – The alternative’s identity.
- Returns:
A number in
[0, 1).- Return type:
float
- openmobisim.choice_model_register(name, factory)#
Make a Python choice model usable by name, like the built-in ones.
After
choice_model_register("my_model", MyModel),Scenario.from_parts(..., choice_model="my_model", choice_options={...})builds the model asfactory(choice_options)(a dict, empty when none are given) and runs it; the scenario keeps the name, soreplaceand a plain design can name it. The model is shown in the manifest by itsname(the registered name unless it has its own) and identified in the fingerprint by itsdescriptor, which should hold every option it read. A name is registered once per session: registering it again replaces the factory.- Parameters:
name (str) – Letters, digits and underscores, not a built-in model’s name.
factory (collections.abc.Callable[[dict[str, float]], Any]) – Called with the options dict; returns an object with
choose(batch).
- Raises:
ValueError – If the name is a built-in model’s or not a plain identifier.
- Return type:
None
- openmobisim.choice_models()#
The choice models that can be selected by name.
The built-in ones (
"deterministic","logit","nested_logit"), then those registered withchoice_model_register, in the order registered. Which built-in one aScenariouses unless told:"nested_logit"when it offers more than one mode,"logit"otherwise.- Return type:
list[str]
- openmobisim.config_read(path)#
Read a
run.toml: what it states, every name and value checked.Relative paths (
[inputs], a service’s tables) are resolved against the file’s folder when used. A table or a name not in the file’s layout is refused with the list of its table’s names, a value of the wrong kind with what it should be.- Raises:
FileNotFoundError – If there is no such file.
ValueError – If it is not TOML, or a name or value is not valid.
- Parameters:
path (str | pathlib.Path)
- Return type:
- openmobisim.config_write_defaults(path)#
Write the complete
run.tomlat the shipped defaults topath; return the path.Every parameter on its line, its comment giving its default, its meaning and its unit; the inputs, a service and a policy (none by default) as comments to fill in.
- Parameters:
path (str | pathlib.Path)
- Return type:
pathlib.Path
- openmobisim.demand_aggregate_space(trips, zones=None, *, grid_m=None, modes=_FORM_DEFAULT, stats=False, quiet=False)#
Trip ends moved to their zone’s or their grid cell’s point: the demand aggregated over space.
Give exactly one of
zonesandgrid_m.Zones: a trips table carries no zone, so a trip end’s zone is the zone whose point is nearest it (by the ground distance at the city’s scale; of equally near ones, the first listed); a gateway, a zone of one point, keeps its trips there. The trips of one zone pair then share their two points, and so their routes. On a demand made with one point per zone (
Case.demand(one_point_per_zone=True),demand_from_od’spoints_per_zone=1) nothing moves; a trip end drawn near the edge of its zone (aspread_m, azone_pointstable) may be nearer a neighbour’s point and go there. The static assignment (flow_level=1) applies it before it routes, with the scenario’szones, to every trip. Cost: one comparison per trip end and zone.Grid: square cells of
grid_mmetres a side, every trip end moved to the most used trip-end point of its cell (an existing origin or destination, never a new place, so that no trip is sent to a spot the network cannot serve; the first listed among equals), the cell being cell. The grid starts at the whole degree of longitude and of latitude at or below the demand’s westernmost and southernmost trip end; cell(i, j)is thei-thgrid_meastward and thej-thgrid_mnorthward, metres converted to degrees once for the whole table, at the latitude of the grid’s corner (110 574 m per degree of latitude, 111 320 m × cos(latitude) per degree of longitude, as elsewhere in the package; the corner’s latitude and not the trip ends’ mean, so that applying the grid again moves nothing). A trip end moves at most half a cell’s diagonal,0.71 × grid_m. Cost: one division per trip end.Either way the trips of one pair of cells or zones share one origin and one destination point, so a run routes them on one route set and one search tree per origin instead of one per trip; the price is the distance each end moves, which
statsmeasures. A trip whose two ends land on one point is complete at once in a run. Nothing else about a trip changes.- Parameters:
trips (Any) – In any form
Scenario.from_partstakes (rows, columns, a data frame); checked.zones (collections.abc.Mapping[str, tuple[float, float]] | str | pathlib.Path | None) –
{zone_id: (lon, lat)}(Case.zones(),demand_read_zones) or a path to azones.csv.grid_m (float | None) – The side of a grid cell, in metres, above 0.
modes (collections.abc.Iterable[str] | str | None) – The stated modes whose trips move (a mode name or several,
Trip.mode); a trip of another mode, or with no stated mode (None: a car trip, or one that chooses its mode in a run withmodes), keeps its ends.Nonemoves every trip. By default("car",)withgrid_m, the trips whose route sets a shared point saves the most, and every trip withzones, as the static assignment moves them.stats (bool) – If
True, also return a dict of what the move did (see Returns).quiet (bool) – If
False(the default), log one line: how many trip ends moved and how many were at their point already, how many trips have both ends on one point, and the number of distinct origin–destination point pairs before and after.
- Returns:
The trips as
Triprows, in the order given; withstats=True,(rows, stats). Over the trips of the modes that move:moved, the trip ends moved;kept, those at their point already;moved_m_meanandmoved_m_p95, the mean and 95th percentile of the distance a moved end moved, in metres (by the conversion above, at the mean latitude; 0 if none moved);collapsed, the trips whose two ends land on one point;pairs_beforeandpairs_after, the distinct (origin point, destination point) pairs, points compared by their exact coordinates; andoriginal, one tuple(traveller_id, trip_seq, origin_lon, origin_lat, destination_lon, destination_lat)per trip with an end moved, its ends before the move. ATriprow has no place for them and a run does not write them, so a study joinsoriginalto the run’strip_resultsby(traveller_id, trip_seq)to read where each trip really began and ended.- Raises:
ValueError – If a row is refused (as
Scenario.from_partsrefuses it), not exactly one ofzonesandgrid_mis given,grid_mis not a number of metres above 0, a mode is unknown, or a zone’s point is not (lon, lat) in degrees.- Return type:
- openmobisim.demand_aggregate_time(trips, start=None)#
Every departure set to one instant,
start: the demand aggregated in time to one bin.The static assignment (
flow_level=1) applies it before it routes, with the window’s start; the hour of flow it loads is read from the departures before they move (loading_optionsperiod_s). Nothing else about a trip changes.- Parameters:
trips (Any) – In any form
Scenario.from_partstakes; checked.start (str | float | None) – The instant, a clock time (
"07:30") or seconds after midnight;None(the default), the earliest departure rounded down to the quarter hour, the window’s start by default.
- Returns:
The trips as
Triprows, in the order given.- Raises:
ValueError – If a row is refused, or
startis not a time of day.- Return type:
list[Trip]
- openmobisim.demand_assign_classes(trips, classes, seed=0)#
Give every traveller a class, drawn by the classes’ shares.
The shares are of people (a trip’s weight,
Nonetaken as 1), scaled to sum to one, and are met to within one traveller: the travellers are put in a random order fixed byseedand their id, and the classes take consecutive runs of that order, each as many people as its share. Who falls in which class is random; how many is not. A traveller’s trips all get the same class, which replaces theuser_classthey had.The same table, classes and
seedalways give the same classes, on any machine; anotherseedis another draw, for replications.- Parameters:
trips (list[tuple]) – Rows in the schema of
Scenario.from_parts’demand.classes (collections.abc.Mapping[str, object]) – The classes, as
demand_read_classesreturns them (or a dict of the same columns), each with ashare.seed (int) – Which draw.
- Returns:
The rows, in their original order, with their
user_classreplaced.- Raises:
ValueError – If a class has no share, or the shares sum to 0.
- Return type:
list[tuple]
- openmobisim.demand_from_od(od, zones, *, start_s=7 * 3600, end_s=9 * 3600, profile='uniform', spread_m=300.0, user_class='default', seed=0, spread_m_by_zone=None, points_per_zone=None, zone_points=None)#
Turn an OD matrix into the trips a
Scenarioruns (the deterministic integerisation).Whole trips: within each group of rows with the same window, class and mode, every cell gets the whole part of its trips, and the cells with the largest remainders one more each until the group’s total (rounded to a whole number) is reached; a tie between remainders is broken by a draw keyed on the seed and the cell’s two zone points, so the result never depends on the order of the rows nor on the zones’ names.
One traveller per trip, with one trip (a chain needs a trips table): ids
od0000001… in the order of the cells, sorted by their origin’s and then their destination’s point (longitude, then latitude), so renaming the zones gives the same trips.When: a departure in the row’s window (
start_s–end_s, else the arguments’), drawn fromprofile:"uniform", or"am_peak", a bell over the window (a Beta(3, 3) distribution: two thirds of the trips in its middle 40%, against 40% for"uniform").Where: the zone’s point, moved by a random distance of up to
spread_mmetres in a random direction (uniform over the disc), so a zone’s trips do not all start at one node;spread_m_by_zonegives some zones their own (0 for a gateway: a road where the study area’s edge cuts it, where trips from outside enter). Withpoints_per_zone, a trip end is instead one of that many fixed points around the zone’s (half its spread away, evenly around it; 1: the zone’s own point), drawn at random: trips from the same zones then share their routes and their route searches. Withzone_points(demand_read_zone_points’s shape), a zone that has points draws each trip end among them by weight, the origin byweight_originand the destination byweight_destination(both uniform when a zone’s weights are all 0), so trips start where people live and end where they work; a trip within such a zone ends at a point other than its origin’s when the zone has more than one (with one point, both ends are that point). A zone without points keeps the rule above.
The draws (steps 3 and 4) come from one NumPy generator seeded by
seed, consumed in that order of the cells (a zone’s own points in the order of their coordinates), so the same inputs and seed give the same trips on any machine for one NumPy version: NumPy does not promise the same stream across its releases, so another release may give other departures and places (the whole trips of step 1 are keyed hashes and do not depend on it). Keep the returned trips, not only the seed, to repeat a study.- Parameters:
od (str | pathlib.Path | list[collections.abc.Mapping[str, Any]]) –
od.csv’s path, or its rows (demand_read_od’s shape).zones (str | pathlib.Path | collections.abc.Mapping[str, tuple[float, float]]) –
zones.csv’s path, or{zone_id: (lon, lat)}.start_s (int) – The departure window’s start for rows without one, seconds after the day’s start.
end_s (int) – Its end.
profile (str) –
"uniform"or"am_peak".spread_m (float) – How far from its zone’s point a trip may start or end, in metres.
user_class (str) – The class of rows without one.
seed (int) – Which draws.
spread_m_by_zone (collections.abc.Mapping[str, float] | None) –
{zone_id: metres}, the spread of these zones instead ofspread_m. The draws are the same either way: only their distance is scaled.points_per_zone (int | None) – Draw each trip end from this many fixed points per zone instead of anywhere in its disc (at least 1;
None: anywhere).zone_points (collections.abc.Mapping[str, list[tuple[float, float, float, float]]] | None) –
{zone_id: [(lon, lat, weight_origin, weight_destination), …]}, the places a zone’s trips start and end, drawn by weight; the other zones as above.
- Returns:
Trips rows (
traveller_id, trip_seq, origin_lon, origin_lat, destination_lon, destination_lat, departure_time_s, user_class, weight, mode), weightNone.- Raises:
ValueError – For an unknown profile, a window that is empty, a zone the matrix names but
zonesdoes not have, a negative spread, or a zone inzone_pointsthatzonesdoes not have or whose points have a negative weight.- Return type:
list[tuple]
- openmobisim.demand_read_classes(path)#
Read a class table (
classes.csv): one row per traveller class.Columns:
class(its name, as the trips’user_class); optionallyshare(the share of the people in the class, fordemand_assign_classes),modes(the modes its travellers may use, separated by;:car;bike;walk; empty: every mode the run offers),owns_car,owns_bikeandhas_transit_pass(1or0; empty: a car for a class that may drive or park and ride, a bike for one that may cycle, both when the modes are empty, and no pass — a pass only waives the fare, never gates transit),has_bike_share(0: the class is never offered a shared bike; empty: offered, in a run with a docked bike service, whatever itsmodes, which govern the ordinary modes only),has_taxi(likewise for a taxi, in a run with a taxi fleet), anybeta_*coefficient of the choice model (beta_mode_bike,beta_time_min…; empty: the model’s own) and the class’s own choice-set limits in seconds,walk_max_s,bike_max_sandaccess_walk_max_s(empty: the run’smode_optionsandtransit_options). Every value is what the user gives, not a calibration.- Returns:
The classes in the file’s order, a dict by class name of dicts with the keys
share,modes,owns_car,owns_bike,has_transit_pass,betasandlimits: the shapeScenario(classes=...)anddemand_assign_classestake.- Raises:
ValueError – If a row has no class, a class repeats, or a column or value is not one of those above.
- Parameters:
path (str | pathlib.Path)
- Return type:
dict[str, dict[str, Any]]
- openmobisim.demand_read_od(path)#
Read
od.csv: one row per (origin zone, destination zone[, window, class, mode]).Columns:
origin_zone,destination_zone,trips(people, may be fractional); optionalstart_sandend_s(the departure window, seconds after the day’s start),user_classandmode(car,bike, …; empty: chosen, or car). Returns the rows as dicts with those keys, missing onesNone.- Raises:
ValueError – If a row lacks a zone or a number of trips, or the number is negative.
- Parameters:
path (str | pathlib.Path)
- Return type:
list[dict[str, Any]]
- openmobisim.demand_read_trips(path)#
Read
trips.csv: the columns oftrips.parquet, as rowsScenariotakes.Columns:
traveller_id,trip_seq,origin_lon,origin_lat,destination_lon,destination_lat,departure_time_s,user_class, and optionallyweightandmode(empty: the default weight; no stated mode).- Raises:
ValueError – If a required column is missing in a row.
- Parameters:
path (str | pathlib.Path)
- Return type:
list[tuple]
- openmobisim.demand_read_zone_points(path)#
Read
zone_points.csv: where within each zone its trips may start and end, with weights.Columns:
zone_id,x_coord/y_coord(orlon/lat, WGS84 degrees) and the weightsweight_originandweight_destination(either may be replaced byweight, which stands for both; a missing weight is 1). A point with a residents’ weight as origin and a workplaces’ weight as destination places a zone’s trips where its buildings are, instead of around its centre. Returns{zone_id: [(lon, lat, weight_origin, weight_destination), …]}in the file’s order; seedemand_from_od’szone_points.- Raises:
ValueError – If a row has no id or no point, or a weight is negative or not a number.
- Parameters:
path (str | pathlib.Path)
- Return type:
dict[str, list[tuple[float, float, float, float]]]
- openmobisim.demand_read_zones(path)#
Read
zones.csv: each zone’s point,{zone_id: (lon, lat)}.Columns:
zone_idandx_coord/y_coord(GMNS’s names) orlon/lat, in WGS84 degrees. Other columns (aname, aboundary) are not read.- Raises:
ValueError – If a row has no id or no point, or an id repeats.
- Parameters:
path (str | pathlib.Path)
- Return type:
dict[str, tuple[float, float]]
- openmobisim.demand_sample(trips, weight, seed=0)#
Keep one traveller in every
weight, each standing forweighttimes as many people.A traveller is kept or left out with all of their trips, so a day’s chain of trips stays whole. The travellers are put in a random order fixed by
seedand their id, and everyweight-th is kept, within each group of the same user class and the same stated mode of their first trip: each group keeps its share of the demand to within one traveller, and a mode or class that is rare is not lost or doubled by chance. Every kept trip’s weight (column 9,Nonemeaning the scenario’sdefault_weight, taken as 1 here) is multiplied byweight, so totals in the results (travel time, volumes, mode shares by weight) estimate those of the whole table.A small aggregation, not a rescaled network: a kept traveller is a group of
weightpeople who travel and choose together; on the roads it is a platoon ofweightcars, each counted at its full size on every link it uses, and the network keeps its real capacities, storage and signal timings. (Sample-based agent simulations such as MATSim often scale the network’s capacities to the sample instead, a well-established approach; here nothing about the network is scaled.) What a group gives up is individuality: one choice for all its members, one platoon in the queues; under congestion its queues form and clear in blocks, so delays read a little higher than with one traveller per person.The same table,
weightandseedalways keep the same travellers, on any machine; anotherseedis another sample, for replications.- Parameters:
trips (list[tuple]) – Rows in the schema of
Scenario.from_parts’demand.weight (int) – People per kept traveller, a whole number of at least 1 (1 keeps everyone).
seed (int) – Which sample.
- Returns:
The kept rows, in their original order, with their weights multiplied.
- Raises:
ValueError – If
weightis not a whole number of at least 1.- Return type:
list[tuple]
- openmobisim.demand_write_trips(trips, path)#
Write trips rows as
trips.csv(the columns oftrips.parquet); returns the count.- Parameters:
trips (collections.abc.Iterable[tuple])
path (str | pathlib.Path)
- Return type:
int
- openmobisim.dock_read_gbfs(station_information, station_status=None)#
Docks from a bike-sharing system’s GBFS feed (General Bikeshare Feed Specification).
Every system publishes its stations in
station_information.json(id, name, place,capacity) and their state instation_status.json(bikes available now). Give the two files here, as paths, their text or their parsed JSON; versions 2 and 3 are read. A station without acapacityis left out.- Parameters:
station_information (str | pathlib.Path | collections.abc.Mapping[str, Any]) –
station_information.json.station_status (str | pathlib.Path | collections.abc.Mapping[str, Any] | None) –
station_status.json, for the bikes docked when the day starts: each station’snum_bikes_available(version 2) ornum_vehicles_available(version 3), at most its capacity. Without it, a dock starts at the service’sstart_shareof its slots. A snapshot of one moment: take one from early morning for a day’s start.
- Raises:
ValueError – If a file is not a GBFS file or a station is not valid.
- Return type:
openmobisim._core.Docks
- openmobisim.dock_read_table(source)#
Docks from a table: one row per dock.
Columns (names in any case):
dock_id— unique in the table;lon,lat— where it is (WGS84 degrees);capacity— its slots: how many bikes it holds;optional:
name;hub_id(the hub it belongs to);bikes(bikes docked when the day starts; empty: the service’sstart_shareof the slots, half by default).
Each dock is snapped to the walk and bike layers; one too far from either (the service’s
snap_m) or without slots is left out.- Parameters:
source (str | collections.abc.Iterable[collections.abc.Mapping[str, Any]]) – A CSV/TSV file’s path or text, or rows as dicts.
- Raises:
ValueError – If a required column is missing, a value is not valid, a dock holds more bikes than slots, or a
dock_idrepeats.- Return type:
openmobisim._core.Docks
- openmobisim.equilibration_strategies()#
The equilibration strategies that can be selected by name, the default first.
The default is
"free_flow".- Return type:
list[str]
- openmobisim.fixed_order_sum_f64(values)#
Sum
valueswith the core’s fixed-order reduction.- Parameters:
values (list[float]) – The numbers to add.
- Returns:
The sum, identical on every call with the same input on the same platform, whatever the thread count.
- Return type:
float
- openmobisim.fleet_day(network, services, trips=None, *, frozen=None, window=None, road_times=None, seed=None, policy=None, policy_options=None, zone_grid_m=ZONE_GRID_M)#
Run every service’s day together on the fleet engine, from a table of trips.
Or from a run’s frozen day (
frozen, a folderRun.freezewrote): the legs of the run’s service day as the run played them (its last loading’s service trips: the docks the travellers chose, the second each asks for a bike or a taxi, its ride and walk), on the road times its taxis drove on, over its window. With no policy, the day replays the run’s service day: every leg’s outcome, seconds, docks and vehicle, and the docks’ bins, bikes and taxis, are the run’s own. The services must be the run’s (the same names, docks, bikes and options) and the network too: either differing is refused, saying what differs. Each trip of the result is a leg: itstrip_idthe trip’s index in the run (Run.trip_results()’strip);FleetDay.frozenholds the day’ssetup.json.- Parameters:
network (Any) – The road network (its walk and bike layers are made from it).
services (collections.abc.Sequence[Service]) – The services (
service_bike_docked,service_taxi), names unique.trips (str | collections.abc.Iterable[collections.abc.Mapping[str, Any]] | None) – One row per trip:
origin_lon, origin_lat, destination_lon, destination_lat,departure(seconds from midnight, or"HH:MM"), and optionallytrip_id,service(a service’s name; required with more than one service) andweight(the people it stands for, 1 by default). A CSV/TSV path or text, or rows as dicts.Nonewithfrozen.frozen (str | pathlib.Path | None) – A folder
Run.freezewrote, in place oftripsandroad_times.window (tuple[object, object] | None) – The day’s start and end (seconds or
"HH:MM"); a trip asking before it opens asks at its start, one after it ends is never asked.None: 07:30 to 09:30, or a frozen day’s own (another window is refused withfrozen).road_times (RoadTimes | None) – An earlier run’s road times (
road_times_read);None: free flow.seed (int | None) – The day’s seed (a policy’s draws);
None: 0, or a frozen day’s (the run’s master seed).policy (Any) – An operator steering the services (
openmobisim.operator): a policy object (step(view)), a built-in one (policy_threshold(...)), a name (built-in or registered withpolicy_register), orNone: no operator.policy_options (collections.abc.Mapping[str, float] | None) – A named policy’s options (
{"low": 0.1}for"threshold").zone_grid_m (float) – The side of the square zones a view groups places by, in metres (
ZONE_GRID_M, 1 000: an assumption, uncalibrated).
- Raises:
ValueError – For a service, trip, option or policy that is not valid, road times of another network, or a decision naming an id that does not exist; with
frozen, for another network, other services, another window, or trips or road times given too.FileNotFoundError – For a
frozenfolder withoutsetup.json.Exception – A Python policy’s own exception, which stops the day.
- Return type:
- openmobisim.fleet_environment(network, services, trips=None, *, frozen=None, window=None, road_times=None, step_s=900.0, reward_weights=None, legs_keep=1.0, departure_jitter_s=0.0, n=1, zone_grid_m=ZONE_GRID_M)#
A fleet day to step through:
reset(seed), thenstep(decisions)until the day ends.The day is
fleet_day’s (the same services, trips, window and road times; a frozen day: the travellers’ choices and the traffic are held fixed), with no policy of its own: the caller decides at each step.reset(seed)returns(view, info)at the window’s start;step(decisions)applies the decisions (as a policy returns them:operator.Move,Target,Relocate,Charge), runsstep_sseconds and returns(view, reward, terminated, truncated, info); at the window’s endinfo["outcome"]holds the day’s tables.fork()copies the day at its clock, to simulate ahead without touching it. A view cannot be read after the next step.The reward of a step is minus
w_cancelled× the people whose request was cancelled (a taxi request no taxi could pick up within the cancel limit, which ends there; a traveller who found no bike at any dock tried),w_wait× the minutes they waited,w_walk× the extra minutes they walked (between docks: shared bikes only), andw_km× the kilometres the policy’s decisions drove (vans moving bikes, taxis relocating or driving to charge), each counted once, when its leg ends (REWARD_WEIGHTS, uncalibrated).info["refused"]holds, per decision given at the step, why the engine refused it (None: accepted).With
nabove 1 the result is aFleetVectorEnvironment:ndays stepped together, in parallel,reset(seeds)taking one seed per day andstepone list of decisions per day. Seedkgives the same day there as here.observation(view, spec)andaction(vector, spec)turn views and decisions into arrays of fixed shapes, for learning methods (specis described withobservation).With
frozen(a folderRun.freezewrote), the day is a run’s last loading: its legs as the run played them and its road times, in place of trips;frozenon the environment holds itssetup.json.legs_keepanddeparture_jitter_svary it by seed as they vary a day of trips; with neither, every seed replays the run’s day.- Parameters:
network (Any) – The road network.
services (collections.abc.Sequence[Service]) – The services (
service_bike_docked,service_taxi).trips (str | collections.abc.Iterable[collections.abc.Mapping[str, Any]] | None) – The trips, as for
fleet_day;Nonewithfrozen.frozen (str | pathlib.Path | None) – A run’s frozen day, as for
fleet_day.window (tuple[object, object] | None) – The day’s start and end;
None: 07:30 to 09:30, or a frozen day’s own.road_times (RoadTimes | None) – An earlier run’s road times, or
None: free flow (a frozen day’s own withfrozen).step_s (float) – The seconds between steps.
reward_weights (collections.abc.Mapping[str, float] | None) – Weights by name in place of
REWARD_WEIGHTS’; a name not among them is refused with the list.legs_keep (float) – The share of the trips’ legs each day keeps, drawn by the day’s seed (1: all).
zone_grid_m (float) – The side of the square zones a view groups places by, in metres (
ZONE_GRID_M, 1 000: an assumption, uncalibrated).departure_jitter_s (float) – How far each kept leg’s request moves, drawn by the day’s seed, in seconds either way (0: not at all). With these two, each seed of
resetis another day; both thin and shift the same trips, they do not draw a new demand.n (int) – How many days to step together (1: a
FleetEnvironment).
- Raises:
ValueError – As
fleet_day.- Return type:
Any
- openmobisim.network_check(network, *, layers=True)#
Check a network before running it: what would make trips fail, and what to look at.
For a network you bring (
network_read_gmns,network_read_table) or build. Each check is pass, warn (worth a look on the map, not necessarily wrong) or fail (trips will fail or a run is refused). On the road network, over the links a car may use: strongly connected, no self-loops, every length and free-flow time above 0, no link more than 1% shorter than the straight line between its ends, few very short or parallel links, each class’s median speed plausible (a unit mix-up shows here), capacity per lane and lanes per direction plausible, few dead ends. On the bike and walk layers: connected, no self-loops, lengths and times above 0, lengths against the straight line, and a plausible median speed; the bike layer’s summary says how much of it is separated or a painted lane. The thresholds are judgement calls, written next to each check (rule).- Parameters:
network (openmobisim._core.Network) – A road network.
layers (bool) – Also check its bike and walk layers.
- Returns:
one row per check (
layer,check,status,value,rule), the worst status as the verdict, and each layer’s size.- Return type:
{"verdict": "pass" | "warn" | "fail", "checks": [...], "summary": {...}}- Raises:
ValueError – If
networkis a layer, not a road network.
- openmobisim.network_edit(network, *, close=None, lanes=None, capacity_factor=None, bike_facility=None, signal_off=False)#
The same network with a scenario’s changes made, for a study to compare.
A new network is returned;
networkis left as it was. Links keep their indices, so the per-link results of a run on each (Run.link_bins) line up link by link, and a run’s fingerprint records the changes.- Parameters:
network (openmobisim._core.Network) – The road network (the handle a scenario runs on, not a layer’s).
close (collections.abc.Sequence[str | int] | None) – Road links closed to motor traffic, cars and buses, for the whole run (works, an accident lasting the day): no route uses them; buses that rode them take another way. Walking and cycling keep their own layers. Everyone knows of the closure in advance (a planned closure, an informed equilibrium).
lanes (collections.abc.Mapping[str | int, int] | None) –
{road link: lanes per direction}: capacity, jam density and storage scale with the lanes (a lane closed, or one added). At least 1; close the link instead.capacity_factor (collections.abc.Mapping[str | int, float] | None) –
{road link: factor}: capacity multiplied, storage kept (a bottleneck), the backward wave speed derived again. Above 0.bike_facility (collections.abc.Mapping[str | int, str] | None) –
{bike link: "separated" | "lane" | "mixed"}: the bike layer’s infrastructure (a cycle track or a painted lane added, or taken away). A changed link rides at that infrastructure’s speed (network_options’bike_dedicated_km_horbike_mixed_km_h), its route cost follows (bike_lane_cost_factor,bike_mixed_cost_factor), and so do the attributes choice models see (bike_separated_km…).signal_off (bool | collections.abc.Sequence[str | int]) –
Trueto ignore every traffic signal, or the road links (the approaches) whose signal is ignored. Such a link loses its signal’s control delay (its free-flow time becomes its length over its free-flow speed) and its turns get the full saturation flow, as at a junction without a signal: the network is then the one built without those signals. A link without a signal is left as it is. Meant for flow levels 0 to 2, where a signal is only that delay and that share of capacity; at levels 3 and 4 such a junction also follows the merge and priority rules of a junction without a signal.
- Return type:
openmobisim._core.Network
A link is named by its id (
network.link_ids(),network.layer("bike").link_ids()for a bike link) or by its index (an integer, Python’s or NumPy’s, as in the per-link arrays).- Returns:
The changed network.
- Raises:
ValueError – For an unknown link, 0 lanes, a factor not above 0, an unknown facility, a ferry crossing given a bike facility, or
signal_offneither a bool nor links.- Parameters:
network (openmobisim._core.Network)
close (collections.abc.Sequence[str | int] | None)
lanes (collections.abc.Mapping[str | int, int] | None)
capacity_factor (collections.abc.Mapping[str | int, float] | None)
bike_facility (collections.abc.Mapping[str | int, str] | None)
signal_off (bool | collections.abc.Sequence[str | int])
- Return type:
openmobisim._core.Network
- openmobisim.network_options(network=None)#
Every network parameter by name, at its shipped value, or at network’s.
The road-class table (
"<class>.free_flow_km_h","<class>.lanes","<class>.saturation_flow_veh_h_lane","<class>.jam_density_veh_km_lane"for every class:motorway,primary,residential, …), the global multipliers (capacity_factor, …), the signal settings (signal_cycle_s,signal_green_fraction,signal_degree_of_saturation), the most a lane of an at-grade road discharges at a signal, by its speed (street_30.saturation_flow_veh_h_lane1 000,street_50.…1 200,street_70.…1 500 veh/h per hour of green: CEREMA’s values for French signals) and the bike and walk layers (bike_mixed_km_h,walk_km_h, …). Each is an uncalibrated default; the readers’network_optionsoverride them by name.- Parameters:
network (openmobisim._core.Network | None)
- Return type:
dict[str, float]
- openmobisim.network_read_cache(path, source=None)#
Read a road network
network_write_cachewrote: the same network, bit for bit.With its street geometry, its bike and walk layers and the report of its import. Its
read_sis the time this read took.- Parameters:
path (str | os.PathLike[str]) – The file.
source (str | None) – If given, what the file must have been written with (
network_write_cache’ssource), so that a network made from other data is never taken for this one.
- Returns:
The
Network.- Raises:
ValueError – For a file that is not a network cache, is damaged, was written by another version or build of openmobisim, or from another
source.OSError – If the file cannot be read.
- Return type:
Network
- openmobisim.network_read_gmns(folder, network_options=None)#
Read a network from GMNS files.
folderis either one GMNS network (node.csv,link.csv, optionallyconfig.csv), read as the road network with its bike and walk layers derived from it, or a folder ofroad/,bike/andwalk/GMNS networks asnetwork_write_gmnswrites them, read as the road network and its own layers. See the module docs for the columns read.- Parameters:
folder (str) – The folder.
network_options (collections.abc.Mapping[str, float] | None) – Network parameters by name, as
network_read_tabletakes them.
- Returns:
A
Network, asnetwork_read_osmreturns one.- Raises:
ValueError – If the folder holds no GMNS network, a
config.csvnames units or a coordinate system that is not read, or a table is malformed.- Return type:
openmobisim._core.Network
- openmobisim.network_read_osm(path, contract=True, region=None, connectivity='strong', contract_drivable=True, layers=True, network_options=None, region_stubs=True, region_buffer_m=2000.0, bus_lanes=True)#
Read a road network from an OpenStreetMap
.osm.pbfextract.- Parameters:
path (str) – The extract.
contract (bool) – Merge chains of degree-two nodes whose links agree on every parameter (the default; turn it off only to debug an import).
region (tuple[float, float, float, float] | list[tuple[float, float]] | None) – Cut a study area out of the extract: a rectangle
(west, south, east, north)in degrees, or a polygon as a list of(lon, lat)vertices. Nodes outside are dropped and a road that crosses the edge ends at its last node inside; a road that leaves and re-enters is two roads, never one bridged across the gap.connectivity (str) –
"strong"(the default) keeps only the largest strongly connected part of the drivable network, so that every node a car can use reaches every other: an extract is cut out of a larger network, and without this some trips have no route at all. Whole links are removed and none is changed; footways and other links a car may not use are untouched. What was removed is counted inNetwork.report_import()and drawn fromNetwork.report_dropped()."keep"imports every road.contract_drivable (bool) – Merge car links across nodes that only footways, cycleways or pedestrian streets touch. A footway crossing a street shares a node with it, and so does every sidewalk that meets a driveway; without this (
False) such a node is a junction and splits the street, which in a city that maps its sidewalks cuts a third of the car network into pieces a few metres long. With it (the default) they merge (by the usual rule: same class, lanes and speed, no signal, stop or barrier, nothing a car could turn into), the node stays for the footway and the footway links are unchanged. Only acts withcontract.layers (bool) – Also read the bike and walk layers from the same ways (the default):
network.layer("bike"),network.layer("walk").network_options (dict[str, float] | None) – Network parameters by name, overriding their shipped values (the road-class table, the multipliers, the signal settings, the bike and walk layers’ speeds;
openmobisim.network_options()lists them). An unknown name is refused with the list.region_stubs (bool) – With a
region: keep each road’s first node outside, so the segment that crosses the edge stays. On by default.region_buffer_m (float) – With a
region: keep motorways, trunk roads and their slip roads within this many metres of it, so a ring road just outside the area (Amsterdam’s A10, Paris’ Périphérique) and the main approaches stay; nothing else outside is kept. 2 000 m by default (uncalibrated); 0 keeps none.bus_lanes (bool) – Read the lanes reserved for buses (on by default):
busway,busway:both|left|right(lane,opposite_lane),lanes:bus,lanes:psv(counts),bus:lanes,psv:lanes(designatedlanes), and their:forwardand:backwardforms; where several describe a direction, the largest count is taken. A lane also designated for carpools (hov:lanes,lanes:hov,hov=designated) is not a bus lane: cars keep it, as the model does not tell a car’s occupancy. OpenStreetMap’slanescounts bus lanes with the others, so a car link’s bus lanes are taken out of the lanes cars use, never below one (where nolanesis tagged, out of the class’s default), and kept on the link (Network.link_bus_lanes()); with buses on the roads (transit_optionsbuses_on_roads1), a bus there rides at free flow, outside the cars’ queue. A contraflow bus lane on a one-way street, or a one-way street buses may ride both ways (oneway:busoroneway:psvno), is a busway link against it, for buses alone. On the bike layer a bus lane bikes share (cycleway=share_busway,opposite_share_busway) is a bike lane.False: none of these, and every lanelanescounts is the cars’. Right-hand traffic is assumed for the sides.
- Returns:
A
Networkwith the defaults table’s parameters and the street geometry kept for maps.- Raises:
ValueError – If the file cannot be read,
regionorconnectivityis not valid, or the result holds no usable road network.- Return type:
Network
- openmobisim.network_read_table(links, nodes=None, *, length_unit='m', speed_unit='km_h', time_unit='min', coordinates='lonlat', coordinate_scale_m=1.0, layout_spacing_m=200.0, network_options=None)#
Read a road network from a plain table of links.
- Parameters:
links (str | Rows) – A path to a delimited text file (CSV, TSV, or a TNTP-style
~-headed,;-terminated one — the dialect is detected), or an in-memory sequence of row mappings, column name to value (for exampledf.to_dict("records")). Recognised columns, by canonical name (aliases in parentheses; matching is case-insensitive):from(init_node,from_node),to(term_node,to_node) — required;id(auto-numbered if absent);length(length_m,dist);lanes(the lanes cars use);bus_lanes: lanes reserved for buses besides them, on which a bus on the roads rides at free flow outside the cars’ queue (absent: none);free_flow_speed(free_flow_speed_km_h; notspeed) orfree_flow_time(fftt) — at most one is read,free_flow_speedfirst;capacity(cap);class(type,link_type,highway) — a name fromopenmobisim.LINK_CLASSES("primary","residential", …; TNTP’s numericlink_typeis not one, so it is treated as unrecognised, like an unfamiliar OSM tag, with a diagnostic — pass aclasscolumn of your own if you have the mapping);roundabout;signalised(signal): a signal at the link’s end that stops it alone (a stop line for one direction; a signalised node stops every approach). A column not given, for a row that does not state it, defaults from the class table exactly as an unstated OSM tag does, with the same diagnostics for what was filled in — a two-way street is two rows, each is one directed link, and every trip’s demand is already routed on the network this way.nodes (str | Rows | None) – A node table in the same two shapes, or
Noneif links carries no coordinates at all — then nodes are laid out on a deterministic grid (layout_spacing_m apart, in the order they are first named by a link) purely so a figure has something to draw; the layout carries no meaning and is never read by the loading. Recognised columns:id(node) — required;x/yorlon/latdepending on coordinates;signalised(signal) — every approach to a signalised node gets a control delay and a green-time fraction;signal_location— a signal stands at the node but stops only the links whose ownsignalisedsays so (a stop line’s).length_unit (str) – The unit of a links
lengthcolumn:"m"(the default),"km"or"mi".speed_unit (str) – The unit of a links
free_flow_speedcolumn:"km_h"(the default) or"mi_h".time_unit (str) – The unit of a links
free_flow_timecolumn (read only whenfree_flow_speedis absent, and converted to a speed usinglength— so a links row with a time but no length has no free-flow speed and gets the class default instead, with a diagnostic the same way a degenerate length does):"s","min"(the default — the convention of the standard TNTP benchmark networks) or"h".coordinates (str) – What a nodes table’s position columns are:
"lonlat"(the default — real-worldlon/latdegrees, read and projected exactly as an OSM import’s are) or"xy"(an arbitrary local coordinate system, as the standard TNTP benchmark networks use for their node files — placed on a flat, representative-of-nowhere-in-particular layout, the same construction examples.manhattan_grid uses for its own grid, so it can be drawn but carries no real-world meaning).coordinate_scale_m (float) – Metres per unit of a nodes table’s
x/y, undercoordinates="xy". The default,1.0, assumes the table’s units already are metres; the standard TNTP node files do not document their unit, so check a network’s own extent (a printed figure, or report_connectivity’s counts) before trusting it for anything but a schematic plot.layout_spacing_m (float) – Grid spacing for the coordinate-free fallback layout (nodes is
Noneand links carries no coordinates).network_options (collections.abc.Mapping[str, float] | None) – Network parameters by name, overriding their shipped values: the road-class table (
"residential.free_flow_km_h",".lanes",".saturation_flow_veh_h_lane",".jam_density_veh_km_lane"), the multipliers, the signal settings and the bike and walk layers’ speeds.network_options()lists every name and value; an unknown name is refused with the list.
- Returns:
A
Network, exactly asnetwork_read_osmorexamples.manhattan_gridreturn one — usable by aScenario, report_connectivity, and everyopenmobisim.vizfigure.- Raises:
FileNotFoundError – If links or nodes is a string without a line break (a path) and no such file exists.
ValueError – If links has no usable rows, a row’s
from/tois missing, length_unit/speed_unit/time_unit/coordinates is not one of the values above, or the resulting network holds no usable links (the same failuresnetwork_read_osmcan raise).
- Return type:
openmobisim._core.Network
Example
Sioux Falls, from its published TNTP files (
sioux_falls_net.tntp, tab-separated, lengths in miles, times in minutes; a node file with arbitraryx/y):net = network_read_table( "data/sioux_falls_net.tntp", "data/sioux_falls_node.tntp", length_unit="mi", coordinates="xy", )
- openmobisim.network_write_cache(network, path, source='')#
Write a road network to a cache file, read back by
network_read_cache.The file holds the network as built, with its street geometry, its bike and walk layers and the report of its import, and
network_read_cache()reads it back as the same network, bit for bit (the same fingerprint, the same results), in a fraction of an import’s time. A starter case’s network is cached this way by itself (Case.network()).The file is valid for this build of openmobisim only: another version, or another build of this one, refuses it, and the network is then imported again. It is a cache, not a way to keep or share a network: keep its source files. It is written beside its final name and then renamed, so a reader never sees half of it.
- Parameters:
network (Network) – The road network’s handle (not a layer’s: the road network holds its layers).
path (str | os.PathLike[str]) – The file to write.
source (str) – What the network was made from (a checksum of its files and reading options, say), kept in the file for
network_read_cache()to compare.
- Raises:
ValueError – For a bike or walk layer’s handle.
OSError – If the file cannot be written.
- Return type:
None
- openmobisim.network_write_gmns(network, folder, *, layers=True, geometry=True)#
Write
networkas GMNS files:road/, andbike/andwalk/withlayers.See the module docs for the columns. Every file is plain CSV; the street geometry (
geometry, WKT) makes the files larger and lets GIS tools draw them, and is not needed to read the network back.- Parameters:
network (openmobisim._core.Network) – The road network (a handle from
network_read_osm,network_read_table,network_read_gmnsorexamples).folder (str) – Where to write; made if missing.
layers (bool) – Also write the bike and walk layers.
geometry (bool) – Write each link’s polyline.
- Returns:
Links written per layer.
- Return type:
dict[str, int]
- openmobisim.notebooks(folder=FOLDER, *, overwrite=False)#
Copy the tutorial notebooks into
folderand say where the first one is.Ten notebooks,
00_getting_started.ipynbto09_applications.ipynb, without their outputs (run them to see them; the repository has them run). A notebook already infolderis kept, with your changes, unlessoverwrite. Open the first in JupyterLab (jupyter labin that folder, oropenmobisim notebooksin a terminal does it) or in your editor.- Parameters:
folder (str | pathlib.Path) – Where to put them,
openmobisim-notebooksin the current folder by default.overwrite (bool) – Replace notebooks already there.
- Returns:
The folder.
- Raises:
FileNotFoundError – If this build carries no notebooks (one built from the repository between releases); they are in the repository,
NOTEBOOKS_URL.- Return type:
pathlib.Path
- openmobisim.parameters()#
Every parameter openmobisim assumes, at the defaults a
Scenariouses.Columns by name, one row per parameter:
group(network,loading,modes,transit,parking,prices,scenario,equilibration.<strategy>,route_method.<method>,route_update.<update>,choice_model.<model>,bike_route.doubly_stochastic,service.bike_dockedandservice.taxi(a service’soptions),service_prices(price_options),service_assumptionsandpolicy.<policy>(Scenario.run’s),fleet_environmentandfleet),argument(what overrides it by name:network_optionsof a network reader,loading_options,equilibration_options… ofScenario.from_parts,optionsofservice_bike_dockedorservice_taxi,policy_options,reward_weightsoffleet_environment, or the argument itself for thescenariogroup),name,value,unit(read from the name, which carries it),note(where a default is a rule of the run’s level),meaning(what the parameter does, in a few sentences) andsource(where its default comes from, with a reference where there is one; “uncalibrated” where none is known). Every value is an uncalibrated default.- Returns:
The table, as
Columns(a dict of lists by column, withto_pandas()…).- Return type:
openmobisim.table.Columns
- openmobisim.parking_read_cache(path, source=None)#
Read parkings
parking_write_cachewrote: the same parkings, bit for bit.With the report of the read that found them. Their
read_sis the time this read took.- Parameters:
path (str | os.PathLike[str]) – The file.
source (str | None) – If given, what the file must have been written with (
parking_write_cache’ssource), so that parkings made from other data are never taken for these.
- Returns:
The
Parkings.- Raises:
ValueError – For a file that is not a parkings cache, is damaged, was written by another version or build of openmobisim, or from another
source.OSError – If the file cannot be read.
- Return type:
- openmobisim.parking_read_osm(path, region=None, merge_m=100.0, capacity_car=100, capacity_bike=10, area_per_car_m2=25.0, area_per_bike_m2=1.5)#
Park-and-ride car parks and bike parkings from an OpenStreetMap extract.
A car park is kept if it is a park-and-ride (
park_rideother thanno, or a name that says so); every bike parking is kept; private ones are not. A capacity comes from thecapacitytag, else from the area (area_per_*), else the default for a point (capacity_*). Parkings of one vehicle closer thanmerge_mare merged into one site. These values are defaults, not a calibration.- Raises:
ValueError – If the file cannot be read or the region is not valid.
- Parameters:
path (str)
region (tuple[float, float, float, float] | list[tuple[float, float]] | None)
merge_m (float)
capacity_car (int)
capacity_bike (int)
area_per_car_m2 (float)
area_per_bike_m2 (float)
- Return type:
- openmobisim.parking_read_table(source)#
Parkings from a table: one row per parking.
Columns (names in any case):
parking_id— unique in the table;lon,lat— where it is (WGS84 degrees);vehicle—"car"or"bike";capacity— how many vehicles it holds;optional:
name;hub_id(rows sharing one join one hub, such as a station’s car park and its bike parking; else each parking is its own hub);initial_occupancy(vehicles parked when the day starts; 0);fee_eur(what a stay costs, in euros, seen by choice models ascost_parking_eur; empty: the scenario’sprice_optionsparking_car_eurorparking_bike_eur).
A run snaps each parking to its vehicle’s layer and to the walk layer, and keeps it only if a stop is within walking distance (see
Scenario’sparking_options).- Parameters:
source (str | collections.abc.Iterable[collections.abc.Mapping[str, Any]]) – A CSV/TSV file’s path or text, or rows as dicts.
- Raises:
FileNotFoundError – If source is a string without a line break (a path) and no such file exists.
ValueError – If a required column is missing, a value is not valid, or a
parking_idrepeats.
- Return type:
openmobisim._core.Parkings
- openmobisim.parking_write_cache(parkings, path, source='')#
Write parkings to a cache file, read back by
parking_read_cache.The file holds the parkings as read, with the report of the read that found them, and
parking_read_cache()reads them back as the same parkings, bit for bit (the same fingerprint, the same results), in a fraction of the time reading them from an extract takes. A starter case’s parkings are cached this way by themselves (Case.parkings()).The file is valid for this build of openmobisim only: another version, or another build of this one, refuses it, and the parkings are then read again. It is a cache, not a way to keep or share parkings: keep their source (an extract, a table). It is written beside its final name and then renamed, so a reader never sees half of it.
- Parameters:
parkings (Parkings) – The parkings.
path (str | os.PathLike[str]) – The file to write.
source (str) – What the parkings were made from (a checksum of the extract and the reading options, say), kept in the file for
parking_read_cache()to compare.
- Raises:
OSError – If the file cannot be written.
- Return type:
None
- openmobisim.policy_register(name, factory)#
Make a policy usable by name, like the built-in ones.
After
policy_register("my_rule", MyRule),fleet_day(..., policy="my_rule", policy_options={...})builds the policy asfactory(policy_options)(a dict, empty when none are given). A name is registered once per session: registering it again replaces the factory.- Parameters:
name (str) – Letters, digits and underscores, not a built-in policy’s name.
factory (collections.abc.Callable[[dict[str, float]], Any]) – Called with the options dict; returns a policy (an object with
step(view), or a built-in one).
- Raises:
ValueError – If the name is a built-in policy’s or not a plain identifier, or the factory is not callable.
- Return type:
None
- openmobisim.road_times_read(link_bins)#
The road times of an earlier run, from its
link_bins.parquet.Each link’s mean time in each bin is
pcu_seconds / pcu; a link or bin without a row is taken at free flow. The run’s network must be the network the fleet day is given (its fingerprint is checked). These times are by the bin a vehicle left the link, which the fleet day reads as the bin it enters: an approximation.- Parameters:
link_bins (str | Any) – The path of a run’s
link_bins.parquet.- Raises:
ImportError – Without pyarrow — install
openmobisim[all].- Return type:
RoadTimes
- openmobisim.route_cache_clear()#
Forget every route set the cache holds (the counters of
route_cache_info()stay).- Return type:
None
- openmobisim.route_cache_info()#
What the route-set cache has done:
(hits, misses, sets held).- Return type:
tuple[int, int, int]
- openmobisim.route_methods()#
The route-set methods that can be selected, the default (
"penalty") first.- Return type:
list[str]
- openmobisim.route_sets_build(network, od_lonlat, method='penalty', options=None)#
Make route sets for origin-destination pairs given as coordinates.
- Parameters:
network (Network) – The network to route on.
od_lonlat (list[tuple[float, float, float, float]]) – Pairs
(origin_lon, origin_lat, destination_lon, destination_lat). Each end is snapped to the nearest drivable node; pairs that snap to one node are dropped.method (str) – A name from
route_methods().options (dict[str, float] | None) – The method’s options, numbers by name. For
"penalty":max_paths(5),max_detour(1.3),max_overlap(0.75),penalty(1.5),max_attempts(15). For"montecarlo":draws(16),sigma(4),max_detour(2),max_overlap(0.9),max_paths(10),seed(0) andbiased(1; 0 for none). The method’s noise is biased towards the links the demand is likely to congest; here the demand is the given pairs, one traveller each, leaving at once.
- Returns:
The sets, one per distinct pair, best route first.
- Raises:
ValueError – For an unknown method, an unknown option or an out-of-range value.
- Return type:
RouteSets
- openmobisim.route_update_methods()#
The route updates that can be selected by name, the default (
"none") first.- Return type:
list[str]
- openmobisim.service_bike_docked(docks, *, name='bike_share', options=None)#
A docked bike-sharing service: bikes counted per dock.
- Parameters:
docks (Any) – Its docks (
dock_read_tableordock_read_gbfs).name (str) – Its name, unique among a day’s services.
options (collections.abc.Mapping[str, float] | None) – Its options by name (
walk_max_s,redirect_max,redirect_max_m,pickup_s,return_s,ride_factor,start_share,fail_s,bin_s,handling_s,van_bikes,candidates,snap_m, andlog_events: 1 to keep the day’s log of events, the default, 0 not to, for a very large run, whose results are otherwise the same); a name not among them is refused with the list. A fleet day does not readcandidatesorfail_s.
- Return type:
- openmobisim.service_taxi(vehicles, chargers=None, *, name='taxi', options=None)#
An electric taxi fleet: vehicles tracked one by one, with a battery.
- Parameters:
vehicles (Any) – Its vehicles (
vehicle_read_table).chargers (Any) – Its chargers (
charger_read_table), orNone: its vehicles never charge.name (str) – Its name, unique among a day’s services.
options (collections.abc.Mapping[str, float] | None) – Its options by name (
battery_kwh,kwh_per_km,soc_start,reserve_soc,charge_below,charge_to,charger_kw,request_cancel_s,boarding_s,dispatch_delay_s,snap_m,charger_reach_s, andlog_events: 1 by default, 0 to keep no event log in a very large run,taxi_events.parquetthen empty); a name not among them is refused with the list.request_cancel_s(600 s, an assumption): a request is cancelled if no taxi can pick it up within this time.dispatch_delay_s(120 s, an assumption): the time from a request being matched to the taxi setting off (the app’s dispatch and the driver’s acceptance), so the waiting time counts it, and a taxi is matched to a request only if the dispatch delay and its drive fit withinrequest_cancel_s; adispatch_delay_sat or aboverequest_cancel_sis refused.boarding_s(60 s, an assumption): the time to get in at the pickup.
- Return type:
- openmobisim.step_of(origin_second, step_seconds, window_seconds, second)#
Return the loading step containing
second.- Parameters:
origin_second (int) – The scenario origin, in seconds.
step_seconds (int) – The loading step length, in seconds.
window_seconds (int) – The window length; must be a whole number of steps.
second (int) – The instant to locate, in seconds from the same origin.
- Returns:
The zero-based step index, clamped to the window.
- Raises:
ValueError – If the grid is not valid — a zero step, a window that is not a whole number of steps, or one running past the end of the 32-bit clock.
- Return type:
int
- openmobisim.transit_edit(transit, *, cancel=None, headway=None)#
The same service day with a scenario’s changes made.
- Parameters:
transit (openmobisim._core.Transit) – The timetable (
transit_read_gtfs).cancel (collections.abc.Sequence[str] | None) – Lines that do not run that day (a whole line out of service). Everyone knows in advance: passengers plan without them.
headway (collections.abc.Mapping[str, float | collections.abc.Sequence[float]] | None) –
{line: seconds}to run a line every so many seconds through its day (from its first departure to its last,lines()’first_sandlast_s), or{line: (seconds, from_s, to_s)}(a tuple or a list) within a window of seconds after midnight ((300, 7 * 3600, 9 * 3600): every 5 minutes from 07:00 to 09:00). Within the window, each of the line’s stop patterns (its runs calling at the same stops, each direction one) runs everysecondsfrom its first departure there, at the times of its middle run there; a pattern with no run in the window gets none, so a line is made more or less frequent, not new. A new run is named<template run>@<seconds after midnight>.
- Return type:
openmobisim._core.Transit
A line is named by its GTFS
route_idor by its name (route_short_name) where that is unique;transit.lines()lists both. Without crowding or vehicle capacities (not yet modelled), a headway changes the waits and transfers passengers plan on, and how many buses ride the roads.- Returns:
The changed timetable.
- Raises:
ValueError – For an unknown or ambiguous line, a headway not above 0, or a window that ends before it starts.
- Parameters:
transit (openmobisim._core.Transit)
cancel (collections.abc.Sequence[str] | None)
headway (collections.abc.Mapping[str, float | collections.abc.Sequence[float]] | None)
- Return type:
openmobisim._core.Transit
- openmobisim.transit_read_gtfs(path, network=None, date=None)#
Read one service day of a GTFS feed.
- Parameters:
path (str) – The feed: a
.zip, or a folder of its.txtfiles.network (Network | None) – If given, only the stops a pedestrian can reach on the network’s walk layer are kept (within 300 m of its nearest node), and every run keeps its calls at them.
date (str | None) – The service day,
"YYYY-MM-DD";Nonereads the feed’s busiest weekday.
- Raises:
ValueError – If the feed cannot be read, lacks a required file, or runs nothing on the day.
- Return type:
- openmobisim.vehicle_read_table(source)#
An electric fleet’s vehicles from a table: one row per vehicle.
Columns (names in any case):
vehicle_id(unique),lon,lat(where it is when the day starts, WGS84 degrees) and, optionally,soc(its charge then, a share from 0 to 1; empty: the service’ssoc_start, 0.8 by default). Each is snapped to the road network; one farther than the service’ssnap_mis left out.- Parameters:
source (str | collections.abc.Iterable[collections.abc.Mapping[str, Any]]) – A CSV/TSV file’s path or text, or rows as dicts.
- Raises:
ValueError – If a required column is missing, a value is not valid, or an id repeats.
- Return type:
openmobisim._core.Vehicles
- openmobisim.ENGINES = ('current', 'one-loop')#
- openmobisim.LINK_CLASSES: tuple[str, ...]#
- openmobisim.MODES = ('car', 'bike', 'walk', 'transit', 'car_transit', 'bike_transit')#
- openmobisim.PRESETS: dict[str, dict[str, dict[str, float]]]#
- openmobisim.SERVICE_MODES = ('bike_share', 'bike_share_transit', 'taxi')#