Struct sim::Sim[][src]

pub struct Sim {
    driving: DrivingSimState,
    parking: ParkingSimState,
    walking: WalkingSimState,
    intersections: IntersectionSimState,
    transit: TransitSimState,
    cap: CapSimState,
    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,
}

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

Fields

driving: DrivingSimStateparking: ParkingSimStatewalking: WalkingSimStateintersections: IntersectionSimStatetransit: TransitSimStatecap: CapSimStatetrips: 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

impl Sim[src]

pub fn time(&self) -> Time[src]

pub fn is_done(&self) -> bool[src]

pub fn is_empty(&self) -> bool[src]

pub fn num_trips(&self) -> (usize, usize)[src]

(number of finished trips, number of unfinished trips)

pub fn num_agents(&self) -> Counter<AgentType>[src]

pub fn num_commuters_vehicles(&self) -> CommutersVehiclesCounts[src]

pub fn num_ppl(&self) -> (usize, usize, usize)[src]

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

pub fn debug_ped(&self, id: PedestrianID)[src]

pub fn debug_car(&self, id: CarID)[src]

pub fn debug_car_ui(&self, id: CarID) -> String[src]

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

pub fn debug_intersection(&self, id: IntersectionID, map: &Map)[src]

pub fn debug_lane(&self, id: LaneID)[src]

pub fn agent_properties(&self, map: &Map, id: AgentID) -> AgentProperties[src]

Only call for active agents, will panic otherwise

pub fn num_transit_passengers(&self, car: CarID) -> usize[src]

pub fn bus_route_id(&self, maybe_bus: CarID) -> Option<BusRouteID>[src]

pub fn active_agents(&self) -> Vec<AgentID>[src]

pub fn num_active_agents(&self) -> usize[src]

pub fn agent_to_trip(&self, id: AgentID) -> Option<TripID>[src]

pub fn trip_to_agent(&self, id: TripID) -> TripResult<AgentID>[src]

pub fn trip_info(&self, id: TripID) -> TripInfo[src]

pub fn all_trip_info(&self) -> Vec<(TripID, TripInfo)>[src]

pub fn finished_trip_details(
    &self,
    id: TripID
) -> Option<(Duration, Duration, Distance)>
[src]

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

pub fn trip_blocked_time(&self, id: TripID) -> Duration[src]

pub fn trip_to_person(&self, id: TripID) -> Option<PersonID>[src]

pub fn agent_to_person(&self, id: AgentID) -> Option<PersonID>[src]

pub fn person_to_agent(&self, id: PersonID) -> Option<AgentID>[src]

pub fn get_owner_of_car(&self, id: CarID) -> Option<PersonID>[src]

pub fn lookup_parked_car(&self, id: CarID) -> Option<&ParkedCar>[src]

pub fn all_parked_car_positions(&self, map: &Map) -> Vec<(Position, Position)>[src]

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

pub fn lookup_person(&self, id: PersonID) -> Option<&Person>[src]

pub fn get_person(&self, id: PersonID) -> &Person[src]

pub fn find_person_by_orig_id(&self, id: OrigPersonID) -> Option<PersonID>[src]

pub fn get_all_people(&self) -> &Vec<Person>[src]

pub fn lookup_car_id(&self, idx: usize) -> Option<CarID>[src]

pub fn get_path(&self, id: AgentID) -> Option<&Path>[src]

pub fn get_all_driving_paths(&self) -> Vec<&Path>[src]

pub fn trace_route(&self, id: AgentID, map: &Map) -> Option<PolyLine>[src]

pub fn get_canonical_pt_per_trip(
    &self,
    trip: TripID,
    map: &Map
) -> TripResult<Pt2D>
[src]

pub fn get_canonical_pt_per_person(
    &self,
    p: PersonID,
    map: &Map
) -> Option<Pt2D>
[src]

pub fn canonical_pt_for_agent(&self, id: AgentID, map: &Map) -> Option<Pt2D>[src]

pub fn get_accepted_agents(&self, id: IntersectionID) -> Vec<(AgentID, TurnID)>[src]

pub fn get_waiting_agents(
    &self,
    id: IntersectionID
) -> Vec<(AgentID, TurnID, Time)>
[src]

pub fn get_blocked_by_graph(
    &self,
    map: &Map
) -> BTreeMap<AgentID, (Duration, DelayCause)>
[src]

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

pub fn status_of_buses(
    &self,
    route: BusRouteID,
    map: &Map
) -> Vec<(CarID, Option<usize>, f64, Pt2D)>
[src]

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

pub fn get_analytics(&self) -> &Analytics[src]

pub fn delayed_intersections(
    &self,
    threshold: Duration
) -> Vec<(IntersectionID, Time)>
[src]

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>[src]

pub fn get_pandemic_model(&self) -> Option<&PandemicModel>[src]

pub fn get_end_of_day(&self) -> Time[src]

pub fn current_stage_and_remaining_time(
    &self,
    i: IntersectionID
) -> (usize, Duration)
[src]

pub fn all_arrivals_at_border(
    &self,
    i: IntersectionID
) -> Vec<(AgentType, Vec<(Time, usize)>)>
[src]

pub fn target_lane_penalty(&self, lane: &Lane) -> (usize, usize)[src]

(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: BusStopID
) -> &Vec<(PedestrianID, BusRouteID, Option<BusStopID>, Time)>
[src]

pub fn generate_scenario(&self, map: &Map, name: String) -> Scenario[src]

pub fn get_cap_counter(&self, r: RoadID) -> usize[src]

pub fn infinite_parking(&self) -> bool[src]

pub fn all_waiting_people(&self) -> BTreeMap<PersonID, Duration>[src]

pub fn describe_internal_stats(&self) -> Vec<String>[src]

