openmobisim.config#

The run configuration file, run.toml: every parameter of a run in one file.

config_write_defaults(path) writes the complete file at the shipped defaults (openmobisim config --defaults prints it): every parameter on its own line, its comment giving the default, the meaning and the unit. Change what you want; a line left out keeps its default, so a file holding a few lines is valid. config_read(path) reads a file back as a Config; Scenario.run(config="run.toml") and openmobisim run --config run.toml run one. Every run writes the complete file it ran with, run.toml, beside its manifest.json (Run.config() reads it back), so a run is repeated from its folder. Nothing is read unless a file is given.

The tables, in the order a run is read: [inputs] (paths, relative to the file), [run], [equilibration], [choice], [modes], [prices], [services.<name>] (a service’s kind, its tables as paths, its options), [service_assumptions], [policy], [network] (applied when the network is read), [loading], [routes], [route_update], [transit] and [parking]. A method’s name and its options share a table: [equilibration] holds method = "msa" and the method’s options. The defaults are those of parameters(), read from the core’s defaults table, so the file and the code cannot disagree.

Classes#

Config

A run's parameters, as a run.toml states them (config_read) or a run was given.

Functions#

config_read(path)

Read a run.toml: what it states, every name and value checked.

config_write_defaults(path)

Write the complete run.toml at the shipped defaults to path; return the path.

Module Contents#

class openmobisim.config.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.

differences()#

The stated parameters that differ from their defaults, as table.key.

A service or a policy is listed as a whole (services.taxi, policy); the inputs are not parameters.

Return type:

list[str]

classmethod from_arguments(run_id=None, **arguments)#

The configuration of a run with these arguments, to write as a file.

The keyword arguments of Scenario.from_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.

Parameters:
  • run_id (str | None)

  • arguments (Any)

Return type:

Config

inputs()#

The [inputs] table’s paths, resolved against the file’s folder (dates as given).

Return type:

dict[str, Any]

run(output_dir=None, *, overwrite=False, quiet=False)#

Run the file: scenario(), then Scenario.run(config=self).

Parameters:
  • output_dir (str | None)

  • overwrite (bool)

  • quiet (bool)

Return type:

openmobisim.run.Run

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.

Return type:

openmobisim.scenario.Scenario

text()#

The complete file: every parameter, stated or at its default, with its comment.

Return type:

str

write(path)#

Write the complete file to path and return the path.

Parameters:

path (str | pathlib.Path)

Return type:

pathlib.Path

absent: list[str] = []#
folder: pathlib.Path | None = None#
name: str | None = None#
resolved: dict[str, Any]#
values: dict[str, Any]#
openmobisim.config.config_read(path)#

Read a run.toml: what it states, every name and value checked.

Relative paths ([inputs], a service’s tables) are resolved against the file’s folder when used. A table or a name not in the file’s layout is refused with the list of its table’s names, a value of the wrong kind with what it should be.

Raises:
  • FileNotFoundError – If there is no such file.

  • ValueError – If it is not TOML, or a name or value is not valid.

Parameters:

path (str | pathlib.Path)

Return type:

Config

openmobisim.config.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.

Parameters:

path (str | pathlib.Path)

Return type:

pathlib.Path