Crate sim[][src]

Expand description

The sim crate runs a traffic simulation on top of the map_model. See also https://a-b-street.github.io/docs/tech/trafficsim/index.html.

The simulation is very roughly layered into two pieces: the low-level “mechanics” of simulating individual agents over time, and higher-level systems like TripManager and TransitSimState that glue together individual goals executed by the agents.

Helpful terminology:

  • sov = single occupancy vehicle, a car with just a driver and no passengers. (Car passengers are not currently modelled)

Modules

Everything needed to setup a simulation. https://a-b-street.github.io/docs/tech/trafficsim/travel_demand.html for context.

An experimental SEIR model by https://github.com/omalaspinas/ glued to the traffic simulation. Transmission may occur when people spend time in shared spaces like buildings, bus stops, and buses.

Intermediate structures so that sim and game crates don’t have a cyclic dependency.

For vehicles only, not pedestrians. Follows a Path from map_model, but can opportunistically lane-change to avoid a slow lane, can can handle re-planning to look for available parking.

Structs

As a simulation runs, different pieces emit Events. The Analytics object listens to these, organizing and storing some information from them. The UI queries Analytics to draw time-series and display statistics.

The number of active vehicles and commuters, broken into different categories.

Lists all border intersections of the map, broken down by mode and whether they support incoming or outgoing traffic.

A Scenario describes all the input to a simulation. Usually a scenario covers one day.

The Sim ties together all the pieces of the simulation. Its main property is the current time.

SimFlags specifies a simulation to setup.

Options controlling the traffic simulation.

A sliding window, used to count something over time

Enums

Why is an agent delayed? If there are multiple reasons, arbitrarily pick one – ie, somebody could be blocked by two conflicting turns.

Shows an agent’s current inner intention or thoughts.

Transforms an existing Scenario before instantiating it.

Point of interest, that is

Specifies where a trip begins or ends.

Lifted from Seattle’s Soundcast model, but seems general enough to use anyhere.

Constants

At all speeds (including at rest), cars must be at least this far apart, measured from front of one car to the back of the other.

When spawning at borders, start the front of the vehicle this far along and gradually appear. Getting too close to EPSILON_DIST can lead to get_draw_car having no geometry at all.

Traits

Functions

Need to explain this trick – basically keeps consistency between two different simulations when each one might make slightly different sequences of calls to the RNG.