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: DrivingSimState
parking: ParkingSimState
walking: WalkingSimState
intersections: IntersectionSimState
transit: TransitSimState
trips: TripManager
pandemic: Option<PandemicModel>
scheduler: Scheduler
time: Time
map_name: MapName
edits_name: String
run_name: String
step_count: usize
highlighted_people: Option<BTreeSet<PersonID>>
analytics: Analytics
recorder: Option<TrafficRecorder>
alerts: AlertHandler
Implementations
sourceimpl Sim
impl Sim
pub fn time(&self) -> Time
pub fn is_done(&self) -> bool
pub fn is_empty(&self) -> bool
sourcepub fn num_trips(&self) -> (usize, usize)
pub fn num_trips(&self) -> (usize, usize)
(number of finished trips, number of unfinished trips)
pub fn num_agents(&self) -> Counter<AgentType>
pub fn num_commuters_vehicles(&self) -> CommutersVehiclesCounts
sourcepub fn num_ppl(&self) -> (usize, usize, usize)
pub fn num_ppl(&self) -> (usize, usize, usize)
(total number of people, just in buildings, just off map)
pub fn debug_ped(&self, id: PedestrianID)
pub fn debug_car(&self, id: CarID)
sourcepub fn debug_car_ui(&self, id: CarID) -> String
pub fn debug_car_ui(&self, id: CarID) -> String
Return a short string to debug a car in the UI.
pub fn debug_agent_json(&self, id: AgentID) -> String
pub fn debug_intersection_json(&self, id: IntersectionID, map: &Map) -> String
pub fn debug_lane(&self, id: LaneID)
sourcepub fn agent_properties(&self, map: &Map, id: AgentID) -> AgentProperties
pub fn agent_properties(&self, map: &Map, id: AgentID) -> AgentProperties
Only call for active agents, will panic otherwise
pub fn num_transit_passengers(&self, car: CarID) -> usize
pub fn bus_route_id(&self, maybe_bus: CarID) -> Option<TransitRouteID>
pub fn active_agents(&self) -> Vec<AgentID>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn num_active_agents(&self) -> usize
pub fn agent_to_trip(&self, id: AgentID) -> Option<TripID>
pub fn trip_to_agent(&self, id: TripID) -> TripResult<AgentID>
pub fn trip_info(&self, id: TripID) -> TripInfo
pub fn all_trip_info(&self) -> Vec<(TripID, TripInfo)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn finished_trip_details(
&self,
id: TripID
) -> Option<(Duration, Duration, Distance)>
pub fn finished_trip_details(
&self,
id: TripID
) -> Option<(Duration, Duration, Distance)>
If trip is finished, returns (total time, total waiting time, total distance)
pub fn trip_blocked_time(&self, id: TripID) -> Duration
pub fn trip_to_person(&self, id: TripID) -> Option<PersonID>
pub fn agent_to_person(&self, id: AgentID) -> Option<PersonID>
pub fn person_to_agent(&self, id: PersonID) -> Option<AgentID>
pub fn get_owner_of_car(&self, id: CarID) -> Option<PersonID>
pub fn lookup_parked_car(&self, id: CarID) -> Option<&ParkedCar>
sourcepub fn all_parked_car_positions(&self, map: &Map) -> Vec<(Position, Position)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn all_parked_car_positions(&self, map: &Map) -> Vec<(Position, Position)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
For every parked car, (position of parking spot, position of owner)
pub fn lookup_person(&self, id: PersonID) -> Option<&Person>
pub fn get_person(&self, id: PersonID) -> &Person
pub fn find_person_by_orig_id(&self, id: OrigPersonID) -> Option<PersonID>
pub fn get_all_people(&self) -> &Vec<Person>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn lookup_car_id(&self, idx: usize) -> Option<CarID>
pub fn get_path(&self, id: AgentID) -> Option<&Path>
pub fn get_all_driving_paths(&self) -> Vec<&Path>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn trace_route(&self, id: AgentID, map: &Map) -> Option<PolyLine>
pub fn get_canonical_pt_per_trip(
&self,
trip: TripID,
map: &Map
) -> TripResult<Pt2D>
pub fn get_canonical_pt_per_person(&self, p: PersonID, map: &Map) -> Option<Pt2D>
pub fn canonical_pt_for_agent(&self, id: AgentID, map: &Map) -> Option<Pt2D>
pub fn get_accepted_agents(&self, id: IntersectionID) -> Vec<(AgentID, TurnID)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_waiting_agents(
&self,
id: IntersectionID
) -> Vec<(AgentID, TurnID, Time)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn get_blocked_by_graph(
&self,
map: &Map
) -> BTreeMap<AgentID, (Duration, DelayCause)>
pub fn get_blocked_by_graph(
&self,
map: &Map
) -> BTreeMap<AgentID, (Duration, DelayCause)>
For every agent that’s currently not moving, figure out how long they’ve been waiting and why they’re blocked.
sourcepub fn status_of_buses(
&self,
route: TransitRouteID,
map: &Map
) -> Vec<(CarID, Option<usize>, f64, Pt2D)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn status_of_buses(
&self,
route: TransitRouteID,
map: &Map
) -> Vec<(CarID, Option<usize>, f64, Pt2D)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
(bus, stop index it’s coming from, percent to next stop, location)
pub fn get_analytics(&self) -> &Analytics
sourcepub fn delayed_intersections(
&self,
threshold: Duration
) -> Vec<(IntersectionID, Time)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn delayed_intersections(
&self,
threshold: Duration
) -> Vec<(IntersectionID, Time)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
For intersections with an agent waiting beyond some threshold, return when they started waiting. Sorted by earliest waiting (likely the root cause of gridlock).
pub fn bldg_to_people(&self, b: BuildingID) -> Vec<PersonID>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_pandemic_model(&self) -> Option<&PandemicModel>
pub fn get_end_of_day(&self) -> Time
pub fn current_stage_and_remaining_time(
&self,
i: IntersectionID
) -> (usize, Duration)
pub fn all_arrivals_at_border(
&self,
i: IntersectionID
) -> Vec<(AgentType, Vec<(Time, usize)>)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn target_lane_penalty(&self, lane: &Lane) -> (usize, usize)
pub fn target_lane_penalty(&self, lane: &Lane) -> (usize, usize)
(number of vehicles in the lane, penalty if a bike or other slow vehicle is present)
pub fn get_people_waiting_at_stop(
&self,
at: TransitStopID
) -> &Vec<(PedestrianID, TransitRouteID, Option<TransitStopID>, Time)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn generate_scenario(&self, map: &Map, name: String) -> Scenario
pub fn infinite_parking(&self) -> bool
pub fn all_waiting_people(&self) -> BTreeMap<PersonID, Duration>
pub fn describe_internal_stats(&self) -> Vec<String>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn debug_queue_lengths(&self, l: LaneID) -> Option<(Distance, Distance)>
sourcepub fn get_trip_time_lower_bound(&self, map: &Map, id: TripID) -> Result<Duration>
pub fn get_trip_time_lower_bound(&self, map: &Map, id: TripID) -> Result<Duration>
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.
pub fn get_highlighted_people(&self) -> &Option<BTreeSet<PersonID>>
sourcepub fn get_pedestrian_density(
&self,
map: &Map
) -> (BTreeMap<RoadID, f64>, BTreeMap<IntersectionID, f64>)
pub fn get_pedestrian_density(
&self,
map: &Map
) -> (BTreeMap<RoadID, f64>, BTreeMap<IntersectionID, f64>)
Returns people / m^2. Roads have up to two sidewalks and intersections have many crossings – take the max density along any one.
sourceimpl Sim
impl Sim
pub fn step_count(&self) -> usize
pub fn get_draw_car(&self, id: CarID, map: &Map) -> Option<DrawCarInput>
pub fn get_draw_ped(
&self,
id: PedestrianID,
map: &Map
) -> Option<DrawPedestrianInput>
pub fn get_draw_cars(&self, on: Traversable, map: &Map) -> Vec<DrawCarInput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_draw_peds(
&self,
on: Traversable,
map: &Map
) -> (Vec<DrawPedestrianInput>, Vec<DrawPedCrowdInput>)
pub fn get_all_draw_cars(&self, map: &Map) -> Vec<DrawCarInput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_all_draw_peds(&self, map: &Map) -> Vec<DrawPedestrianInput>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn get_unzoomed_agents(&self, map: &Map) -> Vec<UnzoomedAgent>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_unzoomed_agents(&self, map: &Map) -> Vec<UnzoomedAgent>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
This does not include transit riders. Some callers need those in addition, but the rendering ones don’t.
pub fn get_unzoomed_transit_riders(&self, map: &Map) -> Vec<UnzoomedAgent>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourceimpl Sim
impl Sim
pub fn instantiate(
&mut self,
scenario: &Scenario,
map: &Map,
rng: &mut XorShiftRng,
timer: &mut Timer<'_>
)
sourcepub fn instantiate_without_retries(
&mut self,
scenario: &Scenario,
map: &Map,
rng: &mut XorShiftRng,
retry_if_no_room: bool,
timer: &mut Timer<'_>
)
pub fn instantiate_without_retries(
&mut self,
scenario: &Scenario,
map: &Map,
rng: &mut XorShiftRng,
retry_if_no_room: bool,
timer: &mut Timer<'_>
)
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.
sourceimpl Sim
impl Sim
pub fn new(map: &Map, opts: SimOptions) -> Sim
pub(crate) fn spawn_trips(
&mut self,
input: Vec<(PersonID, TripInfo, StartTripArgs)>,
map: &Map,
timer: &mut Timer<'_>
)
pub fn get_free_onstreet_spots(&self, l: LaneID) -> Vec<ParkingSpot>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_free_offstreet_spots(&self, b: BuildingID) -> Vec<ParkingSpot>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_free_lot_spots(&self, pl: ParkingLotID) -> Vec<ParkingSpot>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn get_all_parking_spots(&self) -> (Vec<ParkingSpot>, Vec<ParkingSpot>)
pub fn get_all_parking_spots(&self) -> (Vec<ParkingSpot>, Vec<ParkingSpot>)
(Filled, available)
pub fn bldg_to_parked_cars(&self, b: BuildingID) -> Vec<CarID>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn walking_path_to_nearest_parking_spot(
&self,
map: &Map,
b: BuildingID
) -> Option<Path>
pub(crate) fn new_person(
&mut self,
orig_id: Option<OrigPersonID>,
ped_speed: Speed,
vehicle_specs: Vec<VehicleSpec>
) -> &Person
pub(crate) fn seed_parked_car(&mut self, vehicle: Vehicle, spot: ParkingSpot)
pub(crate) fn seed_bus_route(&mut self, route: &TransitRoute)
fn start_bus(&mut self, route: &TransitRoute, map: &Map)
pub fn set_run_name(&mut self, name: String)
pub fn get_run_name(&self) -> &String
sourceimpl Sim
impl Sim
fn minimal_step(
&mut self,
map: &Map,
max_dt: Duration,
maybe_cb: &mut Option<Box<dyn SimCallback>>
) -> bool
fn do_step(
&mut self,
map: &Map,
time: Time,
cmd: Command,
maybe_cb: &mut Option<Box<dyn SimCallback>>
) -> bool
fn dispatch_events(&mut self, events: Vec<Event>, map: &Map)
pub fn timed_step(
&mut self,
map: &Map,
dt: Duration,
maybe_cb: &mut Option<Box<dyn SimCallback>>,
timer: &mut Timer<'_>
)
pub fn tiny_step(
&mut self,
map: &Map,
maybe_cb: &mut Option<Box<dyn SimCallback>>
)
pub fn time_limited_step(
&mut self,
map: &Map,
dt: Duration,
real_time_limit: Duration,
maybe_cb: &mut Option<Box<dyn SimCallback>>
)
pub fn dump_before_abort(&self)
sourceimpl Sim
impl Sim
pub fn save_dir(&self) -> String
fn save_path(&self, base_time: Time) -> String
pub fn save(&mut self) -> String
pub fn find_previous_savestate(&self, base_time: Time) -> Option<String>
pub fn find_next_savestate(&self, base_time: Time) -> Option<String>
pub fn load_savestate(path: String, timer: &mut Timer<'_>) -> Result<Sim>
sourceimpl Sim
impl Sim
pub fn handle_live_edited_traffic_signals(&mut self, map: &Map)
sourceimpl Sim
impl Sim
sourcepub fn set_periodic_callback(&mut self, frequency: Duration)
pub fn set_periodic_callback(&mut self, frequency: Duration)
Only one at a time supported.
pub fn unset_periodic_callback(&mut self)
sourceimpl Sim
impl Sim
pub fn record_traffic_for(&mut self, intersections: BTreeSet<IntersectionID>)
pub fn num_recorded_trips(&self) -> Option<usize>
pub fn save_recorded_traffic(&mut self, map: &Map)
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Sim
impl<'de> Deserialize<'de> for Sim
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Sim
impl Send for Sim
impl Sync for Sim
impl Unpin for Sim
impl UnwindSafe for Sim
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more