pub fn debug_queue_lengths(&self, l: LaneID) -> Option<(Distance, Distance)>[src]

pub fn get_trip_time_lower_bound(
    &self,
    map: &Map,
    id: TripID
) -> Result<Duration>
[src]

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>>[src]

impl Sim[src]

pub fn step_count(&self) -> usize[src]

pub fn get_draw_car(&self, id: CarID, map: &Map) -> Option<DrawCarInput>[src]

pub fn get_draw_ped(
    &self,
    id: PedestrianID,
    map: &Map
) -> Option<DrawPedestrianInput>
[src]

pub fn get_draw_cars(&self, on: Traversable, map: &Map) -> Vec<DrawCarInput>[src]

pub fn get_draw_peds(
    &self,
    on: Traversable,
    map: &Map
) -> (Vec<DrawPedestrianInput>, Vec<DrawPedCrowdInput>)
[src]

pub fn get_all_draw_cars(&self, map: &Map) -> Vec<DrawCarInput>[src]

pub fn get_all_draw_peds(&self, map: &Map) -> Vec<DrawPedestrianInput>[src]

pub fn get_unzoomed_agents(&self, map: &Map) -> Vec<UnzoomedAgent>[src]

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>[src]

impl Sim[src]

pub fn new(map: &Map, opts: SimOptions) -> Sim[src]

pub(crate) fn spawn_trips(
    &mut self,
    input: Vec<(PersonID, TripInfo, StartTripArgs)>,
    map: &Map,
    timer: &mut Timer<'_>
)
[src]

pub fn get_free_onstreet_spots(&self, l: LaneID) -> Vec<ParkingSpot>[src]

pub fn get_free_offstreet_spots(&self, b: BuildingID) -> Vec<ParkingSpot>[src]

pub fn get_free_lot_spots(&self, pl: ParkingLotID) -> Vec<ParkingSpot>[src]

pub fn get_all_parking_spots(&self) -> (Vec<ParkingSpot>, Vec<ParkingSpot>)[src]

(Filled, available)

pub fn bldg_to_parked_cars(&self, b: BuildingID) -> Vec<CarID>[src]

pub fn walking_path_to_nearest_parking_spot(
    &self,
    map: &Map,
    b: BuildingID
) -> Option<Path>
[src]

pub(crate) fn new_person(
    &mut self,
    orig_id: Option<OrigPersonID>,
    ped_speed: Speed,
    vehicle_specs: Vec<VehicleSpec>
) -> &Person
[src]

pub(crate) fn seed_parked_car(&mut self, vehicle: Vehicle, spot: ParkingSpot)[src]

pub(crate) fn seed_bus_route(&mut self, route: &BusRoute)[src]

fn start_bus(&mut self, route: &BusRoute, map: &Map)[src]

pub fn set_run_name(&mut self, name: String)[src]

pub fn get_run_name(&self) -> &String[src]

impl Sim[src]

fn minimal_step(
    &mut self,
    map: &Map,
    max_dt: Duration,
    maybe_cb: &mut Option<Box<dyn SimCallback>>
) -> bool
[src]

fn do_step(
    &mut self,
    map: &Map,
    time: Time,
    cmd: Command,
    maybe_cb: &mut Option<Box<dyn SimCallback>>
) -> bool
[src]

fn dispatch_events(&mut self, events: Vec<Event>, map: &Map)[src]

pub fn timed_step(
    &mut self,
    map: &Map,
    dt: Duration,
    maybe_cb: &mut Option<Box<dyn SimCallback>>,
    timer: &mut Timer<'_>
)
[src]

pub fn tiny_step(
    &mut self,
    map: &Map,
    maybe_cb: &mut Option<Box<dyn SimCallback>>
)
[src]

pub fn time_limited_step(
    &mut self,
    map: &Map,
    dt: Duration,
    real_time_limit: Duration,
    maybe_cb: &mut Option<Box<dyn SimCallback>>
)
[src]

pub fn dump_before_abort(&self)[src]

impl Sim[src]

pub fn save_dir(&self) -> String[src]

fn save_path(&self, base_time: Time) -> String[src]

pub fn save(&mut self) -> String[src]

pub fn find_previous_savestate(&self, base_time: Time) -> Option<String>[src]

pub fn find_next_savestate(&self, base_time: Time) -> Option<String>[src]

pub fn load_savestate(path: String, timer: &mut Timer<'_>) -> Result<Sim>[src]

impl Sim[src]

pub fn handle_live_edited_traffic_signals(&mut self, map: &Map)[src]

pub fn handle_live_edits(&mut self, map: &Map) -> (usize, usize)[src]

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

fn find_trips_affected_by_live_edits(
    &mut self,
    map: &Map
) -> (BTreeSet<(AgentID, TripID)>, usize)
[src]

Returns (trips affected, number of parked cars displaced)

impl Sim[src]

pub fn delete_car(&mut self, id: CarID, map: &Map)[src]

pub fn clear_alerts(&mut self) -> Vec<(Time, AlertLocation, String)>[src]

impl Sim[src]

pub fn set_periodic_callback(&mut self, frequency: Duration)[src]

Only one at a time supported.

pub fn unset_periodic_callback(&mut self)[src]

impl Sim[src]

pub fn record_traffic_for(&mut self, intersections: BTreeSet<IntersectionID>)[src]

pub fn num_recorded_trips(&self) -> Option<usize>[src]

pub fn save_recorded_traffic(&mut self, map: &Map)[src]

impl Sim[src]

pub fn set_highlighted_people(&mut self, people: BTreeSet<PersonID>)[src]

Trait Implementations

impl Clone for Sim[src]

impl<'de> Deserialize<'de> for Sim[src]

impl Serialize for Sim[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,