The Rust crates#
The simulator’s core is twelve Rust crates in one workspace (crates/ in the repository). You do not need them to use
openmobisim from Python. This page is for readers who want to know where something is computed, or to extend the core.
How they fit together is in How a run works; the graph below, drawn from the crates’ own
Cargo.toml at every build, shows which crate uses which (an arrow points from a crate to one it depends on, without
the arrows another path already implies).
Each crate’s API, every public type and function, is documented in its doc comments. Build it locally with
cargo doc --workspace --no-deps --open from a clone of the repository.
What each crate holds#
Crate |
Modules |
What they hold |
|---|---|---|
|
|
Dense integer identities with a null value; the clock in whole seconds and the loading’s time grid; SI units as types; parallel sums in a fixed order; random draws addressed by identity; run diagnostics; registries of named methods; the FNV-1a hash |
|
|
The road network (built once, then never changed); the table that turns OpenStreetMap tags into traffic parameters; the walk and bike layers; hubs and their transfers; turns; connectivity checks; projection to metres; street shapes; the test networks |
|
|
Reading and checking trips and persons; travellers and their trips in sorted arrays; a trip’s mode; who owns which vehicle and where it is |
|
|
Turn-aware shortest-path search; the route-set methods; the route-set store; each route’s length and path size; the nearest node to a point; bounded searches from a point |
|
|
A batch of choice situations with their alternatives and attributes; the choice-model interface and its registry; the built-in models |
|
|
Vehicles; the free-flow loading; the link transmission model (levels 2–4); cumulative counts per link; the node model; per-link results by time bin |
|
|
A day’s stops, routes, runs and calls; RAPTOR; the kind of service and whether it uses the roads; service days; the transit defaults; the test timetables |
|
|
The run and everything it brings together |
|
|
Reading OpenStreetMap: elements, cutting a study area, interpreting tags, building the network, parkings |
|
|
Reading a GTFS feed (a zip or a folder) into one day’s timetable |
|
|
Writing the output files |
|
— |
The Python module |
Extending the core#
The methods selected by name in a Scenario are entries in registries. A new method is a Rust type that implements the
interface, added to the registry; the run, the fingerprint, the manifest and the Python interface need no other
change. This means building openmobisim from source.
To add |
Implement |
In |
Built in today |
|---|---|---|---|
A choice model |
|
|
|
A route-set method |
|
|
|
An equilibration strategy |
|
|
|
A route update |
|
|
|
A source of OpenStreetMap data |
|
|
the |
A choice model can also be written in Python, without building anything; see Choice.
Rules the code follows#
Three rules keep the core repeatable and lean; a contribution follows them:
Parallel sums go through
core-types’ fixed-order reductions, never a plain parallelsum().Stored arrays of identities use each identity type’s null value, never
Option, which would double their size.Units are converted once, where a scenario is built (capacities arrive in vehicles per hour), never inside a loop.
Methods selected by name are also looked up once, when a run is built, never inside a loop.