Crate sim

Source
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)

Re-exportsΒ§

pub use self::prebake::PrebakeSummary;

ModulesΒ§

analytics πŸ”’
events πŸ”’
make πŸ”’
Everything needed to setup a simulation.
mechanics πŸ”’
pandemic πŸ”’
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.
prebake
recorder πŸ”’
render πŸ”’
Intermediate structures so that sim and game crates don’t have a cyclic dependency.
router πŸ”’
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.
scheduler πŸ”’
sim πŸ”’
transit πŸ”’
trips πŸ”’

StructsΒ§

AgentProperties
Analytics
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.
BorderSpawnOverTime
CarID
CommutersVehiclesCounts
The number of active vehicles and commuters, broken into different categories.
CreateCar πŸ”’
CreatePedestrian πŸ”’
DistanceInterval πŸ”’
DrawCarInput
DrawPedCrowdInput
DrawPedestrianInput
ParkedCar
PedestrianID
Person
PersonID
ScenarioGenerator
SidewalkSpot πŸ”’
Sim
The Sim ties together all the pieces of the simulation. Its main property is the current time.
SimFlags
SimFlags specifies a simulation to setup. After parsing from structopt, you must call initialize.
SimOptions
Options controlling the traffic simulation.
SlidingWindow
A sliding window, used to count something over time
SpawnOverTime
TimeInterval πŸ”’
TripID
TripInfo
TripPhase
UnzoomedAgent
Vehicle
VehicleSpec

EnumsΒ§

AgentID
AgentType
AlertHandler
AlertLocation
CarStatus
DelayCause
Why is an agent delayed? If there are multiple reasons, arbitrarily pick one – ie, somebody could be blocked by two conflicting turns.
DrivingGoal πŸ”’
Intent
Shows an agent’s current inner intention or thoughts.
ParkingSpot
PedCrowdLocation
PersonState
Problem
ProblemType
SidewalkPOI πŸ”’
Point of interest, that is
TripPhaseType
TripResult
VehicleType

ConstantsΒ§

BIKE_LENGTH πŸ”’
BUS_LENGTH πŸ”’
FOLLOWING_DISTANCE πŸ”’
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.
LIGHT_RAIL_LENGTH πŸ”’
MAX_CAR_LENGTH πŸ”’
MIN_CAR_LENGTH πŸ”’
SPAWN_DIST πŸ”’
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Β§

SimCallback

FunctionsΒ§

count_parked_cars_per_bldg
fork_rng
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.
pedestrian_body_radius
rand_dist