Struct sim::sim::Sim [−][src]
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
(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
pub fn active_agents(&self) -> Vec<AgentID>ⓘ
If trip is finished, returns (total time, total waiting time, total distance)
For every parked car, (position of parking spot, position of owner)
pub fn get_all_people(&self) -> &Vec<Person>ⓘ
pub fn get_all_driving_paths(&self) -> Vec<&Path>ⓘ
pub fn get_accepted_agents(&self, id: IntersectionID) -> Vec<(AgentID, TurnID)>ⓘ
pub fn get_waiting_agents(
&self,
id: IntersectionID
) -> Vec<(AgentID, TurnID, Time)>ⓘ
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).
pub fn bldg_to_people(&self, b: BuildingID) -> Vec<PersonID>ⓘ
(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)>ⓘ
pub fn describe_internal_stats(&self) -> Vec<String>ⓘ
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_draw_cars(&self, on: Traversable, map: &Map) -> Vec<DrawCarInput>ⓘ
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>ⓘ
pub fn get_all_draw_peds(&self, map: &Map) -> Vec<DrawPedestrianInput>ⓘ
This does not include transit riders. Some callers need those in addition, but the rendering ones don’t.
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>ⓘ
pub fn get_free_offstreet_spots(&self, b: BuildingID) -> Vec<ParkingSpot>ⓘ
pub fn get_free_lot_spots(&self, pl: ParkingLotID) -> Vec<ParkingSpot>ⓘ
(Filled, available)
pub fn bldg_to_parked_cars(&self, b: BuildingID) -> Vec<CarID>ⓘ
pub(crate) fn new_person(
&mut self,
orig_id: Option<OrigPersonID>,
ped_speed: Speed,
vehicle_specs: Vec<VehicleSpec>
) -> &Person
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
pub fn timed_step(
&mut self,
map: &Map,
dt: Duration,
maybe_cb: &mut Option<Box<dyn SimCallback>>,
timer: &mut Timer<'_>
)
pub fn time_limited_step(
&mut self,
map: &Map,
dt: Duration,
real_time_limit: Duration,
maybe_cb: &mut Option<Box<dyn SimCallback>>
)
Respond to arbitrary map edits without resetting the simulation. Returns the number of (trips cancelled, parked cars displaced).
Only one at a time supported.
Trait Implementations
fn 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 UnwindSafe for Sim
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
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
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub 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
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub 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
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self