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#
A run's parameters, as a |
Functions#
|
Read a |
|
Write the complete |
Module Contents#
- class openmobisim.config.Config#
A run’s parameters, as a
run.tomlstates them (config_read) or a run was given.valuesholds what is stated, by table (values["choice"]["beta_time_min"]; a service’s undervalues["services"][name]); every parameter not stated keeps its default.write(path)writes the complete file,text()returns it,differences()lists what differs from the defaults,scenario()reads its[inputs]into aScenarioandrun()runs it.- differences()#
The stated parameters that differ from their defaults, as
table.key.A service or a policy is listed as a whole (
services.taxi,policy); the inputs are not parameters.- Return type:
list[str]
- classmethod from_arguments(run_id=None, **arguments)#
The configuration of a run with these arguments, to write as a file.
The keyword arguments of
Scenario.from_partsandScenario.runthat are parameters (numbers, names, lists of modes, options dicts, services, a policy by name or a built-in one), andnetwork_options;run_idis the file’sname. What a file cannot hold (link values, disruptions, a Python choice model or policy) is listed inabsentand the file’s header.- Raises:
TypeError – For an argument that is not one of these, with the list of them.
- Parameters:
run_id (str | None)
arguments (Any)
- Return type:
- inputs()#
The
[inputs]table’s paths, resolved against the file’s folder (dates as given).- Return type:
dict[str, Any]
- run(output_dir=None, *, overwrite=False, quiet=False)#
Run the file:
scenario(), thenScenario.run(config=self).- Parameters:
output_dir (str | None)
overwrite (bool)
quiet (bool)
- Return type:
openmobisim.run.Run
- scenario()#
A
Scenarioof the file’s[inputs](read by the package’s readers) and values.networkis read by its kind: a starter case’s folder (itscase.json), a GMNS folder, an OpenStreetMap.osm.pbf(both with the file’s[network]) or a filenetwork_write_cachewrote;demand(required),personsandzonesare given toScenario.from_partsas paths;classesbydemand_read_classes;transitbytransit_read_gtfs(ontransit_date);parkingsbyparking_read_table(a.csv),parking_read_osm(a.pbf) orparking_read_cache; a service’s tables bydock_read_table,vehicle_read_tableandcharger_read_table.- Raises:
ValueError – If
networkordemandis missing, or a value is not valid.- Return type:
openmobisim.scenario.Scenario
- text()#
The complete file: every parameter, stated or at its default, with its comment.
- Return type:
str
- write(path)#
Write the complete file to
pathand return the path.- Parameters:
path (str | pathlib.Path)
- Return type:
pathlib.Path
- absent: list[str] = []#
- folder: pathlib.Path | None = None#
- name: str | None = None#
- resolved: dict[str, Any]#
- values: dict[str, Any]#
- 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:
- openmobisim.config.config_write_defaults(path)#
Write the complete
run.tomlat the shipped defaults topath; return the path.Every parameter on its line, its comment giving its default, its meaning and its unit; the inputs, a service and a policy (none by default) as comments to fill in.
- Parameters:
path (str | pathlib.Path)
- Return type:
pathlib.Path