Struct sim::Sim

source · []
pub struct Sim {
Show 17 fields driving: DrivingSimState, parking: ParkingSimState, walking: WalkingSimState, intersections: IntersectionSimState, transit: TransitSimState, trips: TripManager, pandemic: Option<PandemicModel>, scheduler: Scheduler, time: Time, pub(crate) map_name: MapName, pub(crate) edits_name: String, run_name: String, step_count: usize, highlighted_people: Option<BTreeSet<PersonID>>, analytics: Analytics, recorder: Option<TrafficRecorder>, alerts: AlertHandler,
}
Expand description

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

Fields

driving: DrivingSimStateparking: ParkingSimStatewalking: WalkingSimStateintersections: IntersectionSimStatetransit: TransitSimStatetrips: TripManagerpandemic: Option<PandemicModel>scheduler: Schedulertime: Timemap_name: MapNameedits_name: Stringrun_name: Stringstep_count: usizehighlighted_people: Option<BTreeSet<PersonID>>analytics: Analyticsrecorder: Option<TrafficRecorder>alerts: AlertHandler

Implementations

(number of finished trips, number of unfinished trips)

(total number of people, just in buildings, just off map)

Return a short string to debug a car in the UI.

Only call for active agents, will panic otherwise

If trip is finished, returns (total time, total waiting time, total distance)

For every parked car, (position of parking spot, position of owner)

For every agent that’s currently not moving, figure out how long they’ve been waiting and why they’re blocked.

(bus, stop index it’s coming from, percent to next stop, location)

For intersections with an agent waiting beyond some threshold, return when they started waiting. Sorted by earliest waiting (likely the root cause of gridlock).

(number of vehicles in the lane, penalty if a bike or other slow vehicle is present)

Returns the best-case time for a trip in a world with no traffic or intersection delays. Might fail in some cases where the real trip succeeds, but the single-mode path can’t be found. Assumes the TripID exists.

Returns people / m^2. Roads have up to two sidewalks and intersections have many crossings – take the max density along any one.

This does not include transit riders. Some callers need those in addition, but the rendering ones don’t.

If retry_if_no_room is false, any vehicles that fail to spawn because of something else in the way will just wind up as cancelled trips.

(Filled, available)

Respond to arbitrary map edits without resetting the simulation. Returns the number of (trips cancelled, parked cars displaced).

Returns (trips affected, number of parked cars displaced)

Only one at a time supported.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.