openmobisim =========== .. py:module:: openmobisim .. autoapi-nested-parse:: 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 ---------- .. toctree:: :maxdepth: 1 /reference/api/openmobisim/choice/index /reference/api/openmobisim/config/index /reference/api/openmobisim/contrib/index /reference/api/openmobisim/examples/index /reference/api/openmobisim/fleet/index /reference/api/openmobisim/operator/index /reference/api/openmobisim/services/index /reference/api/openmobisim/viz/index Attributes ---------- .. autoapisummary:: openmobisim.ENGINES openmobisim.LINK_CLASSES openmobisim.MODES openmobisim.PRESETS openmobisim.SERVICE_MODES Exceptions ---------- .. autoapisummary:: openmobisim.EngineNotSupportedError openmobisim.FallbackWarning openmobisim.NoAlternativeWarning openmobisim.WindowWarning Classes ------- .. autoapisummary:: openmobisim.BestResponseOptions openmobisim.Columns openmobisim.Config openmobisim.FleetDay openmobisim.FrankWolfeOptions openmobisim.FreeFlowOptions openmobisim.LeastCostOptions openmobisim.LinkClassOptions openmobisim.LinkPenaltyOptions openmobisim.LoadingOptions openmobisim.LogitOptions openmobisim.ModeOptions openmobisim.MonteCarloOptions openmobisim.MsaOptions openmobisim.NestedLogitOptions openmobisim.NetworkOptions openmobisim.ParkingOptions openmobisim.Parkings openmobisim.PenaltyOptions openmobisim.PriceOptions openmobisim.Run openmobisim.Scenario openmobisim.ShortestOptions openmobisim.SimulationOptions openmobisim.SraOptions openmobisim.Table openmobisim.Transit openmobisim.TransitOptions openmobisim.Trip Functions --------- .. autoapisummary:: openmobisim.build_info openmobisim.charger_read_table openmobisim.choice_draw openmobisim.choice_model_register openmobisim.choice_models openmobisim.config_read openmobisim.config_write_defaults openmobisim.demand_aggregate_space openmobisim.demand_aggregate_time openmobisim.demand_assign_classes openmobisim.demand_from_od openmobisim.demand_read_classes openmobisim.demand_read_od openmobisim.demand_read_trips openmobisim.demand_read_zone_points openmobisim.demand_read_zones openmobisim.demand_sample openmobisim.demand_write_trips openmobisim.dock_read_gbfs openmobisim.dock_read_table openmobisim.equilibration_strategies openmobisim.fixed_order_sum_f64 openmobisim.fleet_day openmobisim.fleet_environment openmobisim.network_check openmobisim.network_edit openmobisim.network_options openmobisim.network_read_cache openmobisim.network_read_gmns openmobisim.network_read_osm openmobisim.network_read_table openmobisim.network_write_cache openmobisim.network_write_gmns openmobisim.notebooks openmobisim.parameters openmobisim.parking_read_cache openmobisim.parking_read_osm openmobisim.parking_read_table openmobisim.parking_write_cache openmobisim.policy_register openmobisim.road_times_read openmobisim.route_cache_clear openmobisim.route_cache_info openmobisim.route_methods openmobisim.route_sets_build openmobisim.route_update_methods openmobisim.service_bike_docked openmobisim.service_taxi openmobisim.step_of openmobisim.transit_edit openmobisim.transit_read_gtfs openmobisim.vehicle_read_table Package Contents ---------------- .. py:exception:: 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. .. py:exception:: 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_car`` lists them. .. py:exception:: 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. .. py:exception:: WindowWarning Trips of the demand departed outside the simulation window and were left out. They are not simulated and not counted in any result. .. py:class:: BestResponseOptions(**options) The old name of ``LeastCostOptions``, still accepted with a ``DeprecationWarning``. .. py:class:: Columns A table held as columns: a ``dict`` from 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 with ``to_pandas()``, ``to_polars()`` or ``to_arrow()``. Each column is a list or a NumPy array, all of one length. .. py:method:: to_arrow() The columns as a ``pyarrow.Table``. :raises ImportError: If pyarrow is not installed — install ``openmobisim[all]``. .. py:method:: to_pandas() The columns as a ``pandas.DataFrame``. :raises ImportError: If pandas is not installed — install ``openmobisim[all]``. .. py:method:: to_polars() The columns as a ``polars.DataFrame``. :raises ImportError: If polars is not installed — install ``openmobisim[all]``. .. py:property:: row_count :type: int How many rows the columns hold (0 without columns). .. py:class:: Config A run's parameters, as a ``run.toml`` states them (``config_read``) or a run was given. ``values`` holds what is stated, by table (``values["choice"]["beta_time_min"]``; a service's under ``values["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 a ``Scenario`` and ``run()`` runs it. .. py:method:: 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. .. py:method:: from_arguments(run_id = None, **arguments) :classmethod: The configuration of a run with these arguments, to write as a file. The keyword arguments of ``Scenario.from_parts`` and ``Scenario.run`` that are parameters (numbers, names, lists of modes, options dicts, services, a policy by name or a built-in one), and ``network_options``; ``run_id`` is the file's ``name``. What a file cannot hold (link values, disruptions, a Python choice model or policy) is listed in ``absent`` and the file's header. :raises TypeError: For an argument that is not one of these, with the list of them. .. py:method:: inputs() The ``[inputs]`` table's paths, resolved against the file's folder (dates as given). .. py:method:: run(output_dir = None, *, overwrite = False, quiet = False) Run the file: ``scenario()``, then ``Scenario.run(config=self)``. .. py:method:: scenario() A ``Scenario`` of the file's ``[inputs]`` (read by the package's readers) and values. ``network`` is read by its kind: a starter case's folder (its ``case.json``), a GMNS folder, an OpenStreetMap ``.osm.pbf`` (both with the file's ``[network]``) or a file ``network_write_cache`` wrote; ``demand`` (required), ``persons`` and ``zones`` are given to ``Scenario.from_parts`` as paths; ``classes`` by ``demand_read_classes``; ``transit`` by ``transit_read_gtfs`` (on ``transit_date``); ``parkings`` by ``parking_read_table`` (a ``.csv``), ``parking_read_osm`` (a ``.pbf``) or ``parking_read_cache``; a service's tables by ``dock_read_table``, ``vehicle_read_table`` and ``charger_read_table``. :raises ValueError: If ``network`` or ``demand`` is missing, or a value is not valid. .. py:method:: text() The complete file: every parameter, stated or at its default, with its comment. .. py:method:: write(path) Write the complete file to ``path`` and return the path. .. py:attribute:: absent :type: list[str] :value: [] .. py:attribute:: folder :type: pathlib.Path | None :value: None .. py:attribute:: name :type: str | None :value: None .. py:attribute:: resolved :type: dict[str, Any] .. py:attribute:: values :type: dict[str, Any] .. py:class:: FleetDay What one fleet day did (``fleet_day``). .. py:method:: 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``; ``None`` or NaN where a kind has none), ``accepted``, ``reason`` (why it was refused, ``None`` if 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). .. py:method:: 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``. .. py:attribute:: counts :type: dict[str, float] .. py:attribute:: decision_rows :type: openmobisim.table.Columns .. py:attribute:: dock_bins :type: dict[str, openmobisim.table.Columns] .. py:attribute:: fidelity :type: str .. py:attribute:: frozen :type: dict[str, Any] | None :value: None .. py:attribute:: plan :type: dict[str, int] .. py:attribute:: policy :type: dict[str, Any] | None .. py:attribute:: seconds :type: dict[str, float] .. py:attribute:: services :type: list[str] .. py:attribute:: trips :type: openmobisim.table.Columns .. py:class:: FrankWolfeOptions(*, gap_tolerance = 0.0001, iterations = 1000) ``equilibration="frank_wolfe"`` (``flow_level=1`` only): ``equilibration_options``. .. attribute:: gap_tolerance —; ``0.0001``. .. attribute:: iterations count; ``1000``. .. py:class:: FreeFlowOptions(*, increments = None, warmup = 1) ``equilibration="free_flow"``: ``equilibration_options``. .. attribute:: increments count; by default ``None``: 1 at flow_level 0 whatever is set. .. attribute:: warmup count; ``1``. .. py:class:: 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. .. attribute:: max_routes count; ``10``. .. attribute:: searches count; ``1``. .. attribute:: slack —; ``0.02``. .. attribute:: tree_step_s s; ``300.0``. .. attribute:: until_iteration —; ``0.0``. .. py:class:: 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 ``None`` by default: the class's own shipped value, which ``parameters()`` lists (as ``motorway.lanes`` …). A class without one of them refuses it when the network is read. .. attribute:: free_flow_km_h km/h. .. attribute:: jam_density_veh_km_lane veh/km per lane. .. attribute:: lanes count. .. attribute:: saturation_flow_veh_h_lane veh/h per lane. .. py:class:: 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 ``penalty`` and the search is repeated. .. attribute:: max_attempts count; ``15``. .. attribute:: max_detour —; ``1.3``. .. attribute:: max_overlap —; ``0.75``. .. attribute:: max_paths count; ``5``. .. attribute:: penalty —; ``1.5``. .. py:class:: 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``. .. attribute:: bpr_alpha —; ``0.15``. .. attribute:: bpr_beta —; ``4.0``. .. attribute:: node_inflow 0 or 1; ``0``. .. attribute:: origin_inflow 0 or 1; ``0``. .. attribute:: period_s s; ``0.0``. .. attribute:: pocket_length_m m; ``50.0``. .. attribute:: priority 0 or 1; ``0``. .. attribute:: reroute 0 or 1; by default ``None``: on at flow_level 3 and 4; off at 2 unless asked for (1). .. attribute:: reroute_after_s s; ``300.0``. .. attribute:: reroute_max count; ``3``. .. attribute:: reroute_min_gain —; ``0.1``. .. attribute:: reroute_tree_s s; ``60.0``. .. py:class:: 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``. .. attribute:: beta_bike_lane_km per km; ``0.0``. .. attribute:: beta_bike_min per min; ``0.0``. .. attribute:: beta_bike_mixed_km per km; ``-0.16``. .. attribute:: beta_bike_separated_km per km; ``0.0``. .. attribute:: beta_car_min per min; ``0.0``. .. attribute:: beta_cost_eur per EUR; ``-1.2``. .. attribute:: beta_cost_fare_eur per EUR; ``0.0``. .. attribute:: beta_cost_parking_eur per EUR; ``0.0``. .. attribute:: beta_cost_running_eur per EUR; ``0.0``. .. attribute:: beta_cost_toll_eur per EUR; ``0.0``. .. attribute:: beta_detour per unit of the attribute; ``0.0``. .. attribute:: beta_length_km per km; ``0.0``. .. attribute:: beta_ln_path_size per unit of the attribute; ``1.0``. .. attribute:: beta_mode_bike per unit of the attribute; ``0.0``. .. attribute:: beta_mode_bike_transit per unit of the attribute; ``0.0``. .. attribute:: beta_mode_car per unit of the attribute; ``0.0``. .. attribute:: beta_mode_car_transit per unit of the attribute; ``0.0``. .. attribute:: beta_mode_transit per unit of the attribute; ``0.0``. .. attribute:: beta_mode_walk per unit of the attribute; ``0.0``. .. attribute:: beta_n_links per unit of the attribute; ``0.0``. .. attribute:: beta_overlap per unit of the attribute; ``0.0``. .. attribute:: beta_parking_min per min; ``0.0``. .. attribute:: beta_ride_bus_min per min; ``0.0``. .. attribute:: beta_ride_ferry_min per min; ``0.0``. .. attribute:: beta_ride_metro_min per min; ``0.0``. .. attribute:: beta_ride_min per min; ``0.0``. .. attribute:: beta_ride_other_min per min; ``0.0``. .. attribute:: beta_ride_rail_min per min; ``0.0``. .. attribute:: beta_ride_tram_min per min; ``0.0``. .. attribute:: beta_time_min per min; ``-0.2``. .. attribute:: beta_transfers per unit of the attribute; ``-1.0``. .. attribute:: beta_trip_departure_h per unit of the attribute; ``0.0``. .. attribute:: beta_wait_first_min per min; ``0.0``. .. attribute:: beta_wait_min per min; ``-0.09``. .. attribute:: beta_wait_transfer_min per min; ``0.0``. .. attribute:: beta_walk_access_min per min; ``0.0``. .. attribute:: beta_walk_egress_min per min; ``0.0``. .. attribute:: beta_walk_min per min; ``-0.13``. .. attribute:: beta_walk_transfer_min per min; ``0.0``. .. py:class:: 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``. .. attribute:: bike_access_s s; ``60.0``. .. attribute:: bike_egress_s s; ``60.0``. .. attribute:: bike_max_s s; ``3600.0``. .. attribute:: car_access_s s; ``120.0``. .. attribute:: car_egress_s s; ``300.0``. .. attribute:: car_snap_motorway_m m; ``50.0``. .. attribute:: fallback_car 0 or 1; ``0``. .. attribute:: walk_max_s s; ``1800.0``. .. py:class:: MonteCarloOptions(**options) The old name of ``SimulationOptions``, still accepted with a ``DeprecationWarning``. .. py:class:: 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``. .. attribute:: cost_bin_s s; ``300.0``. .. attribute:: gap_every —; ``0.0``. .. attribute:: gap_sample count; ``300``. .. attribute:: gap_tolerance —; ``0.05``. .. attribute:: increments count; by default ``None``: 1 at flow_level 0 whatever is set. .. attribute:: iterations count; ``15``. .. attribute:: itinerary_gap_sample count; ``100000000``. .. attribute:: route_growth_tolerance —; ``1.0``. .. attribute:: step_offset —; ``0.0``. .. attribute:: warmup count; ``1``. .. py:class:: 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``. .. attribute:: beta_bike_lane_km per km; ``0.0``. .. attribute:: beta_bike_min per min; ``0.0``. .. attribute:: beta_bike_mixed_km per km; ``-0.16``. .. attribute:: beta_bike_separated_km per km; ``0.0``. .. attribute:: beta_car_min per min; ``0.0``. .. attribute:: beta_cost_eur per EUR; ``-1.2``. .. attribute:: beta_cost_fare_eur per EUR; ``0.0``. .. attribute:: beta_cost_parking_eur per EUR; ``0.0``. .. attribute:: beta_cost_running_eur per EUR; ``0.0``. .. attribute:: beta_cost_toll_eur per EUR; ``0.0``. .. attribute:: beta_detour per unit of the attribute; ``0.0``. .. attribute:: beta_length_km per km; ``0.0``. .. attribute:: beta_ln_path_size per unit of the attribute; ``1.0``. .. attribute:: beta_mode_bike per unit of the attribute; ``0.0``. .. attribute:: beta_mode_bike_transit per unit of the attribute; ``0.0``. .. attribute:: beta_mode_car per unit of the attribute; ``0.0``. .. attribute:: beta_mode_car_transit per unit of the attribute; ``0.0``. .. attribute:: beta_mode_transit per unit of the attribute; ``0.0``. .. attribute:: beta_mode_walk per unit of the attribute; ``0.0``. .. attribute:: beta_n_links per unit of the attribute; ``0.0``. .. attribute:: beta_overlap per unit of the attribute; ``0.0``. .. attribute:: beta_parking_min per min; ``0.0``. .. attribute:: beta_ride_bus_min per min; ``0.0``. .. attribute:: beta_ride_ferry_min per min; ``0.0``. .. attribute:: beta_ride_metro_min per min; ``0.0``. .. attribute:: beta_ride_min per min; ``0.0``. .. attribute:: beta_ride_other_min per min; ``0.0``. .. attribute:: beta_ride_rail_min per min; ``0.0``. .. attribute:: beta_ride_tram_min per min; ``0.0``. .. attribute:: beta_time_min per min; ``-0.2``. .. attribute:: beta_transfers per unit of the attribute; ``-1.0``. .. attribute:: beta_trip_departure_h per unit of the attribute; ``0.0``. .. attribute:: beta_wait_first_min per min; ``0.0``. .. attribute:: beta_wait_min per min; ``-0.09``. .. attribute:: beta_wait_transfer_min per min; ``0.0``. .. attribute:: beta_walk_access_min per min; ``0.0``. .. attribute:: beta_walk_egress_min per min; ``0.0``. .. attribute:: beta_walk_min per min; ``-0.13``. .. attribute:: beta_walk_transfer_min per min; ``0.0``. .. attribute:: mu —; ``0.5``. .. py:class:: 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``. .. attribute:: bike_dedicated_km_h km/h; ``18.0``. .. attribute:: bike_lane_cost_factor —; ``1.0``. .. attribute:: bike_mixed_cost_factor —; ``1.2``. .. attribute:: bike_mixed_km_h km/h; ``15.0``. .. attribute:: capacity_factor —; ``1.0``. .. attribute:: control_delay_factor —; ``1.0``. .. attribute:: ferry_km_h km/h; ``10.0``. .. attribute:: ferry_wait_s s; ``300.0``. .. attribute:: free_flow_speed_factor —; ``1.0``. .. attribute:: green_fraction_factor —; ``1.0``. .. attribute:: jam_density_factor —; ``1.0``. .. attribute:: signal_cycle_s s; ``90.0``. .. attribute:: signal_degree_of_saturation —; ``0.85``. .. attribute:: signal_green_fraction —; ``0.48``. .. attribute:: signal_merge_m m; ``25.0``. .. attribute:: walk_km_h km/h; ``4.8``. .. attribute:: busway the class's ``LinkClassOptions``; its own values by default. .. attribute:: cycleway the class's ``LinkClassOptions``; its own values by default. .. attribute:: ferry the class's ``LinkClassOptions``; its own values by default. .. attribute:: footway the class's ``LinkClassOptions``; its own values by default. .. attribute:: living_street the class's ``LinkClassOptions``; its own values by default. .. attribute:: motorway the class's ``LinkClassOptions``; its own values by default. .. attribute:: motorway_link the class's ``LinkClassOptions``; its own values by default. .. attribute:: pedestrian the class's ``LinkClassOptions``; its own values by default. .. attribute:: primary the class's ``LinkClassOptions``; its own values by default. .. attribute:: primary_link the class's ``LinkClassOptions``; its own values by default. .. attribute:: residential the class's ``LinkClassOptions``; its own values by default. .. attribute:: secondary the class's ``LinkClassOptions``; its own values by default. .. attribute:: secondary_link the class's ``LinkClassOptions``; its own values by default. .. attribute:: service the class's ``LinkClassOptions``; its own values by default. .. attribute:: street_30 the class's ``LinkClassOptions``; its own values by default. .. attribute:: street_50 the class's ``LinkClassOptions``; its own values by default. .. attribute:: street_70 the class's ``LinkClassOptions``; its own values by default. .. attribute:: tertiary the class's ``LinkClassOptions``; its own values by default. .. attribute:: tertiary_link the class's ``LinkClassOptions``; its own values by default. .. attribute:: trunk the class's ``LinkClassOptions``; its own values by default. .. attribute:: trunk_link the class's ``LinkClassOptions``; its own values by default. .. attribute:: unclassified the class's ``LinkClassOptions``; its own values by default. .. py:class:: 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``. .. attribute:: bin_s s; ``900.0``. .. attribute:: candidates count; ``3``. .. attribute:: pr_min_km km; ``3.0``. .. attribute:: rank_speed_km_h km/h; ``30.0``. .. attribute:: reach_bike_s s; ``1200.0``. .. attribute:: reach_car_s s; ``1800.0``. .. attribute:: reach_car_step_s s; ``0.0``. .. attribute:: slope_bike_s s; ``180.0``. .. attribute:: slope_car_s s; ``600.0``. .. attribute:: snap_m m; ``300.0``. .. attribute:: walk_max_s s; ``300.0``. .. py:class:: Parkings A scenario's parkings: park-and-ride car parks and bike parkings. Read them with :func:`parking_read_osm` or ``openmobisim.parking_read_table``; give them to a ``Scenario`` (``parkings=``) for its ``"car_transit"`` and ``"bike_transit"`` trips. .. py:method:: by_vehicle() Parkings and spaces by vehicle: ``{"car": (parkings, spaces), "bike": ...}``. .. py:method:: read_report() What reading OpenStreetMap found, kept and merged (``None`` if not read from it). .. py:method:: rows() Every parking, as columns. ``parking_id``, ``name``, ``hub_id``, ``lon``, ``lat``, ``vehicle``, ``capacity``, ``initial_occupancy``, ``fee_eur`` (``None`` where the table gave none: the run's price for the kind applies). .. py:attribute:: count :type: int .. py:attribute:: read_s :type: float | None .. py:class:: PenaltyOptions(**options) The old name of ``LinkPenaltyOptions``, still accepted with a ``DeprecationWarning``. .. py:class:: 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``. .. attribute:: bike_eur_km EUR/km; ``0.0``. .. attribute:: car_eur_km EUR/km; ``0.0``. .. attribute:: fare_base_eur EUR; ``0.0``. .. attribute:: fare_km_eur EUR/km; ``0.0``. .. attribute:: fare_transfer_eur EUR; ``0.0``. .. attribute:: parking_bike_eur EUR; ``0.0``. .. attribute:: parking_car_eur EUR; ``0.0``. .. py:class:: 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. .. py:method:: bike_route_choices() Which route each stated bike trip took among its set; ``None`` without bike sets. The same arrays as ``route_choices()``, one entry per trip of the demand; ``-1`` marks 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 in ``itinerary_choices()`` instead (in ``chains()`` on the one-loop engine, whose ``alternatives`` count the routes in the trip's own choice set). .. py:method:: bike_route_sets() The bike route sets, with ``bike_route_choice="doubly_stochastic"``; ``None`` otherwise. 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 with ``Run.open`` gives ``None``. .. py:method:: bike_share_dock_places() Every dock of the docked bike service, for maps; ``None`` without a service. ``dock``, ``hub_id``, ``hub_kind`` (``"stop"`` or ``"declared"``), ``service``, ``slots``, ``bikes_start`` (bikes at the start of the day), ``lon`` and ``lat``. .. py:method:: bike_share_docks() Every dock of the docked bike service over the service day, bin by bin. ``None`` without a service. One row per dock and time bin (the service's ``bin_s``, 900 s by default): ``service``, ``dock``, ``hub_id`` (its hub: a stop's within ``hub_join_m``, or its own), ``bin_start`` and ``bin_end`` (``"08:00:00"``), ``bin_start_s`` and ``bin_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 to ``bike_share_docks.parquet``: read it with ``bike_share_docks_table()``. .. py:method:: bike_share_docks_table() ``bike_share_docks.parquet``: ``bike_share_docks()`` after ``run_id``. ``None`` without a service. .. py:method:: bike_share_events() The docked bike service's logbook over its service day; ``None`` without 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) and ``time`` (the same as ``"08:03:20"``), ``traveller_id`` and ``trip_seq`` (as in ``trip_results()``; ``None`` for 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`` (``None`` for ``reached_destination``), ``bikes_at_dock_after`` and ``free_slots_after`` (the dock's state just after the event; ``None`` without a dock), ``next_dock`` and ``to_next_m`` (the dock walked or ridden on to, and how far in metres as the crow flies; ``None`` and ``NaN`` otherwise), ``transit_stop`` (for ``reached_transit_stop``, the stop's hub). ``event`` is 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's ``redirect_max`` and ``redirect_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`` (a ``bike_share`` trip at its destination), ``reached_transit_stop`` (a ``bike_share_transit`` trip at its stop's hub, named in ``transit_stop``; ``dock`` ``None``); and for an operator's van ``van_took_bikes`` and ``van_brought_bikes``. A service with ``options={"log_events": 0}`` keeps no log (for very large runs): no rows. The same table is written to ``bike_share_events.parquet``: read it with ``bike_share_events_table()``. .. py:method:: bike_share_events_table() ``bike_share_events.parquet``: ``bike_share_events()`` after ``run_id``. ``None`` without a service. .. py:method:: bike_share_trips() Every trip that chose a shared bike, over the service day; ``None`` without 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_dock`` and ``pickup_s`` (``None`` and ``NaN``: no bike), ``docks_tried_for_bike``, ``return_dock`` and ``return_s``, ``docks_tried_for_slot``, ``leg_end_s`` (at the destination, or for ``bike_share_transit`` the dock at the stop's hub; riding, or on foot after finding no bike). The extra time at the docks: ``extra_s`` (``leg_end_s`` less ``planned_leg_end_s``), split into ``extra_walk_at_pickup_s`` and ``extra_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_empty`` and ``docks_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 to ``bike_share_trips.parquet``: read it with ``bike_share_trips_table()``. .. py:method:: bike_share_trips_table() ``bike_share_trips.parquet``: ``bike_share_trips()`` after ``run_id``. What did not happen is null. ``None`` without a service. .. py:method:: 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) and ``travel_time_s`` at 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 with ``bike_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, as ``link_bins_table()``'s ``link``; ``network.layer("bike")``'s or ``"walk"``'s, as ``link_bins_table("bike")``'s) and ``link_index`` (the same links as indices into that layer's links; for a car, as ``route_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) and ``transfers``; 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 GTFS ``trip_id`` of the run ridden), ``ride_board_stop`` and ``ride_alight_stop`` (GTFS ``stop_id``), ``ride_board_s`` and ``ride_alight_s`` (when the run leaves the one and reaches the other, seconds after midnight). Read from ``chains.parquet``; needs pyarrow. .. py:method:: config() The run's ``run.toml``, the complete configuration it ran with, as a ``Config``. 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 /run.toml`` too when the file names its inputs (a scenario built from files by ``Config.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). .. py:method:: 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). ``nan`` marks 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``; ``found`` and ``found_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); ``added`` and ``added_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) and ``switch_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) and ``switch_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 most ``switch_tolerance``, 0.05 by default) and ``switch_above_floor`` (``switch_share − switch_floor``: the share of all trips that changed chain beyond chance, reported only); ``departed``, ``arrived``, ``unfinished`` (people) and ``unfinished_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 are ``gap_deterministic`` and ``spread``, ``(Σ 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 to ``gap`` under 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_bike`` and ``switch_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_bike`` is the share of the trips on a bike chain that took another chain, of any mode; ``nan`` when 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_bike`` and ``mode_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_mode`` the 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; ``nan`` without such trips); ``mode_share_car``, ``mode_share_bike`` and ``mode_share_walk`` (the modal split of the trips choosing their mode after the choice, over those with a chain; ``nan`` when 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 four ``mode_share_change_expected_`` columns sum to 0; and each stage's wall-clock seconds, ``search_s``, ``choose_s``, ``load_s``, ``measure_s`` and ``assess_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`` — what ``changed_share`` would 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 of ``1 − Σ q²`` (``q`` the 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 equilibrium ``changed_share`` sits near it; travellers still moving towards better routes put the share above it. ``nan`` at the first iteration, without trips given the car, and for a model that gives no probabilities. Not in ``kpis.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 is ``total_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), ``t`` the 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; ``nan`` for 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 what ``gap_tolerance`` stops on and what ``convergence_verdict`` judges (``gap_generalised_excess`` instead where that is measured). Equal to ``gap`` for ``"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, ``nan`` elsewhere (``gap_sample`` 0 switches it off). It shows whether the choice set was missing a route that traffic has made worthwhile. * ``gap_network_excess`` — its disequilibrium: ``gap_network`` less 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 a ``probabilities(batch)`` method) and are ``nan`` without one; ``gap`` does 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; ``nan`` for a mode without such trips. ``gap`` above 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), and ``gap_car``, ``gap_bike`` and ``gap_walk`` are the same for the trips that chose those modes, door to door against the best of their mode (``gap`` above covers every car trip's route: given the car, or choosing it). With ``itinerary_gap_sample`` set 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; ``nan`` without 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); with ``transit_options`` ``buses_on_roads`` 1, what traffic did to the buses. ``nan`` when 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 in ``gap_transit``, ``gap_car_transit`` and ``gap_bike_transit`` paid above the best of their mode. 0 when the difference is 0; ``nan`` when it is, or when no such trip was measured (a run of one loading). Neither is in ``kpis.parquet``. * ``mode_changed_share`` — with ``modes``: of the trips choosing their mode that had chosen before, the share (by traveller weight) whose mode changed on the way to this loading; ``nan`` at the first iteration and without ``modes``. 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 of ``convergence_gap`` and of what ``gap_tolerance`` stops 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``, ``g`` a route's generalised minutes at this loading's times (defined under the full gaps below), ``g_expected`` its expectation under the model's probabilities over the routes offered and ``g_least`` the least of them: ``gap_excess`` with 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 what ``gap_tolerance`` stops on in place of ``gap_excess``, together with ``itinerary_gap_excess``, and what ``convergence_gap`` and ``convergence_verdict`` read. ``nan`` where the route cost is travel time alone (the defaults: ``gap_excess`` is 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_options`` ``gap_every`` 1, else ``nan`` before 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 euro ``beta_cost_eur / beta_time_min`` minutes. Nothing stops or judges the run on them (``gap_tolerance``, ``convergence_gap`` and ``convergence_verdict`` read the gaps above); ``nan`` for 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 expects ``gap_route`` to be at these costs: the same sum with each trip's expected ``g`` under the model's probabilities over the routes it was offered; ``nan`` without 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_route`` against 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 in ``g``, so where money weighs this gap can read low. * ``gap_route_network_excess`` — its disequilibrium: ``gap_route_network`` less 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; ``nan`` without mode choice. * ``gap_mode_expected`` — what the choice model expects ``gap_mode`` to 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 of ``gap_route`` that arrived on a route it was offered, ``p`` is the probability the model gives the route it took and ``p*`` the highest probability among the routes it was offered, both at this loading's costs; the spread is ``Σ w (1 − p / p*) / Σ w``, ``w`` the 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, while ``gap_route_excess`` says how far the run is from equilibrium. ``nan`` for 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; ``nan`` without mode choice. * ``excess_min_route`` — the deterministic part of the route gap as minutes per traveller: what the average traveller pays, in ``g``, 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 (their ``g``, 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_excess`` are also in ``kpis.parquet``, a row per metric per iteration, and so are the itinerary gaps (under their modes, as ``gap``), ``hub_mismatch_s``, ``mode_changed_share``, ``itinerary_gap_excess``, ``gap_generalised_excess`` and the full gaps. .. py:method:: diagnostics() ``diagnostics.parquet``: aggregated counters, one row per issue. .. py:method:: events() ``events.parquet``: sampled per-trip events. .. py:method:: 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 that ``fleet_day(network, services, frozen=folder)`` and ``fleet_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 in ``trip_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_node`` and ``destination_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_from`` and ``dock_to`` (the docks it chose; empty for a taxi), ``ride_s`` (the planned ride between them, the service's ``ride_factor`` included), ``egress_s`` (the walk from the return dock to the destination) and ``assumed_extra_walk_s`` (the extra walk at the docks its choice assumed, in seconds; ``NaN`` for 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``: ``format`` and ``version``, the ``run_id``, the run's, its network's and its services' fingerprints (``run_fingerprint``, ``network_fingerprint``, ``services_fingerprint``), the ``window`` (seconds from midnight), the ``seed`` (the run's master seed, the engine's), the ``services`` (name, kind, docks, options), the ``legs`` and ``people``, and the road times' bin length and rows. A replay is refused with a network or services other than the run's. :param folder: Where to write; made if missing. :param overwrite: 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``). :raises RuntimeError: For a run read back with ``Run.open``: only a run in memory holds its service day. .. py:method:: 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 least ``g_chosen_min`` of 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``'s ``points_per_zone``, ``Case.demand``'s ``one_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, their ``g_chosen_min`` the 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 are ``gap_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 with ``convergence()``'s ``gap_route``, not with ``gap_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 of ``g_chosen_min`` over the group's people), ``excess_min`` (``Σ w (g_chosen − g_best)``, minutes summed over the group's people), ``gap`` (``excess_min / Σ w g_best``; ``nan`` where that is 0) and ``unfinished`` (the group's trips still under way when the window ended). ``gap_pairs_relative`` sums it over every group. :param departure_bin_s: 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 ``None`` for a run of one loading (``gap_trips()`` is ``None``). :raises ValueError: If ``departure_bin_s`` is not a whole number of at least 1. :raises RuntimeError: For a run read back with ``Run.open``, which has no ``gap_trips()``. .. py:method:: 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 most ``gap_route``; trips leaving at other seconds of a bin can make it read higher. :param departure_bin_s: The bins' width, in seconds (``gap_pairs``'). :returns: The share, or ``nan`` for a run of one loading (``gap_trips()`` is ``None``). :raises ValueError: If ``departure_bin_s`` is not a whole number of at least 1. :raises RuntimeError: For a run read back with ``Run.open``, which has no ``gap_trips()``. .. py:method:: 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. ``trip`` is its index in the demand; ``g_chosen_min`` the 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_min`` the best of the car routes it was offered; ``g_best_network_min`` the best over the whole network (the fastest route a time-dependent search finds, if better); ``g_expected_min`` what 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_min`` the best of its whole choice set, every mode (``nan`` for a trip given its mode); ``p_ratio_route`` the choice model's probability of the car route it took over the highest probability among the car routes it was offered, and ``p_ratio_mode`` the same for the alternative it took over its whole choice set (a trip choosing its mode), each ``nan`` where the alternative taken was not offered, the trip was still under way at the end, or the model gives no probabilities; ``unfinished`` whether it was still under way at the end. The units are ``gap_currency``'s; the sums are ``convergence()``'s ``gap_route`` and ``gap_mode``, and ``1 − p_ratio_route`` and ``1 − p_ratio_mode`` averaged by traveller weight its ``spread_route`` and ``spread_mode``, at its last row. In memory, from the run that produced it: ``None`` for a run of one loading, and a run read back with ``Run.open`` has none. .. py:method:: itinerary_choices() Each itinerary trip's choice, and each choice of mode; ``None`` without 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_id`` and ``trip_seq`` (its place in that traveller's day, from 0), ``user_class`` (the traveller's class), ``mode`` (the mode taken; ``None`` for a trip choosing its mode that had nothing to choose from), ``mode_choice`` (whether the trip chose its mode), ``parking_id`` (the parking used; ``None`` for 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) and ``logsum`` (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; ``nan`` for a model that gives none; a model of one's own may give one with a ``logsum(batch)`` method, one number per situation). In the utility's units: divided by ``-beta_time_min`` it 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. .. py:method:: itinerary_journeys() Each itinerary trip's chosen journey, leg by leg; ``None`` without any. The journey each row of ``itinerary_choices()`` planned at its last choice, in the same order (``trip`` is the same column), as NumPy arrays; a list per trip (its links, its rides) is given flat with offsets, one more entry than trips: trip ``i``'s links are ``links[link_offsets[i]:link_offsets[i + 1]]``. Kept in memory: ``None`` for a run opened from its folder. Columns: ``road_origin`` and ``road_destination`` (the trip's origin and destination nodes on the road layer, the pair of ``route_sets()``; ``2**32 - 1`` for 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, ``None`` for no journey), ``links`` and ``link_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_stop`` and ``last_stop`` (indices into ``transit.stops()``; ``2**32 - 1`` without transit), the rides ``ride_line`` (an index into ``transit.lines()``), ``ride_board`` and ``ride_alight`` (stop indices), ``ride_s`` (expected seconds on board) and ``ride_transfer_walk_s`` (the walk before it from the stop last left, 0 for the first ride), by ``ride_offsets``; ``access_walk_s`` and ``egress_walk_s`` (the walks to the first stop and from the last); the expected seconds ``walk_s``, ``wait_s``, ``ride_total_s`` (on board), ``vehicle_s`` (driving or cycling) and ``parking_s`` (parking, or reaching the parked vehicle), and ``expected_s`` (door to door); ``dock_pickup`` and ``dock_return`` (a shared bike's docks, by the docked service's dock index; ``2**32 - 1`` otherwise). ``viz.map_interactive`` draws them, by origin-destination pair. .. py:method:: kpis() ``kpis.parquet``: long format, one row per metric. Columns ``run_id, design_id, replication, iteration, mode, metric, value``. ``mode`` is ``"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 adds ``boardings`` and the buses' numbers under ``"transit"``; the parkings add ``parking_arrivals``, ``parking_overflow_arrivals``, ``parking_full_share``, ``hub_mismatch_s`` and ``vehicles_left_at_parkings`` — car parkings under ``"car_transit"``, bike parkings under ``"bike_transit"`` — and the itineraries ``itinerary_replanned_trips`` and ``return_mismatch_s`` under ``"all"``. With mode choice (``modes``) each trip counts under the mode it took, each mode adds its ``mode_share`` (of the trips, weighted by the travellers), and every iteration adds ``mode_changed_share`` under ``"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, as ``completion`` does: ``completed_trips``, ``completed_people`` and ``total_travel_time_s`` by the second each arrived, ``truncated_trips`` those still under way at the window's end, and ``cancelled_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). .. py:method:: link_bins(layer = 'road') Per-link, per-time-bin results, or ``None`` if the run did not ask. Ask with ``Scenario.run(...)`` on a scenario built with ``link_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 to ``link_bins.parquet``: read it with ``Run.link_bins_table()``. ``layer`` is ``"road"`` (the default), ``"bike"`` or ``"walk"``: the bike and walk layers' results are indexed by their own links (``run.network.layer("bike")``), and their ``pcu`` counts travellers. They are ``None`` when no trip of that mode ran. .. py:method:: link_bins_table(layer = 'road') ``link_bins.parquet``: the per-link results as a table, or ``None``. ``layer="bike"`` or ``"walk"`` reads ``link_bins_bike.parquet`` or ``link_bins_walk.parquet`` instead: the same columns, except that the weighted count is ``travellers`` and its time ``traveller_seconds``. ``None`` unless the scenario was built with ``link_bin_s``. One row per (bin, link) that saw traffic, sorted by bin then link, with columns ``run_id, bin, start_s, link, link_index, crossings, pcu, pcu_seconds``: * ``link`` is the link's external id (an OSM way and direction, say), the id that survives a rebuilt network; ``link_index`` is its row in the network's arrays, meaningful only next to this run's network fingerprint, which the file's metadata carries. * ``crossings`` counts traversals that finished in the bin; ``pcu`` is the traffic that left the link (traveller weight and vehicle size included); ``pcu_seconds`` is the PCU-weighted time they took. Mean traversal time is ``pcu_seconds / pcu`` and the flow in PCU per hour is ``pcu * 3600 / bin_seconds``. .. py:method:: 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. :param links: One link or several, as indices into the layer's links (the road network's, or ``network.layer("bike")``'s or ``"walk"``'s). :param layer: ``"road"`` (the default), ``"bike"`` or ``"walk"``. The bike and walk layers need a run with per-link results (``link_bin_s``). :param zones: ``{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 of ``route_sets()``), for every mode. :param departure_s: ``(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. :param bin_s: 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), ``origin`` and ``destination`` (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) and ``share_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). .. py:method:: 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). :param trips: The trips the run was given: rows of ``Scenario.from_parts``' ``demand``, or a ``trips.csv`` path. :param zones: ``{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). :param by_class: Also by the traveller's class. :returns: ``origin``, ``destination`` (zone names, or node indices), ``user_class`` (with ``by_class``), ``trips`` (simulated), ``people`` (their weights) and ``logsum`` (the people-weighted mean, in the utility's units). :rtype: 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``. .. py:method:: manifest() ``manifest.json``: the file that makes this run reproducible. .. py:method:: open(folder) :classmethod: 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``, ``converged`` and ``manifest()`` (from ``manifest.json``); ``completion``, ``completion_by_mode``, ``total_travel_time_s``, ``mean_travel_time_s``, ``convergence()``, ``convergence_gap`` and ``convergence_verdict`` (from ``kpis.parquet``); ``timings()``; ``trip_results()`` and ``trip_modes()`` (from ``trip_results.parquet``); ``operator_decisions()`` (from ``operator_tasks.parquet``); and every table (``kpis()``, ``diagnostics()``, ``events()``, ``link_bins_table()``, ``parking_bins_table()``, ``transit_calls_table()``, the ``bike_share_*_table()`` and ``taxi_*_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 a ``RuntimeError`` that says so. Needs pyarrow. :param folder: The run's ``output_dir``, holding its ``manifest.json``. :raises FileNotFoundError: If the folder holds no ``manifest.json``. .. py:method:: 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; ``None`` without an operator. The same table is written to ``operator_tasks.parquet`` (read it with ``operator_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``; ``None`` or NaN where a kind has none), ``accepted``, ``reason`` (why it was refused, ``None`` if 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). .. py:method:: operator_tasks_table() ``operator_tasks.parquet``: ``operator_decisions()`` after ``run_id``. ``None`` without an operator. A number a decision does not have is null in the file. .. py:method:: parking_bins() How full each parking was over the day, bin by bin; ``None`` without 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``, ``arrivals`` and ``departures`` (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) and ``overflow_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 to ``parking_bins.parquet``: read it with ``parking_bins_table()``. .. py:method:: parking_bins_table() ``parking_bins.parquet``: ``parking_bins()`` after ``run_id``; ``None`` without parkings. The file's metadata carries the run's fingerprint and its master seed. .. py:method:: parking_places() Each parking the run kept, as columns; ``None`` without parkings. ``parking_id``, ``hub_id``, ``vehicle``, ``capacity``, ``lon``, ``lat`` and ``name``. ``parking`` in ``parking_bins()`` indexes these. .. py:method:: report_gridlock() What stood still when the last loading's window ended; ``None`` at 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``, and ``room_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 a ``gridlock`` diagnostic per loop. .. py:method:: 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's ``modes``, 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. ``change`` names, for each row, what to change: the options behind its reasons (``NO_ALTERNATIVE_CHANGES``). .. py:method:: 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 than ``min_excess_pcu`` is 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. :param min_excess_pcu: How many PCU past its storage a link's peak must be to be listed. :returns: ``link`` (internal link id), ``peak_pcu`` and ``storage_pcu``; ``None`` at level 0. The full model (level 4) keeps queues within storage, so its list is about empty. ``viz.map_interactive`` can show them. :rtype: NumPy arrays, worst first (by the PCU that did not fit) .. py:method:: 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) and ``reason`` (``"closed_ahead"``: its next link closed; ``"stuck"``: blocked for ``reroute_after_s``). Its planned route is its route choice (``route_choices``); what it actually took is in ``route_realised``. .. py:method:: 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 into ``route_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; ``nan`` if it gave none) and ``weight`` (how many people the trip stands for). ``-1`` marks 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. .. py:method:: route_realised() The realised routes of the trips that re-routed in the last loading and arrived. ``trip`` (their indices) and ``links`` (for each, the link indices it took, in order). Every other trip followed its planned route, which nothing stores twice. .. py:method:: route_set_summary() What the car route sets held and how they were used; ``None`` without car route sets. Read from ``route_sets()``, ``route_choices()`` and ``convergence()``; every number is a ``float``, ``nan`` where 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 of ``convergence()["routes_added"]``); 0 without one. A route added to a full set takes the place of one nobody chose, so ``routes`` can grow by less. * ``route_searches`` — how many searches the route update made over the run (the sum of ``convergence()["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().rank`` 0). * ``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. .. py:method:: 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 with ``openmobisim.viz.map_route``. .. py:method:: service_actual() What the service day actually gave, as ``service_assumptions()``; ``None`` without 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 (``cancelled`` over ``requests``); for a docked service, ``assumed_extra_walk_at_pickup_s`` and ``assumed_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_s`` and ``extra_walk_at_return_mean_s``; per trip, ``bike_share_trips()``'s ``extra_walk_at_pickup_s`` and ``extra_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. .. py:method:: service_assumptions() What the run's travellers assumed about the services, by name; ``None`` without 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 as ``manifest.json``'s ``service_assumptions`` (``null`` there for ``None``), and accepted as it is by ``Scenario.run(service_assumptions=...)``. .. py:method:: service_policy() The operator that steered the run's service day; ``None`` without one. ``{"name", "parameters"}``, as ``Scenario.run(policy=...)`` gave it and ``manifest.json``'s ``service_policy`` records it. .. py:method:: 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; at ``flow_level=1`` the 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 (with ``bike_cost="utility"``, the default, a bike trip rides the route of least generalised cost, which may take longer than this time; with ``bike_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 within ``transit_options``' ``access_walk_max_s``. Classes' own limits do not apply. The same point (one node) takes 0; ``nan`` where nothing arrives within ``max_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. :param mode: ``"car"``, ``"bike"``, ``"walk"`` or ``"transit"``. :param origins: The points to leave from: ``(lon, lat)`` pairs, or a dict of them by name (``demand_read_zones``' zones). :param destinations: The points to arrive at, likewise; ``None``: the origins. :param departure_s: When to leave. :param max_s: 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. .. py:method:: taxi_events() The taxi fleet's logbook over the service day; ``None`` without 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) and ``time`` (the same as ``"08:03:20"``), ``event``, ``traveller_id`` and ``trip_seq`` (as in ``trip_results()``; ``None`` for a vehicle's own event), ``travellers`` (1: a trip standing for several people asks for that many taxis, each with its own events; ``None`` for a vehicle's own event), ``vehicle``, ``vehicle_state_after`` (``idle``, ``to_pickup``, ``occupied``, ``relocating``, ``to_charger``, ``charging`` or ``queued_at_charger``), ``charge_after`` (its battery's charge just after, a share; a drive's energy is taken as it starts), ``charger``, and ``drive_km`` (the kilometres of the drive the event starts; ``NaN`` otherwise). ``event`` is 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 limit ``request_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 own ``vehicle_went_to_charge`` (below the fleet's ``charge_below`` after a drop-off), ``queued_for_plug``, ``started_charging`` and ``charged``. A fleet with ``options={"log_events": 0}`` keeps no log (for very large runs): no rows. The same table is written to ``taxi_events.parquet``: read it with ``taxi_events_table()``. .. py:method:: taxi_events_table() ``taxi_events.parquet``: ``taxi_events()`` after ``run_id``. ``None`` without a taxi fleet. .. py:method:: taxi_trips() Every taxi request, over the service day; ``None`` without 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 limit ``request_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 delay ``dispatch_delay_s`` included), ``in_vehicle_s`` (from the pickup to the drop-off, boarding included), ``ride_km`` (with the passenger on board) and ``empty_km`` (the taxi's drive to the pickup). Seconds count from midnight; what did not happen is ``NaN`` (``None`` for a vehicle). The same table is written to ``taxi_trips.parquet``: read it with ``taxi_trips_table()``. .. py:method:: taxi_trips_table() ``taxi_trips.parquet``: ``taxi_trips()`` after ``run_id``. ``None`` without a taxi fleet. .. py:method:: taxi_vehicles() Each taxi of the fleet bin by bin (15 minutes), over the service day; ``None`` without. ``service``, ``vehicle``, ``bin_start`` and ``bin_end`` (``"08:00:00"``), ``bin_start_s`` and ``bin_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_occupied`` and ``km_empty`` (a drive's kilometres spread over its seconds), ``charge_at_start`` and ``charge_at_end`` (shares of the battery), ``kwh_charged`` and ``passengers_dropped_off``. The same table is written to ``taxi_vehicles.parquet``: read it with ``taxi_vehicles_table()``. .. py:method:: taxi_vehicles_table() ``taxi_vehicles.parquet``: ``taxi_vehicles()`` after ``run_id``. ``None`` without a taxi fleet. .. py:method:: 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`` (``None`` for a stage outside the iterations) and ``seconds``. 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_choice`` and ``itinerary_choice``, ``partial_loading`` and ``route_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 of ``convergence()``, after the last, or after each with ``gap_every`` 1) and ``network_gap`` after the last. After them: ``results_assembled``, ``results_written`` and ``total`` (the run alone). Also in ``timings.csv`` next to the other files. Times differ between runs, so they are in no result and not in the fingerprint. .. py:method:: transit_calls() Every call of the timetable in this run, as columns; ``None`` without one. One row per call (a run at a stop, in order): ``run`` (the GTFS ``trip_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``, and ``arrival_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 in ``transit_calls.parquet``) where a bus had not got there by the end of the window — then ``boardings``, ``alightings`` and ``on_board`` (as the vehicle leaves), weighted by traveller weight. Seconds count from the service day's midnight. .. py:method:: transit_calls_table() ``transit_calls.parquet``: every call of the timetable, or ``None`` without one. The columns of ``transit_calls()``, after ``run_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. .. py:method:: 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"``) and ``boardings`` (the travellers who boarded its runs in the window, weighted by traveller weight). ``None`` for a run without transit trips. Read from ``transit_lines.parquet``; needs pyarrow. .. py:method:: 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 against ``final_s`` gives each trip's relative gap, ``(vehicle_s − final_s) / final_s``; against ``free_flow_s``, its congestion ratio, ``vehicle_s / free_flow_s``, which is never below 1 under the point queue. :param departure_bin_s: 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_node`` and ``destination_node`` (indices into the network's nodes), ``car_departure_s`` (when the car enters the roads, seconds after midnight), ``free_flow_s`` and ``free_flow_links`` (the route at free flow: its seconds and its links, indices into the network's links in driving order), ``final_s`` and ``final_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. Seconds ``nan`` and 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 with ``Run.open`` has none. :rtype: Columns, one row per trip in the order of the demand :raises ValueError: If ``departure_bin_s`` is not above 0. .. py:method:: 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; with ``modes``, the mode taken, ``None`` for a trip that had nothing to choose from), ``mode_choice`` (whether the trip chose its mode) and ``weight`` (the people its traveller stands for). A trip that could not travel keeps its mode. ``viz.chart_mode_share`` draws it. .. py:method:: 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 as ``trip_results.parquet`` (with ``run_id``), which ``Run.open`` reads back. Columns: * ``trip`` (its index in the run, as in ``route_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 in ``trip_modes``; ``None`` for a trip that chose and had none to choose) and ``mode_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 trips ``report_no_alternative`` lists, but for those that then went by car: a trip that chose its mode has ``mode`` ``None``, one given transit, park-and-ride or bike-and-ride keeps it; ``completion`` counts them under the outcome they had, most often ``no_feasible_path``); * ``arrival_s`` and ``travel_time_s``: ``NaN`` unless the trip completed. ``travel_time_s`` is door to door: the fixed times of the trip's own vehicle (``mode_options`` ``car_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), and ``access_egress_s``: its fixed seconds around that vehicle (reaching it, leaving it, its parking's time; 0 without one). ``NaN`` unless the trip completed; so ``travel_time_s - vehicle_s - access_egress_s`` is 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 (as ``link_bins``'); ``NaN`` for 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; and ``service_arrival_s``, the second the traveller actually reached the destination (for ``bike_share_transit`` the hub's dock): by the service, or on foot after finding no shared bike; ``NaN`` if 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 with ``completion``, the no-alternative trips aside, and a service's trips counted by ``service_outcome`` instead: completed where ``service_arrival_s`` is a number (for ``bike_share_transit``, a planned arrival shifted by the day's difference at the hub's dock), cancelled where a taxi request was, truncated otherwise. .. py:property:: choice_model :type: str The name of the choice model that picked each trip's route, itinerary or mode. ``"nested_logit"``, ``"logit"`` or ``"deterministic"``, or the ``name`` of a model written in Python. .. py:property:: completion :type: 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_outcome`` and ``service_arrival_s``): ``completed`` if carried to its destination by the window's end (a shared-bike traveller who found no bike: if the walk on ended by then), ``truncated`` if still under way then, and a key of its own, ``cancelled``, if its taxi request was cancelled (the trip ends there). .. py:property:: completion_by_mode :type: dict[str, dict[str, float]] ``completion`` for each mode that has trips, and its travel time. ``{"car": {...}, "bike": {...}}``: the keys of ``completion`` and ``total_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) and ``completed_people`` (the same for its completed trips). The counts of ``completion`` are of simulated trips; a mode's mean trip is ``total_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, as ``completion`` does. .. py:property:: converged :type: 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 than ``max_iterations``). Under ``"msa"`` and ``"sra"``: the disequilibrium, averaged over the last three iterations, under ``gap_tolerance`` with the route sets no longer growing, whether that stopped the run early or held at its last allowed iteration. Always ``False`` with a ``gap_tolerance`` of 0, or under ``"free_flow"``. .. py:property:: convergence_gap :type: 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_excess`` where 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. ``nan`` if no gap was measured (a ``"free_flow"`` run). See ``convergence_verdict``. .. py:property:: convergence_verdict :type: str | None ``"good"`` (disequilibrium below 5%), ``"acceptable"`` (below 15%) or ``"poor"``. ``None`` if no gap was measured (a ``"free_flow"`` run). Judged on ``convergence_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. ``None`` on the one-loop engine, which judges nothing: its ``convergence()`` gives the measures. .. py:property:: engine :type: str ``"current"`` or ``"one-loop"`` (``Scenario.run``). :type: The engine the run ran on .. py:property:: equilibration :type: str ``"free_flow"``, ``"msa"`` or ``"sra"``. :type: The name of the equilibration strategy .. py:property:: fallback_car :type: 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 unless ``mode_options={"fallback_car": 1}`` (experimental, off by default, when such trips stay unsimulated). ``report_no_alternative()`` says why each had no alternative. .. py:property:: fingerprint :type: 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. .. py:attribute:: flow_level :value: 0 .. py:attribute:: flow_step_s :value: 300 .. py:property:: gap_currency :type: str What the full gaps of ``convergence()`` and ``gap_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 with ``Run.open`` has none. .. py:property:: master_seed :type: int The run's master seed (``Scenario`` argument ``master_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. .. py:property:: mean_travel_time_s :type: float The mean travel time of the completed trips, in seconds, per person. ``total_travel_time_s`` over the people the completed trips stand for (their travellers' weights). Dividing by ``completion["completed"]`` instead counts simulated trips, which differs from people when travellers stand for more than one (``default_weight``, ``demand_sample``). ``nan`` if no trip completed. Door to door (every trip's fixed times, walks, waits and rides included); ``mean_vehicle_time_s`` is the part spent in the trips' own vehicles. .. py:property:: mean_vehicle_time_s :type: float The mean time in their own vehicles of the completed trips, in seconds, per person. ``total_vehicle_time_s`` over the people the completed trips stand for, as ``mean_travel_time_s``; the trips without a vehicle of their own count with 0. ``nan`` if no trip completed. .. py:property:: network :type: openmobisim._core.Network | None The network this run loaded. .. py:property:: parking_summary :type: dict[str, float] | None What the parkings did, as numbers by name; ``None`` without parkings. ``parkings_given``, ``parkings_car`` and ``parkings_bike`` (kept), ``parkings_off_layer`` and ``parkings_no_stop`` (left out: too far from their layers, or no stop within walking distance); and for ``car`` and ``bike``: ``*_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). .. py:property:: parkings :type: openmobisim._core.Parkings | None The parkings this run's park-and-ride and bike-and-ride trips used, if any. .. py:property:: route_update :type: 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"``). .. py:attribute:: run_id :value: 'run' .. py:property:: timings_path :type: str ``Run.timings()`` as a file. :type: Path to ``timings.csv`` .. py:property:: total_travel_time_s :type: 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 (``completion`` says which trips count). .. py:property:: total_vehicle_time_s :type: 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_s`` holds less the fixed times (``mode_options`` ``car_access_s`` and 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. .. py:property:: transit :type: openmobisim._core.Transit | None The timetable this run's transit trips rode, if it had one. .. py:property:: transit_summary :type: dict[str, float] | None How transit went, as numbers by name; ``None`` without a timetable. ``boardings`` (weighted); and, with buses on the roads (``transit_options`` ``buses_on_roads`` 1), for the buses: ``bus_groups_on_roads`` (bus patterns that rode the roads), ``bus_groups_by_schedule_off_road``, ``bus_groups_by_schedule_no_route`` and ``bus_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) and ``bus_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_out`` and ``timetable_searches_back`` (made, for plain transit, out of a parking and back to one), ``timetable_reused_transit``, ``timetable_reused_out`` and ``timetable_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) and ``timetable_kept_bytes`` (the memory they hold). .. py:property:: unfinished_share :type: float The share of trips still travelling when the window ended, in the last loading. ``truncated`` over ``total_trips`` of ``completion``; 0 without trips. Above 0.05 the ``convergence_verdict`` is ``"poor"`` whatever the gap. .. py:property:: window :type: dict[str, Any] The simulation window and what departed outside it, left out of the run. Keys: ``start_s`` and ``end_s`` (seconds after midnight), ``start_given`` and ``end_given`` (whether the scenario gave them; else from the earliest departure, rounded down to the quarter hour, for ``default_s``), ``trips`` and ``people`` (the whole demand), ``before_trips``, ``before_people``, ``before_first_s``, ``before_last_s`` and the same ``after_*`` (left out), and ``timetable_runs_kept``, ``timetable_runs_cut``, ``timetable_runs_dropped``, ``timetable_calls_dropped`` (the timetable kept only its calls inside the window; ``None`` without one). .. py:class:: 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_parts`` rather than the constructor directly. .. py:method:: 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) :classmethod: Build a scenario from a network and demand. :param network: Built by, for example, ``examples.manhattan_grid``. :param demand: The trips, in the schema of ``trips.parquet`` whatever the form: rows (``Trip`` named tuples, or plain tuples of the same fields, as ``examples.fixed_car_trips`` returns), a dict of columns or a pandas or polars data frame with those columns (``weight`` and ``mode`` optional), or a path to a ``trips.parquet`` file or a ``trips.csv`` (read by ``demand_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** (the ``mode`` column of ``trips.parquet``): ``"car"``, ``"bike"``, ``"walk"``, ``"transit"``, ``"car_transit"`` (park-and-ride) or ``"bike_transit"`` (bike-and-ride; see ``parkings``). A trip without one is a car trip, or, with ``modes``, 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 needs ``transit``: it walks to a stop, rides and walks on (see ``transit``). :param persons: The ``persons.parquet`` equivalent — an in-memory table, a file path, or ``None`` if every traveller takes their class's default ownership. :param classes: The traveller classes, ``{class_name: columns}``, a trip's class being its ``user_class``: ``demand_read_classes`` reads them from a CSV file, or give a dict of the same columns. A class may say ``modes`` (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 a ``persons`` row 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 the ``price_options`` — the pass is money, never access: who may take transit is said by the modes, so give ``has_transit_pass`` as 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's ``modes``, which govern the ordinary modes only), ``has_taxi`` (likewise for a taxi) and any ``beta_*`` 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_s`` and ``bike_max_s``, the longest walk and ride offered to its trips choosing their mode, and ``access_walk_max_s``, the longest walk to or from a stop (unsaid: ``mode_options``' and ``transit_options``'; for example a class of keen cyclists riding up to 90 minutes, ``{"bike_max_s": 5400}``); its ``share`` is read only by ``demand_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, without ``classes``) may use every mode, with the model's coefficients, and owns a car, a bike and a transit pass unless a ``persons`` row 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. :param default_weight: 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. :param window: 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 a ``WindowWarning`` that says how many, when and how to widen the window. Not given (or ``None`` for 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. :param flow_level: 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. ``4`` is 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. ``3`` is a spatial queue. ``0`` is 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. ``1`` is 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_options`` ``bpr_alpha``, ``bpr_beta``), and the deterministic user equilibrium (every used route of a pair as fast as its fastest) solved by ``equilibration`` ``"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_options`` ``period_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). Under ``equilibration="free_flow"`` (the free-flow loading alone, no iterations) every level from 2 loads as the point queue (``equilibration_options`` ``warmup``, 1 by default), so levels 2, 3 and 4 differ only in whether stuck vehicles may re-route (``loading_options`` ``reroute``: off at 2, on at 3 and 4); the level sets how ``"msa"``'s iterations after it load. :param flow_step_s: The loading step in seconds, for levels 2-4. It is a bookkeeping boundary: results do not depend on it. :param link_bin_s: If given, also record per-link results in time bins of this many seconds, read with ``Run.link_bins()`` and drawn with ``openmobisim.viz.map_link``. It changes no result: the link times travellers choose on are binned at the equilibration's ``cost_bin_s``. :param route_method: 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** (an ``equilibration`` with more than one iteration, or a free-flow loading built up in groups, the default at ``flow_level`` 2 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 giving ``route_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 by ``penalty``. ``"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 most ``twin_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 on ``time_min``, ``length_km``, ``cost_eur`` and its parts ``cost_running_eur`` and ``cost_toll_eur``, ``bike_mixed_km`` and ``link_values`` columns named ``__km`` or ``__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 by ``1 + tau·v``, ``v`` uniform in [-1, 1), and every link's cost by ``1 + sigma·u``, ``u`` uniform in [0, 1). A route is kept if it is new, its generalised cost (unperturbed, by the coefficients it was found with) is at most ``max_detour`` times the first route's, and it shares at most ``max_overlap`` of that cost with each route kept before it, up to ``max_paths`` routes. Which route a trip takes among its alternatives is ``choice_model``'s business. The old names ``"penalty"``, ``"montecarlo"`` and ``"sampled"`` are still accepted, with a ``DeprecationWarning``. :param route_options: 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) and ``twin_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) and ``biased`` (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) and ``seed`` (0: another seed is another set of draws). Every value is an assumption, not a calibration. :param master_seed: 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. :param choice_model: How each trip picks a route from its pair's set: a name from ``openmobisim.choice_models()`` or an object with a ``choose(batch)`` method (see ``openmobisim.choice`` for 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 by ``1/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. :param choice_options: 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) and ``beta_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, see ``price_options``), and 0 for the rest, such as ``beta_length_km``, ``beta_parking_min`` or the mode constants ``beta_mode_bike`` … (``openmobisim.choice.ROUTE_ATTRIBUTES`` lists them), and products of two attributes, ``beta_*`` (see ``trip_values``); for ``"nested_logit"`` also ``mu`` (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. :param choice_detour_limit: 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.5`` offers 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). ``0`` offers 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. The ``ln_path_size`` attribute is computed over the routes offered, so overlap with a route nobody is offered is no overlap. :param choice_max_routes: 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**; ``0`` offers every route within the limit. A pair's set may hold more (the route update's ``max_routes``, 10), so a route not offered now can be later. :param max_cost_vectors: 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_grouped`` diagnostic. Where the utility weighs time alone (cars at the defaults: every price 0) every search is by time and this changes nothing. ``2`` by default (uncalibrated: a bound on run time). :param bike_cost: 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 a ``cost_vectors_grouped`` diagnostic. ``"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. :param bike_route_choice: 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 under ``bike_cost``. ``"doubly_stochastic"``: the ``"doubly_stochastic"`` route method (see ``route_method``) makes a set of routes per pair on the bike layer, the generalised cost of each class including its coefficients on ``bike_mixed_km``, ``length_km`` and money; every bike trip with a stated mode then chooses its route once, on the layer's times, through ``choice_model`` (with the path size over the routes offered, ``choice_detour_limit`` and ``choice_max_routes`` as 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()`` and ``Run.bike_route_choices()`` show the sets and the choices. On ``engine="one-loop"`` the same method makes the sets, its generalised cost under ``bike_cost="utility"`` reading each class's coefficients on ``length_km``, ``bike_mixed_km``, ``bike_lane_km`` and ``bike_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 (no ``choice_detour_limit`` or ``choice_max_routes``). :param bike_route_options: 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 with ``bike_route_choice="doubly_stochastic"``. The old name ``"sampled"`` is still accepted, with a ``DeprecationWarning``. :param route_cache: 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)``. :param equilibration: 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 share ``1/(i + 1)`` of travellers choose again on those times at iteration ``i``, 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 by ``eta_fell`` after a loading whose disequilibrium fell and by ``eta_rose`` after 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 iteration ``i`` reacts to the loadings up to ``i - 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, step ``1/(k + 1)``; ``"free_flow"``, one all-or-nothing assignment on free-flow times; ``"sra"`` is refused. Each stops at its ``iterations`` or 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 its ``gap_tolerance``; ``convergence()`` has one row per solver iteration (``reselected_share`` the step, ``gap`` the relative gap). At ``msa``'s defaults (10 iterations, a gap of 0.05) the equilibrium is coarse: raise ``iterations`` and lower ``gap_tolerance``, or use ``"frank_wolfe"``. The choice model, ``master_seed``, ``route_method``, ``route_update`` and ``link_values`` shape 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 use ``flow_level``. At ``flow_level=0`` there are no groups, since nothing congests. Either way, equilibration only changes anything when vehicles interact (``flow_level`` 2 to 4, the default 2) and a choice model gives travellers something to choose between (``"logit"``): at ``flow_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, and ``Run.convergence_verdict`` judges the disequilibrium the last iteration ended at. :param equilibration_options: 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) and ``cost_bin_s`` (300: the length of the time bins the link times are read in); for ``"sra"``, all of ``"msa"``'s and ``eta_fell`` (0.2, from 0 to 1: how much η grows after a loading whose disequilibrium fell) and ``eta_rose`` (1.5, from 1 to 10: after one where it rose or stayed); for ``"frank_wolfe"`` (``flow_level=1`` only) ``iterations`` (1000, up to 100 000) and ``gap_tolerance`` (0.0001: stop once the relative gap of the flows is below this; 0 never stops early). For the first three: ``increments`` (5 at ``flow_level`` 2 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) and ``warmup`` (1 at ``flow_level`` 2 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 uses ``flow_level``, while a run of one loading is its free-flow loading. ``"free_flow"`` with ``increments`` 1 and ``warmup`` 0 is a single loading at ``flow_level`` on free-flow choices). :param route_update: 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; or ``route_update_options`` is 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 a ``DeprecationWarning``. It closes the gap that ``Run.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, ``draws`` perturbed searches per origin, departure bin and user class at the congested times, by the class's generalised cost (as ``route_method="doubly_stochastic"`` describes, its coefficients drawn again each iteration) with every link's cost multiplied by ``1 + sigma·u``, ``u`` uniform 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 most ``max_detour`` times 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 a ``DeprecationWarning``. :param route_update_options: 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) and ``max_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) and ``slack`` (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) and ``until_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), and ``draws`` (1: perturbed searches per origin, departure bin and user class each iteration), ``sigma`` (0.5), ``tau`` (0.3), ``max_detour`` (1.5) and ``seed`` (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. :param transit: The timetable of a service day (``openmobisim.transit_read_gtfs``), for the ``"transit"`` trips. A transit trip walks (on the walk layer, at its ``walk_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 by** ``choice_model`` among the competitive ones: for each number of vehicles, the earliest arrival that beats every journey with fewer (the attributes ``walk_min``, ``wait_min``, ``ride_min`` and ``transfers`` say 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). With ``transit_options`` ``buses_on_roads`` 1, **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_summary`` counts them). Rail, metro, trams and ferries run by the schedule. These values are defaults, not a calibration: ``transit_options`` overrides them. :param transit_options: 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. :param parkings: Park-and-ride car parks and bike parkings (``openmobisim.parking_read_osm``, ``openmobisim.parking_read_table``), for the ``"car_transit"`` and ``"bike_transit"`` trips; needs ``transit``. **The parking is chosen by** ``choice_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, and ``parking_min`` says 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. :param services: Shared-mobility services: a docked bike service, ``service_bike_docked(docks, options=...)`` (one per run for now). With ``"bike_share"`` among ``modes``, 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's ``candidates`` (3) docks nearest the origin and the destination within its ``walk_max_s`` (600 s) on foot, the ``candidates`` best pairs; each carries ``dock_min`` (the minutes of extra walk assumed to another dock when the pickup dock is empty or the return dock full, part of ``walk_min``) and ``mode_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"`` among ``modes`` and a ``transit`` timetable, 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 within ``hub_join_m`` of a stop, or naming its ``hub_id``), return the bike there, walk to the stop, ride, walk; the pairs are of the ``candidates`` docks nearest the origin and the hubs' docks within ``parking_options``' ``reach_bike_s`` by bike, as bike-and-ride picks its parkings, each with ``dock_min`` and ``mode_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 with ``has_bike_share`` 0 is offered neither; every other class is offered both, whatever its own ``modes`` list. **A taxi fleet**, ``service_taxi(vehicles, chargers, options=...)`` (one per run, beside a docked bike service or alone): with ``"taxi"`` among ``modes`` a 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 carries ``wait_min`` (the assumed waiting time, ``service_assumptions``' ``assumed_wait_s``, whatever the fleet's cancel limit), ``parking_min`` (the fleet's ``boarding_s``), ``car_min`` (the drive), ``fail_prob`` (the assumed chance of no taxi, ``assumed_no_taxi_share``), ``mode_taxi`` and ``time_min``: its planned time (the three summed). With a chance ``p`` of no taxi above 0, a cancelled request is followed, after the cancel limit ``request_cancel_s``, by the traveller's best other alternative; under the random utility model that is the ride, fare in full, with ``request_cancel_s`` × ``p / (1 − p)`` added to its ``time_min`` and ``wait_min``. Once the run has stopped, the last loading's taxi trips are played on the fleet engine (the built-in matching, the dispatch delay ``dispatch_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 within ``request_cancel_s`` is 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_options`` or every class's) or ``price_options``' ``taxi_eur_per_km`` or ``taxi_eur_per_ride``; it refuses to start without, since a free taxi at the door would take nearly every trip. A class with ``has_taxi`` 0 is never offered one. Without a service, nothing changes. :param parking_options: 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) and ``reach_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) and ``slope_bike_s`` (180: what a parking full for a whole time bin adds to the time to leave the vehicle, ``mode_options`` ``car_egress_s`` and ``bike_egress_s``; fetching it costs ``car_access_s`` or ``bike_access_s``), ``snap_m`` (300), ``bin_s`` (900) and ``pr_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. :param modes: **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 than ``parking_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. With ``choice_model="nested_logit"`` the alternatives of a mode share a nest (``choice_options["mu"]``), and ``beta_mode_`` is a mode's constant (0 by default: time decides). One mode is no choice: such trips take it (``("car",)`` is the run without ``modes``, exactly). ``None`` (the default): such trips are car trips. A walk or a ride is offered only up to ``mode_options``' times (30 minutes' walk, 60 minutes' ride), or the trip's class's (``classes``). :param mode_options: Mode choice's parameters by name, each replacing its default: ``walk_max_s`` (1800) and ``bike_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 by ``Run.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) and ``car_egress_s`` (300): what a car trip takes before its drive (reaching the car) and after it (parking and walking from it), and ``bike_access_s`` (60) and ``bike_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_results`` ``vehicle_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, ``inf`` takes the nearest drivable node of any class. Unknown names and negative values are refused (the limits must be above 0). :param loading_options: The loading's rules by name, for ``flow_level`` 2–4 (gridlock remedies; at ``flow_level`` 2, where nothing waits for room, ``reroute`` is 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 for ``reroute_after_s`` (300) re-routes from where it is, at most ``reroute_max`` (3) times, if the new route is at least ``reroute_min_gain`` (0.1) faster; at ``flow_level`` 2 a vehicle waits so only behind a road closed by a disruption (or narrowed by it when ``node_inflow`` is 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_level`` 2, 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) and ``bpr_beta`` (4), the volume-delay function ``t = t0 · (1 + alpha · (v/c)^beta)`` of every road class (``t0`` the link's free-flow time, ``v`` its hourly flow, ``c`` its hourly capacity), the Bureau of Public Roads' (1964) values that TNTP's benchmark networks use; ``.bpr_alpha`` and ``.bpr_beta`` set 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. :param price_options: What travel costs, in euros, by name: ``car_eur_km`` (the fuel a driver pays per km), ``bike_eur_km``, a transit journey's fare ``fare_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's ``fee_eur`` column 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, which ``classes`` give, 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_eur`` is 0), whatever the fare prices. A toll is a road link value named ``toll_eur`` (``link_values``), paid at each passage. Every alternative carries what it costs: ``cost_eur`` and its parts ``cost_running_eur``, ``cost_toll_eur``, ``cost_parking_eur`` (park-and-ride and bike-and-ride, on the trip that parks) and ``cost_fare_eur``. With a docked bike service (``services``), a shared bike's price is part of its ``cost_fare_eur``: ``bike_share_eur_per_ride`` once and ``bike_share_eur_per_min`` per 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 its ``cost_fare_eur``: ``taxi_eur_per_ride`` once and ``taxi_eur_per_km`` per kilometre driven with the passenger (0 by default; a transit pass does not cover it; a cancelled request pays nothing, so with a chance ``p`` of no taxi the fare counts ``1 − p`` times). The built-in models weigh money by ``beta_cost_eur`` (or a part's coefficient), **-1.2 per euro by default** (0 drops it): a value of time of ``V`` euros per hour is ``beta_cost_eur = beta_time_min * 60 / V``, so -1.2 is 10 €/h at the default -0.2; a class's own ``beta_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. On ``engine="one-loop"`` only the fares: ``fare_base_eur`` once per journey and, per ride, ``fare_km_eur`` per 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. :param link_values: 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 as ``network.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: ``__km``, the sum of the value times each link's length in km (greenery along a route, divided by ``length_km`` for its mean), and ``__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 through ``choice_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's ``link_bins`` (``link_ids()`` ties a bike link to its street's road links). Recorded in the fingerprint, and their names in the manifest. :param person_values: 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 attribute ``person_`` of every alternative of that traveller's choices: income, age, a household's children. :param trip_values: The same per trip: ``{name: values}``, the values one per row of ``demand`` in 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 attribute ``trip_``: a purpose, a time budget. **``parking_eur``** is what parking a car at the trip's destination costs, in euros: it is added to ``cost_parking_eur`` of every alternative that arrives by car (see ``price_options``). Beside them every alternative carries ``trip_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 named ``beta_*`` in ``choice_options`` or 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 (give ``income_inv`` as 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. :param disruptions: 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 from ``from_s`` to ``to_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 by ``delay_s`` at 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 at ``flow_level`` 0. At the point queue (``flow_level`` 2) 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_level`` 3) it backs up across the junctions behind it, as a real one does. :param disruptions_known: 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 (at ``flow_level`` 3 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``). :param zones: The demand's zones, ``{zone_id: (lon, lat)}`` (``Case.zones()``, ``demand_read_zones``) or a path to a ``zones.csv``; read at ``flow_level=1`` only, 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. :param preset: Named settings for speed (``PRESETS``). ``"fast"`` is what the starter cases use: the park-and-ride drives shared by origin and half hour (``parking_options`` ``reach_car_step_s`` 1 800), slightly approximate and faster on a city. ``"complete"`` or ``None`` (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_options`` ``tree_step_s`` 300.) 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()``. .. py:method:: replace(**changes) A new scenario: this one with the arguments in ``changes`` changed. The names are those of ``from_parts``; everything not named stays as it is. This scenario is not changed. For example ``base.replace(flow_level=4)`` or ``base.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. .. py:method:: 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. :param run_id: Recorded in every output row; also names the default output directory. :param output_dir: Where ``kpis.parquet`` etc. are written. Defaults to ``./openmobisim-runs/`` (the command line's default folder), under the current directory. :param quiet: If true, do not print the run's wall-clock time by stage when it ends (``Run.timings()`` and ``timings.csv`` have it either way). :param threads: 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 in ``manifest.json`` (``threads``) and not in the fingerprint. The run uses a pool of its own: ``RAYON_NUM_THREADS`` does not change it. :param overwrite: 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 same ``run_id`` cannot silently replace the first one's files. :param design_id: 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. :param replication: Which replication of its design this run is (``kpis.parquet``'s ``replication``), from 0: runs of one design that differ only in their ``master_seed``. Like ``run_id``, both are labels, not in the fingerprint. :param outputs: 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.csv`` and, as the run has them, the link bins, ``transit_calls.parquet`` and ``parking_bins.parquet``. ``"minimal"``, for mass runs (thousands of scenarios, a design space): ``kpis.csv`` (the rows of ``kpis.parquet``), ``manifest.json`` and ``run.toml`` only, a few tens of kilobytes; the run's results in memory, its fingerprint and ``Run.open`` are the same, and the files it left out are refused by name. No page or figure is ever written by ``run``. :param hub_join_m: How far a parking may be from a stop, in metres in a straight line, to join the stop's hub (``hub_id`` in ``transit_calls`` and ``parking_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). :param service_assumptions: 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_s`` and ``assumed_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, or ``None`` (the default, ``NaN`` also 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()``'s ``service_outcome``). Recorded in the fingerprint and ``manifest.json`` of a run with a service; read only then. :param policy: An operator steering the scenario's services in the run's service day (``openmobisim.operator``), as ``fleet_day(policy=...)`` takes it: a policy object (``step(view)``), a built-in one (``policy_threshold(...)``), a name (built-in or registered with ``policy_register``), or ``None`` (the default): no operator. The day is the one ``fleet_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 and ``manifest.json`` (``service_policy``; a Python policy without ``describe()`` is named ``python:``, and its behaviour is not in the manifest); its decisions in ``Run.operator_decisions()``. Travellers still choose on ``service_assumptions``: an operator changes what the services deliver, not who asks for them. Refused without services. :param policy_options: A named policy's options (``{"low": 0.1}`` for ``"threshold"``). :param config: A run configuration file, ``run.toml`` (its path, or a ``Config`` from ``config_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. :param engine: 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"``: its ``iterations`` (50 by default), ``step_offset`` and ``cost_bin_s``, and the loop's ``min_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) and ``indifference_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), and ``link_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_options`` ``car_access_s`` and ``car_egress_s``, rounded to whole seconds): the car enters the roads ``car_access_s`` after the departure, the trip ends ``car_egress_s`` after the car arrives (a trip ending after the window is ``truncated``), and the choice counts them as walking and parking time (``beta_walk_min`` and ``beta_parking_min``, each on top of ``beta_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 by ``bike_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 pays ``mode_options`` ``bike_access_s`` and ``bike_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 by ``beta_bike_mixed_km`` (−0.16 for the logit, 0 for the deterministic choice, by default), on a painted lane by ``beta_bike_lane_km`` and on a track or path of its own by ``beta_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 within ``mode_options`` ``walk_max_s`` and ``bike_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 scale ``choice_options`` ``mu`` (0.5 by default); ``beta_mode_car``, ``beta_mode_bike``, ``beta_mode_walk`` and ``beta_mode_transit`` are 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"``) and ``mode_choice``, ``vehicle_s`` (the drive or the ride) and ``access_egress_s``; with ``link_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 within ``transit_options`` ``access_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 than ``journey_max_s`` door to door, and one walking more than ``walk_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_roads`` 1 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) by ``beta_walk_min`` and ``beta_wait_min`` on top of ``beta_time_min``, each transfer by ``beta_transfers``, its fare (``price_options``, below) by ``beta_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 and ``transit_lines()`` by line (``transit_lines.parquet``). **Fares** (``price_options``): ``fare_base_eur`` once per journey and, per ride, the price per km of its line's kind of service (``fare_km_eur_rail`` and the other ``TRANSIT_KINDS``, else ``fare_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's ``fare_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, ...) raises ``EngineNotSupportedError`` naming 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 in ``manifest.json`` (``options_not_applied``). The run writes ``trip_results.parquet``, ``convergence.parquet`` (one row per iteration), ``chains.parquet`` (every trip's choice set), ``link_bins.parquet`` (with ``link_bin_s``), ``timings.csv``, ``manifest.json`` and ``run.toml``. :param start_from: 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 its ``chains.parquet``), the link travel times its last loading measured (its current chains loaded once again), and the iteration count it reached (its ``convergence()``), 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``'s ``demand_network_fingerprint``); its other settings may differ. Its fingerprint and iteration count are in this run's fingerprint and ``manifest.json`` (``start_from``), not in ``run.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``. :rtype: A ``Run`` :raises FileExistsError: If ``output_dir`` already holds a run and ``overwrite`` is false. :raises EngineNotSupportedError: If ``engine`` does not have something the scenario asks for. .. py:property:: parts :type: dict[str, Any] a copy. ``Scenario.from_parts(**scenario.parts)`` builds the same scenario again (the same fingerprint); ``replace`` builds 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`` .. py:class:: 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_tolerance`` more. .. attribute:: max_paths count; ``2``. .. attribute:: twin_tolerance —; ``0.001``. .. py:class:: 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, ``draws`` times, the draws biased towards the links likely to congest. .. attribute:: biased 0 or 1; ``1``. .. attribute:: draws count; ``16``. .. attribute:: max_detour —; ``2.0``. .. attribute:: max_overlap —; ``0.9``. .. attribute:: max_paths count; ``10``. .. attribute:: seed count; ``0``. .. attribute:: sigma —; ``4.0``. .. py:class:: 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``. .. attribute:: cost_bin_s s; ``300.0``. .. attribute:: eta_fell —; ``0.2``. .. attribute:: eta_rose —; ``1.5``. .. attribute:: gap_every —; ``0.0``. .. attribute:: gap_sample count; ``300``. .. attribute:: gap_tolerance —; ``0.05``. .. attribute:: increments count; by default ``None``: 1 at flow_level 0 whatever is set. .. attribute:: iterations count; ``15``. .. attribute:: itinerary_gap_sample count; ``100000000``. .. attribute:: route_growth_tolerance —; ``1.0``. .. attribute:: warmup count; ``1``. .. py:class:: 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. .. py:method:: to_arrow() Read this table with pyarrow, as a ``pyarrow.Table``. :raises ImportError: If pyarrow is not installed — install ``openmobisim[all]``. .. py:method:: to_pandas() Read this table with pandas. :raises ImportError: If pandas is not installed — install ``openmobisim[all]``. .. py:method:: to_polars() Read this table with polars. :raises ImportError: If polars is not installed — install ``openmobisim[all]``. .. py:attribute:: path .. py:class:: Transit The timetable of one service day: stops, lines and every run that day. Read one with :func:`transit_read_gtfs`; give it to a ``Scenario`` (``transit=``) for its ``"transit"`` trips. .. py:method:: line_patterns() Every line's stop patterns: ``line`` (into ``lines()``) and ``stops`` (stop indices). .. py:method:: lines() Every line: ``{"route_id", "name", "kind", "runs", "first_s", "last_s"}``. .. py:method:: read_report() What reading the feed found, kept and skipped (``None`` if not read from a feed). .. py:method:: runs_by_kind() Runs by kind of service: ``"bus"``, ``"tram"``, ``"metro"``, ``"rail"``, and so on. .. py:method:: stops() Every stop: ``stop_id`` and ``name`` (lists), ``lon`` and ``lat`` (arrays). .. py:attribute:: call_count :type: int .. py:attribute:: date :type: str .. py:attribute:: route_count :type: int .. py:attribute:: run_count :type: int .. py:attribute:: stop_count :type: int .. py:class:: 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``. .. attribute:: access_walk_max_s s; ``1800.0``. .. attribute:: board_slack_s s; ``60.0``. .. attribute:: bus_dwell_s s; ``0.0``. .. attribute:: bus_pcu PCU; ``2.0``. .. attribute:: bus_plausibility_ratio —; ``1.6``. .. attribute:: bus_stop_snap_m m; ``300.0``. .. attribute:: buses_on_roads 0 or 1; ``0``. .. attribute:: journey_max_s s; ``7200.0``. .. attribute:: max_rides count; ``8``. .. attribute:: stop_transfer_s s; ``0.0``. .. attribute:: stop_walk_snap_m m; ``300.0``. .. attribute:: transfer_walk_max_s s; ``300.0``. .. py:class:: Trip One trip: a row of the demand ``Scenario.from_parts`` takes (``trips.parquet``'s columns). A plain tuple of the same nine or ten fields is the same row; ``Trip`` names them. Times are seconds after midnight, coordinates WGS 84 degrees; ``user_class`` names the traveller's class (one of ``classes``, or any name for the defaults). ``weight`` is how many people the row stands for (``None``: the scenario's ``default_weight``); ``mode`` the stated mode (``None``: a car trip, or with ``modes`` one that chooses). .. py:attribute:: departure_time_s :type: int .. py:attribute:: destination_lat :type: float .. py:attribute:: destination_lon :type: float .. py:attribute:: mode :type: str | None :value: None .. py:attribute:: origin_lat :type: float .. py:attribute:: origin_lon :type: float .. py:attribute:: traveller_id :type: str .. py:attribute:: trip_seq :type: int .. py:attribute:: user_class :type: str .. py:attribute:: weight :type: int | None :value: None .. py:function:: 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) and ``profile`` (str). These are the fields a bug report should quote. :rtype: A dict with keys ``version`` (str), ``git_sha`` (str .. py:function:: 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's ``charger_kw``, 50 by default) and ``hub_id`` (the hub it belongs to). Each is snapped to the road network; one farther than the service's ``snap_m``, or without plugs, is left out. :param source: 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. .. py:function:: 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. :param master_seed: The scenario's master seed. :param traveller: The traveller's id. :param trip: The trip's id. :param iteration: The assignment iteration. :param alternative: The alternative's identity. :returns: A number in ``[0, 1)``. .. py:function:: 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 as ``factory(choice_options)`` (a dict, empty when none are given) and runs it; the scenario keeps the name, so ``replace`` and a plain design can name it. The model is shown in the manifest by its ``name`` (the registered name unless it has its own) and identified in the fingerprint by its ``descriptor``, which should hold every option it read. A name is registered once per session: registering it again replaces the factory. :param name: Letters, digits and underscores, not a built-in model's name. :param factory: 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. .. py:function:: choice_models() The choice models that can be selected by name. The built-in ones (``"deterministic"``, ``"logit"``, ``"nested_logit"``), then those registered with ``choice_model_register``, in the order registered. Which built-in one a ``Scenario`` uses unless told: ``"nested_logit"`` when it offers more than one mode, ``"logit"`` otherwise. .. py:function:: 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. :raises ValueError: If it is not TOML, or a name or value is not valid. .. py:function:: config_write_defaults(path) Write the complete ``run.toml`` at the shipped defaults to ``path``; 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. .. py:function:: 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 ``zones`` and ``grid_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``'s ``points_per_zone=1``) nothing moves; a trip end drawn near the edge of its zone (a ``spread_m``, a ``zone_points`` table) may be nearer a neighbour's point and go there. The static assignment (``flow_level=1``) applies it before it routes, with the scenario's ``zones``, to every trip. **Cost:** one comparison per trip end and zone. **Grid**: square cells of ``grid_m`` metres 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 the ``i``-th ``grid_m`` eastward and the ``j``-th ``grid_m`` northward, 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 ``stats`` measures. A trip whose two ends land on one point is complete at once in a run. Nothing else about a trip changes. :param trips: In any form ``Scenario.from_parts`` takes (rows, columns, a data frame); checked. :param zones: ``{zone_id: (lon, lat)}`` (``Case.zones()``, ``demand_read_zones``) or a path to a ``zones.csv``. :param grid_m: The side of a grid cell, in metres, above 0. :param modes: 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 with ``modes``), keeps its ends. ``None`` moves every trip. By default ``("car",)`` with ``grid_m``, the trips whose route sets a shared point saves the most, and every trip with ``zones``, as the static assignment moves them. :param stats: If ``True``, also return a dict of what the move did (see Returns). :param quiet: 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 ``Trip`` rows, in the order given; with ``stats=True``, ``(rows, stats)``. Over the trips of the modes that move: ``moved``, the trip ends moved; ``kept``, those at their point already; ``moved_m_mean`` and ``moved_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_before`` and ``pairs_after``, the distinct (origin point, destination point) pairs, points compared by their exact coordinates; and ``original``, 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. A ``Trip`` row has no place for them and a run does not write them, so a study joins ``original`` to the run's ``trip_results`` by ``(traveller_id, trip_seq)`` to read where each trip really began and ended. :raises ValueError: If a row is refused (as ``Scenario.from_parts`` refuses it), not exactly one of ``zones`` and ``grid_m`` is given, ``grid_m`` is not a number of metres above 0, a mode is unknown, or a zone's point is not (lon, lat) in degrees. .. py:function:: 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_options`` ``period_s``). Nothing else about a trip changes. :param trips: In any form ``Scenario.from_parts`` takes; checked. :param start: 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 ``Trip`` rows, in the order given. :raises ValueError: If a row is refused, or ``start`` is not a time of day. .. py:function:: 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, ``None`` taken as 1), scaled to sum to one, and are met to within one traveller: the travellers are put in a random order fixed by ``seed`` and 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 the ``user_class`` they had. The same table, classes and ``seed`` always give the same classes, on any machine; another ``seed`` is another draw, for replications. :param trips: Rows in the schema of ``Scenario.from_parts``' ``demand``. :param classes: The classes, as ``demand_read_classes`` returns them (or a dict of the same columns), each with a ``share``. :param seed: Which draw. :returns: The rows, in their original order, with their ``user_class`` replaced. :raises ValueError: If a class has no share, or the shares sum to 0. .. py:function:: 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 ``Scenario`` runs (the deterministic integerisation). 1. **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. 2. **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. 3. **When:** a departure in the row's window (``start_s``–``end_s``, else the arguments'), drawn from ``profile``: ``"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"``). 4. **Where:** the zone's point, moved by a random distance of up to ``spread_m`` metres in a random direction (uniform over the disc), so a zone's trips do not all start at one node; ``spread_m_by_zone`` gives some zones their own (0 for a gateway: a road where the study area's edge cuts it, where trips from outside enter). With ``points_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. With ``zone_points`` (``demand_read_zone_points``'s shape), a zone that has points draws each trip end among them by weight, the origin by ``weight_origin`` and the destination by ``weight_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. :param od: ``od.csv``'s path, or its rows (``demand_read_od``'s shape). :param zones: ``zones.csv``'s path, or ``{zone_id: (lon, lat)}``. :param start_s: The departure window's start for rows without one, seconds after the day's start. :param end_s: Its end. :param profile: ``"uniform"`` or ``"am_peak"``. :param spread_m: How far from its zone's point a trip may start or end, in metres. :param user_class: The class of rows without one. :param seed: Which draws. :param spread_m_by_zone: ``{zone_id: metres}``, the spread of these zones instead of ``spread_m``. The draws are the same either way: only their distance is scaled. :param points_per_zone: Draw each trip end from this many fixed points per zone instead of anywhere in its disc (at least 1; ``None``: anywhere). :param zone_points: ``{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``), weight ``None``. :raises ValueError: For an unknown profile, a window that is empty, a zone the matrix names but ``zones`` does not have, a negative spread, or a zone in ``zone_points`` that ``zones`` does not have or whose points have a negative weight. .. py:function:: demand_read_classes(path) Read a class table (``classes.csv``): one row per traveller class. Columns: ``class`` (its name, as the trips' ``user_class``); optionally ``share`` (the share of the people in the class, for ``demand_assign_classes``), ``modes`` (the modes its travellers may use, separated by ``;``: ``car;bike;walk``; empty: every mode the run offers), ``owns_car``, ``owns_bike`` and ``has_transit_pass`` (``1`` or ``0``; 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 its ``modes``, which govern the ordinary modes only), ``has_taxi`` (likewise for a taxi, in a run with a taxi fleet), any ``beta_*`` 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_s`` and ``access_walk_max_s`` (empty: the run's ``mode_options`` and ``transit_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``, ``betas`` and ``limits``: the shape ``Scenario(classes=...)`` and ``demand_assign_classes`` take. :raises ValueError: If a row has no class, a class repeats, or a column or value is not one of those above. .. py:function:: 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); optional ``start_s`` and ``end_s`` (the departure window, seconds after the day's start), ``user_class`` and ``mode`` (``car``, ``bike``, …; empty: chosen, or car). Returns the rows as dicts with those keys, missing ones ``None``. :raises ValueError: If a row lacks a zone or a number of trips, or the number is negative. .. py:function:: demand_read_trips(path) Read ``trips.csv``: the columns of ``trips.parquet``, as rows ``Scenario`` takes. Columns: ``traveller_id``, ``trip_seq``, ``origin_lon``, ``origin_lat``, ``destination_lon``, ``destination_lat``, ``departure_time_s``, ``user_class``, and optionally ``weight`` and ``mode`` (empty: the default weight; no stated mode). :raises ValueError: If a required column is missing in a row. .. py:function:: 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`` (or ``lon``/``lat``, WGS84 degrees) and the weights ``weight_origin`` and ``weight_destination`` (either may be replaced by ``weight``, 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; see ``demand_from_od``'s ``zone_points``. :raises ValueError: If a row has no id or no point, or a weight is negative or not a number. .. py:function:: demand_read_zones(path) Read ``zones.csv``: each zone's point, ``{zone_id: (lon, lat)}``. Columns: ``zone_id`` and ``x_coord``/``y_coord`` (GMNS's names) or ``lon``/``lat``, in WGS84 degrees. Other columns (a ``name``, a ``boundary``) are not read. :raises ValueError: If a row has no id or no point, or an id repeats. .. py:function:: demand_sample(trips, weight, seed = 0) Keep one traveller in every ``weight``, each standing for ``weight`` times 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 ``seed`` and their id, and every ``weight``-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, ``None`` meaning the scenario's ``default_weight``, taken as 1 here) is multiplied by ``weight``, 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 ``weight`` people who travel and choose together; on the roads it is a platoon of ``weight`` cars, 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, ``weight`` and ``seed`` always keep the same travellers, on any machine; another ``seed`` is another sample, for replications. :param trips: Rows in the schema of ``Scenario.from_parts``' ``demand``. :param weight: People per kept traveller, a whole number of at least 1 (1 keeps everyone). :param seed: Which sample. :returns: The kept rows, in their original order, with their weights multiplied. :raises ValueError: If ``weight`` is not a whole number of at least 1. .. py:function:: demand_write_trips(trips, path) Write trips rows as ``trips.csv`` (the columns of ``trips.parquet``); returns the count. .. py:function:: 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 in ``station_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 a ``capacity`` is left out. :param station_information: ``station_information.json``. :param station_status: ``station_status.json``, for the bikes docked when the day starts: each station's ``num_bikes_available`` (version 2) or ``num_vehicles_available`` (version 3), at most its capacity. Without it, a dock starts at the service's ``start_share`` of 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. .. py:function:: 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's ``start_share`` of 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. :param source: 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_id`` repeats. .. py:function:: equilibration_strategies() The equilibration strategies that can be selected by name, the default first. The default is ``"free_flow"``. .. py:function:: fixed_order_sum_f64(values) Sum ``values`` with the core's fixed-order reduction. :param values: The numbers to add. :returns: The sum, identical on every call with the same input on the same platform, whatever the thread count. .. py:function:: 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 folder ``Run.freeze`` wrote): 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: its ``trip_id`` the trip's index in the run (``Run.trip_results()``'s ``trip``); ``FleetDay.frozen`` holds the day's ``setup.json``. :param network: The road network (its walk and bike layers are made from it). :param services: The services (``service_bike_docked``, ``service_taxi``), names unique. :param trips: One row per trip: ``origin_lon, origin_lat, destination_lon, destination_lat``, ``departure`` (seconds from midnight, or ``"HH:MM"``), and optionally ``trip_id``, ``service`` (a service's name; required with more than one service) and ``weight`` (the people it stands for, 1 by default). A CSV/TSV path or text, or rows as dicts. ``None`` with ``frozen``. :param frozen: A folder ``Run.freeze`` wrote, in place of ``trips`` and ``road_times``. :param window: 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 with ``frozen``). :param road_times: An earlier run's road times (``road_times_read``); ``None``: free flow. :param seed: The day's seed (a policy's draws); ``None``: 0, or a frozen day's (the run's master seed). :param policy: An operator steering the services (``openmobisim.operator``): a policy object (``step(view)``), a built-in one (``policy_threshold(...)``), a name (built-in or registered with ``policy_register``), or ``None``: no operator. :param policy_options: A named policy's options (``{"low": 0.1}`` for ``"threshold"``). :param zone_grid_m: 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. :raises FileNotFoundError: For a ``frozen`` folder without ``setup.json``. :raises Exception: A Python policy's own exception, which stops the day. .. py:function:: 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)``, then ``step(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``), runs ``step_s`` seconds and returns ``(view, reward, terminated, truncated, info)``; at the window's end ``info["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), and ``w_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 ``n`` above 1 the result is a ``FleetVectorEnvironment``: ``n`` days stepped together, in parallel, ``reset(seeds)`` taking one seed per day and ``step`` one list of decisions per day. Seed ``k`` gives the same day there as here. ``observation(view, spec)`` and ``action(vector, spec)`` turn views and decisions into arrays of fixed shapes, for learning methods (``spec`` is described with ``observation``). With ``frozen`` (a folder ``Run.freeze`` wrote), the day is a run's last loading: its legs as the run played them and its road times, in place of trips; ``frozen`` on the environment holds its ``setup.json``. ``legs_keep`` and ``departure_jitter_s`` vary it by seed as they vary a day of trips; with neither, every seed replays the run's day. :param network: The road network. :param services: The services (``service_bike_docked``, ``service_taxi``). :param trips: The trips, as for ``fleet_day``; ``None`` with ``frozen``. :param frozen: A run's frozen day, as for ``fleet_day``. :param window: The day's start and end; ``None``: 07:30 to 09:30, or a frozen day's own. :param road_times: An earlier run's road times, or ``None``: free flow (a frozen day's own with ``frozen``). :param step_s: The seconds between steps. :param reward_weights: Weights by name in place of ``REWARD_WEIGHTS``'; a name not among them is refused with the list. :param legs_keep: The share of the trips' legs each day keeps, drawn by the day's seed (1: all). :param zone_grid_m: The side of the square zones a view groups places by, in metres (``ZONE_GRID_M``, 1 000: an assumption, uncalibrated). :param departure_jitter_s: 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 ``reset`` is another day; both thin and shift the same trips, they do not draw a new demand. :param n: How many days to step together (1: a ``FleetEnvironment``). :raises ValueError: As ``fleet_day``. .. py:function:: 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``). :param network: A road network. :param layers: 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. :rtype: ``{"verdict": "pass" | "warn" | "fail", "checks": [...], "summary": {...}}`` :raises ValueError: If ``network`` is a layer, not a road network. .. py:function:: 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; ``network`` is 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. :param network: The road network (the handle a scenario runs on, not a layer's). :param close: 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). :param lanes: ``{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. :param capacity_factor: ``{road link: factor}``: capacity multiplied, storage kept (a bottleneck), the backward wave speed derived again. Above 0. :param bike_facility: ``{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_h`` or ``bike_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`` …). :param signal_off: ``True`` to 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. 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_off`` neither a bool nor links. .. py:function:: network_options(network = None) Every network parameter by name, at its shipped value, or at `network`'s. The road-class table (``".free_flow_km_h"``, ``".lanes"``, ``".saturation_flow_veh_h_lane"``, ``".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_lane`` 1 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_options`` override them by name. .. py:function:: network_read_cache(path, source = None) Read a road network ``network_write_cache`` wrote: the same network, bit for bit. With its street geometry, its bike and walk layers and the report of its import. Its ``read_s`` is the time this read took. :param path: The file. :param source: If given, what the file must have been written with (``network_write_cache``'s ``source``), so that a network made from other data is never taken for this one. :returns: The :class:`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``. :raises OSError: If the file cannot be read. .. py:function:: network_read_gmns(folder, network_options = None) Read a network from GMNS files. ``folder`` is either one GMNS network (``node.csv``, ``link.csv``, optionally ``config.csv``), read as the road network with its bike and walk layers derived from it, or a folder of ``road/``, ``bike/`` and ``walk/`` GMNS networks as ``network_write_gmns`` writes them, read as the road network and its own layers. See the module docs for the columns read. :param folder: The folder. :param network_options: Network parameters by name, as ``network_read_table`` takes them. :returns: A ``Network``, as ``network_read_osm`` returns one. :raises ValueError: If the folder holds no GMNS network, a ``config.csv`` names units or a coordinate system that is not read, or a table is malformed. .. py:function:: 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.pbf`` extract. :param path: The extract. :param contract: Merge chains of degree-two nodes whose links agree on every parameter (the default; turn it off only to debug an import). :param region: 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. :param connectivity: ``"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 in :meth:`Network.report_import` and drawn from :meth:`Network.report_dropped`. ``"keep"`` imports every road. :param contract_drivable: 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 with ``contract``. :param layers: Also read the bike and walk layers from the same ways (the default): ``network.layer("bike")``, ``network.layer("walk")``. :param network_options: 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. :param region_stubs: With a ``region``: keep each road's first node outside, so the segment that crosses the edge stays. On by default. :param region_buffer_m: 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. :param bus_lanes: 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`` (``designated`` lanes), and their ``:forward`` and ``:backward`` forms; 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's ``lanes`` counts bus lanes with the others, so a car link's bus lanes are taken out of the lanes cars use, never below one (where no ``lanes`` is tagged, out of the class's default), and kept on the link (:meth:`Network.link_bus_lanes`); with buses on the roads (``transit_options`` ``buses_on_roads`` 1), 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:bus`` or ``oneway:psv`` ``no``), 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 lane ``lanes`` counts is the cars'. Right-hand traffic is assumed for the sides. :returns: A :class:`Network` with the defaults table's parameters and the street geometry kept for maps. :raises ValueError: If the file cannot be read, ``region`` or ``connectivity`` is not valid, or the result holds no usable road network. .. py:function:: 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. :param links: 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 example ``df.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``; not ``speed``) or ``free_flow_time`` (``fftt``) — at most one is read, ``free_flow_speed`` first; ``capacity`` (``cap``); ``class`` (``type``, ``link_type``, ``highway``) — a name from ``openmobisim.LINK_CLASSES`` (``"primary"``, ``"residential"``, …; TNTP's numeric ``link_type`` is not one, so it is treated as unrecognised, like an unfamiliar OSM tag, with a diagnostic — pass a ``class`` column 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. :param nodes: A node table in the same two shapes, or ``None`` if `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``/``y`` or ``lon``/``lat`` depending 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 own ``signalised`` says so (a stop line's). :param length_unit: The unit of a `links` ``length`` column: ``"m"`` (the default), ``"km"`` or ``"mi"``. :param speed_unit: The unit of a `links` ``free_flow_speed`` column: ``"km_h"`` (the default) or ``"mi_h"``. :param time_unit: The unit of a `links` ``free_flow_time`` column (read only when ``free_flow_speed`` is absent, and converted to a speed using ``length`` — 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"``. :param coordinates: What a `nodes` table's position columns are: ``"lonlat"`` (the default — real-world ``lon``/``lat`` degrees, 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). :param coordinate_scale_m: Metres per unit of a `nodes` table's ``x``/``y``, under ``coordinates="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. :param layout_spacing_m: Grid spacing for the coordinate-free fallback layout (`nodes` is ``None`` and `links` carries no coordinates). :param network_options: 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 as ``network_read_osm`` or ``examples.manhattan_grid`` return one — usable by a ``Scenario``, `report_connectivity`, and every ``openmobisim.viz`` figure. :raises FileNotFoundError: If `links` or `nodes` is a string without a line break (a path) and no such file exists. :raises ValueError: If `links` has no usable rows, a row's ``from``/``to`` is 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 failures ``network_read_osm`` can raise). .. rubric:: Example Sioux Falls, from its published TNTP files (``sioux_falls_net.tntp``, tab-separated, lengths in miles, times in minutes; a node file with arbitrary ``x``/``y``):: net = network_read_table( "data/sioux_falls_net.tntp", "data/sioux_falls_node.tntp", length_unit="mi", coordinates="xy", ) .. py:function:: 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 :func:`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. :param network: The road network's handle (not a layer's: the road network holds its layers). :param path: The file to write. :param source: What the network was made from (a checksum of its files and reading options, say), kept in the file for :func:`network_read_cache` to compare. :raises ValueError: For a bike or walk layer's handle. :raises OSError: If the file cannot be written. .. py:function:: network_write_gmns(network, folder, *, layers = True, geometry = True) Write ``network`` as GMNS files: ``road/``, and ``bike/`` and ``walk/`` with ``layers``. 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. :param network: The road network (a handle from ``network_read_osm``, ``network_read_table``, ``network_read_gmns`` or ``examples``). :param folder: Where to write; made if missing. :param layers: Also write the bike and walk layers. :param geometry: Write each link's polyline. :returns: Links written per layer. .. py:function:: notebooks(folder = FOLDER, *, overwrite = False) Copy the tutorial notebooks into ``folder`` and say where the first one is. Ten notebooks, ``00_getting_started.ipynb`` to ``09_applications.ipynb``, without their outputs (run them to see them; the repository has them run). A notebook already in ``folder`` is kept, with your changes, unless ``overwrite``. Open the first in JupyterLab (``jupyter lab`` in that folder, or ``openmobisim notebooks`` in a terminal does it) or in your editor. :param folder: Where to put them, ``openmobisim-notebooks`` in the current folder by default. :param overwrite: 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``. .. py:function:: parameters() Every parameter openmobisim assumes, at the defaults a ``Scenario`` uses. Columns by name, one row per parameter: ``group`` (``network``, ``loading``, ``modes``, ``transit``, ``parking``, ``prices``, ``scenario``, ``equilibration.``, ``route_method.``, ``route_update.``, ``choice_model.``, ``bike_route.doubly_stochastic``, ``service.bike_docked`` and ``service.taxi`` (a service's ``options``), ``service_prices`` (``price_options``), ``service_assumptions`` and ``policy.`` (``Scenario.run``'s), ``fleet_environment`` and ``fleet``), ``argument`` (what overrides it by name: ``network_options`` of a network reader, ``loading_options``, ``equilibration_options`` … of ``Scenario.from_parts``, ``options`` of ``service_bike_docked`` or ``service_taxi``, ``policy_options``, ``reward_weights`` of ``fleet_environment``, or the argument itself for the ``scenario`` group), ``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) and ``source`` (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, with ``to_pandas()`` …). .. py:function:: parking_read_cache(path, source = None) Read parkings ``parking_write_cache`` wrote: the same parkings, bit for bit. With the report of the read that found them. Their ``read_s`` is the time this read took. :param path: The file. :param source: If given, what the file must have been written with (``parking_write_cache``'s ``source``), so that parkings made from other data are never taken for these. :returns: The :class:`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``. :raises OSError: If the file cannot be read. .. py:function:: 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_ride`` other than ``no``, or a name that says so); every bike parking is kept; private ones are not. A capacity comes from the ``capacity`` tag, else from the area (``area_per_*``), else the default for a point (``capacity_*``). Parkings of one vehicle closer than ``merge_m`` are 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. .. py:function:: 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 as ``cost_parking_eur``; empty: the scenario's ``price_options`` ``parking_car_eur`` or ``parking_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``'s ``parking_options``). :param source: 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. :raises ValueError: If a required column is missing, a value is not valid, or a ``parking_id`` repeats. .. py:function:: 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 :func:`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. :param parkings: The parkings. :param path: The file to write. :param source: What the parkings were made from (a checksum of the extract and the reading options, say), kept in the file for :func:`parking_read_cache` to compare. :raises OSError: If the file cannot be written. .. py:function:: 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 as ``factory(policy_options)`` (a dict, empty when none are given). A name is registered once per session: registering it again replaces the factory. :param name: Letters, digits and underscores, not a built-in policy's name. :param factory: 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. .. py:function:: 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. :param link_bins: The path of a run's ``link_bins.parquet``. :raises ImportError: Without pyarrow — install ``openmobisim[all]``. .. py:function:: route_cache_clear() Forget every route set the cache holds (the counters of :func:`route_cache_info` stay). .. py:function:: route_cache_info() What the route-set cache has done: ``(hits, misses, sets held)``. .. py:function:: route_methods() The route-set methods that can be selected, the default (``"penalty"``) first. .. py:function:: route_sets_build(network, od_lonlat, method = 'penalty', options = None) Make route sets for origin-destination pairs given as coordinates. :param network: The network to route on. :param od_lonlat: 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. :param method: A name from :func:`route_methods`. :param options: 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) and ``biased`` (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. .. py:function:: route_update_methods() The route updates that can be selected by name, the default (``"none"``) first. .. py:function:: service_bike_docked(docks, *, name = 'bike_share', options = None) A docked bike-sharing service: bikes counted per dock. :param docks: Its docks (``dock_read_table`` or ``dock_read_gbfs``). :param name: Its name, unique among a day's services. :param options: 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``, and ``log_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 read ``candidates`` or ``fail_s``. .. py:function:: service_taxi(vehicles, chargers = None, *, name = 'taxi', options = None) An electric taxi fleet: vehicles tracked one by one, with a battery. :param vehicles: Its vehicles (``vehicle_read_table``). :param chargers: Its chargers (``charger_read_table``), or ``None``: its vehicles never charge. :param name: Its name, unique among a day's services. :param options: 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``, and ``log_events``: 1 by default, 0 to keep no event log in a very large run, ``taxi_events.parquet`` then 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 within ``request_cancel_s``; a ``dispatch_delay_s`` at or above ``request_cancel_s`` is refused. ``boarding_s`` (60 s, an assumption): the time to get in at the pickup. .. py:function:: step_of(origin_second, step_seconds, window_seconds, second) Return the loading step containing ``second``. :param origin_second: The scenario origin, in seconds. :param step_seconds: The loading step length, in seconds. :param window_seconds: The window length; must be a whole number of steps. :param second: 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. .. py:function:: transit_edit(transit, *, cancel = None, headway = None) The same service day with a scenario's changes made. :param transit: The timetable (``transit_read_gtfs``). :param cancel: Lines that do not run that day (a whole line out of service). Everyone knows in advance: passengers plan without them. :param headway: ``{line: seconds}`` to run a line every so many seconds through its day (from its first departure to its last, ``lines()``' ``first_s`` and ``last_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 every ``seconds`` from 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 ``