aequilibrae.project#
Classes
|
Small utility class to manage, validate, and apply a set of |
|
|
|
Global parameters module. |
- class aequilibrae.project.MigrationManager(migration_file: Path, database: str | None = None)[source]#
Small utility class to manage, validate, and apply a set of
Migrations.- Arguments:
migration_file (
pathlib.Path): A path to a Python file which defines a globalmigrationsvariable as a list ofpathlib.Pathobjects.database (
str, optional): Name of the closure connection that owns themigrationstable. Defaults to'transit'when the migration file lives under a transit directory and'project'otherwise.
- find_applicable(closure: ConnectionClosure)[source]#
Find all applicable migrations.
A migration is applicable if all migrations before it (ordered by ID) have been applied or skipped.
If an out-of-order migration is detected a
RuntimeErrorwill be raised and manual intervention will be required.- Arguments:
closure (
ConnectionClosure): The scenario’s connection closure.
- mark_all_as_seen(closure: ConnectionClosure)[source]#
Mark all migrations as ‘seen’.
Marking a migration as ‘seen’ will add it to the
migrationstable asMISSINGif it is not already present. If it is present no change is made.- Arguments:
closure (
ConnectionClosure): The scenario’s connection closure.
- status(closure: ConnectionClosure) dict[int, MigrationStatus][source]#
Query the database for all migrations’ status.
If the
migrationstable is not present all migrations are consideredMISSING.- Arguments:
closure (
ConnectionClosure): The scenario’s connection closure.- Returns:
status (
dict[int, MigrationStatus]): Migration status enums by their ID.
- upgrade(closure: ConnectionClosure, skip: set[int] | None = None)[source]#
Find and apply all applicable migrations in one closure-owned transaction.
Optionally skip some migrations. Take care when skipping migrations.
- Arguments:
closure (
ConnectionClosure): The scenario’s connection closure.skip (
set[int]): Set of migration IDs to skip.
- network_migration_file: Path = PosixPath('/home/runner/work/aequilibrae/aequilibrae/build-install/usr/lib/python3.11/site-packages/aequilibrae/project/database_specification/network/migrations/migrations.py')#
- transit_migration_file: Path = PosixPath('/home/runner/work/aequilibrae/aequilibrae/build-install/usr/lib/python3.11/site-packages/aequilibrae/project/database_specification/transit/migrations/migrations.py')#
- class aequilibrae.project.NetworkSimplifier(project: Project | None = None)[source]#
- collapse_links_into_nodes(links: List[int])[source]#
Collapses links into nodes, adjusting the network in the neighbourhood.
- Arguments:
links (
List[int]): List containing link IDs to be collapsed.
- simplify(graph: Graph, max_speed_ratio: float = 1.1)[source]#
Simplifies the network by merging links that are shorter than a given threshold
- Arguments:
graph (
Graph): AequilibraE graph. Prepared graphs must use compact topology.max_speed_ratio (
float, Optional): Maximum ratio between the fastest and slowest speed for a link to be considered for simplification.
- signal = <aequilibrae.utils.python_signal.PythonSignal object>#
- class aequilibrae.project.Parameters(path: PathLike | str | None = None)[source]#
Global parameters module.
Parameters are used in many procedures, and are often defined in the
parameters.ymlfile ONLY.Parameters are organised in the following groups:
assignment
distribution
network * links * modes * nodes * osm * gmns
osm
system
Please observe that OSM information handled on network is not the same on the OSM group.
>>> from aequilibrae.project import Parameters >>> project = Project.create(project_path) >>> p = project.project_parameters >>> p.parameters['system']['logging_directory'] = "/path_to/other_logging_directory" >>> p.parameters['osm']['overpass_endpoint'] = "http://192.168.0.110:32780/api" >>> p.parameters['osm']['timeout'] = 180 >>> p.write_back() >>> # You can also restore the software default values >>> p.restore_default() >>> project.close()
- get_vdfs(exclude_builtins: bool = False, function_map: dict[str, tuple[Callable, Callable]] | None = None)[source]#
Gets Volume Delay Functions (VDFs) specified in the parameters “vdfs” entry, as well as preset VDFs if exclude_builtins is False.
Each entry in the “vdfs” entry of the parameters must either be specifying a default vdf, or either a preset function via “function” or a custom functional form “functional_form”. If “function” is specified, the name of a preset VDF or VDF in function_map must be specified, with an optional “spec” dict overriding the preset’s default parameters. If “functional_form” is specified with a string representation of the VDF (to be interpreted by NumExpr), the specification is required in “spec” and its derivative can be optionally included by its string representation in “derivative_functional_form”. If a derivative of a custom VDF is not specified, it will use a finite difference scheme to calculate the derivative.
- Arguments:
exclude_builtins (
bool, Optional): Setting to exclude the built in preset VDFs, for example bpr. Defaults to False, so presets are included function_map (dict[str, tuple[Callable, Callable]], Optional): mapping of user supplied function names to (function, derivative) tuples, taking precedence over preset vdf definitions. Then the parameters can reference these functions by their name and spec in the “function” entry.- Returns:
results (
dict[str, VDF]): mapping of VDF names to their constructed VDF objects.- Raises:
ValueError: if a “function” entry references a preset not found in function_map or a built in preset, if a “spec” contains keys not present in the preset’s default spec, or if an entry defines neither “function” nor “functional_form”.
- write_back() None[source]#
Write the parameters back to file.
- Raises:
ValueError – If no project folder was supplied.
- file_default: Path = PosixPath('/home/runner/work/aequilibrae/aequilibrae/build-install/usr/lib/python3.11/site-packages/aequilibrae/parameters.yml')#