Struct sim::trips::TripManager
source · pub(crate) struct TripManager {
trips: Vec<Trip>,
people: Vec<Person>,
active_trip_mode: BTreeMap<AgentID, TripID>,
unfinished_trips: usize,
car_id_counter: usize,
events: Vec<Event>,
}
Expand description
Manages people, each of which executes some trips through the day. Each trip is further broken down into legs – for example, a driving trip might start with somebody walking to their car, driving somewhere, parking, and then walking to their final destination. https://a-b-street.github.io/tech/docs/trafficsim/trips.html describes some of the variations.
Fields§
§trips: Vec<Trip>
§people: Vec<Person>
§active_trip_mode: BTreeMap<AgentID, TripID>
§unfinished_trips: usize
§car_id_counter: usize
§events: Vec<Event>
Implementations§
source§impl TripManager
impl TripManager
pub fn new() -> TripManager
pub fn new_person( &mut self, orig_id: Option<OrigPersonID>, ped_speed: Speed, vehicle_specs: Vec<VehicleSpec> ) -> &Person
pub fn new_car_id(&mut self) -> usize
pub fn new_trip(&mut self, person: PersonID, info: TripInfo) -> TripID
pub fn start_trip( &mut self, now: Time, trip: TripID, args: StartTripArgs, ctx: &mut Ctx<'_> )
pub fn collect_events(&mut self) -> Vec<Event>
source§impl TripManager
impl TripManager
sourcepub fn agent_starting_trip_leg(&mut self, agent: AgentID, t: TripID)
pub fn agent_starting_trip_leg(&mut self, agent: AgentID, t: TripID)
This is idempotent to handle the case of cars retrying their spawning.
pub fn car_reached_parking_spot( &mut self, now: Time, car: CarID, spot: ParkingSpot, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_> )
pub fn ped_reached_parking_spot( &mut self, now: Time, ped: PedestrianID, spot: ParkingSpot, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_> )
pub fn ped_ready_to_bike( &mut self, now: Time, ped: PedestrianID, spot: SidewalkSpot, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_> )
pub fn bike_reached_end( &mut self, now: Time, bike: CarID, bike_rack: SidewalkSpot, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_> )
pub fn ped_reached_building( &mut self, now: Time, ped: PedestrianID, bldg: BuildingID, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_> )
sourcepub fn ped_reached_bus_stop(
&mut self,
now: Time,
ped: PedestrianID,
stop: TransitStopID,
blocked_time: Duration,
distance_crossed: Distance,
ctx: &mut Ctx<'_>,
transit: &mut TransitSimState
) -> Option<TransitRouteID>
pub fn ped_reached_bus_stop( &mut self, now: Time, ped: PedestrianID, stop: TransitStopID, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_>, transit: &mut TransitSimState ) -> Option<TransitRouteID>
If no route is returned, the pedestrian boarded a bus immediately.
pub fn ped_boarded_bus( &mut self, now: Time, ped: PedestrianID, bus: CarID, blocked_time: Duration, walking: &mut WalkingSimState ) -> (TripID, PersonID)
pub fn person_left_bus( &mut self, now: Time, person: PersonID, bus: CarID, ctx: &mut Ctx<'_> )
pub fn ped_reached_border( &mut self, now: Time, ped: PedestrianID, i: IntersectionID, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_> )
pub fn transit_rider_reached_border( &mut self, now: Time, person: PersonID, bus: CarID, ctx: &mut Ctx<'_> )
pub fn car_or_bike_reached_border( &mut self, now: Time, car: CarID, i: IntersectionID, blocked_time: Duration, distance_crossed: Distance, ctx: &mut Ctx<'_> )
fn trip_finished(&mut self, now: Time, id: TripID, ctx: &mut Ctx<'_>)
fn start_delayed_trip(&mut self, now: Time, id: PersonID, ctx: &mut Ctx<'_>)
fn spawn_ped( &mut self, now: Time, id: TripID, start: SidewalkSpot, ctx: &mut Ctx<'_> )
source§impl TripManager
impl TripManager
sourcepub fn cancel_unstarted_trip(&mut self, id: TripID, reason: String)
pub fn cancel_unstarted_trip(&mut self, id: TripID, reason: String)
Cancel a trip before it’s started. The person will stay where they are.
sourcepub fn cancel_trip(
&mut self,
now: Time,
id: TripID,
reason: String,
abandoned_vehicle: Option<Vehicle>,
ctx: &mut Ctx<'_>
)
pub fn cancel_trip( &mut self, now: Time, id: TripID, reason: String, abandoned_vehicle: Option<Vehicle>, ctx: &mut Ctx<'_> )
Cancel a trip after it’s started. The person will be magically warped to their destination, along with their car, as if the trip had completed normally.
pub fn trip_abruptly_cancelled(&mut self, trip: TripID, agent: AgentID)
source§impl TripManager
impl TripManager
pub fn active_agents(&self) -> Vec<AgentID>
pub fn active_agents_and_trips(&self) -> &BTreeMap<AgentID, TripID>
pub fn num_active_agents(&self) -> usize
pub fn trip_to_agent(&self, id: TripID) -> TripResult<AgentID>
sourcepub fn agent_to_trip(&self, id: AgentID) -> Option<TripID>
pub fn agent_to_trip(&self, id: AgentID) -> Option<TripID>
This will be None for parked cars and buses. Should always work for pedestrians.
pub fn debug_trip(&self, id: AgentID)
pub fn num_trips(&self) -> (usize, usize)
pub fn num_agents(&self, transit: &TransitSimState) -> Counter<AgentType>
pub fn num_commuters_vehicles( &self, transit: &TransitSimState, walking: &WalkingSimState ) -> CommutersVehiclesCounts
pub fn num_ppl(&self) -> (usize, usize, usize)
pub fn is_done(&self) -> bool
pub fn trip_info(&self, id: TripID) -> TripInfo
pub fn all_trip_info(&self) -> Vec<(TripID, TripInfo)>
pub fn finished_trip_details( &self, id: TripID ) -> Option<(Duration, Duration, Distance)>
pub fn trip_blocked_time(&self, id: TripID) -> Duration
pub fn bldg_to_people(&self, b: BuildingID) -> Vec<PersonID>
pub fn get_person(&self, p: PersonID) -> Option<&Person>
pub fn get_all_people(&self) -> &Vec<Person>
pub fn trip_to_person(&self, id: TripID) -> Option<PersonID>
pub fn all_arrivals_at_border( &self, at: IntersectionID ) -> Vec<(Time, AgentType)>
sourcepub fn generate_scenario(&self, map: &Map, name: String) -> Scenario
pub fn generate_scenario(&self, map: &Map, name: String) -> Scenario
Recreate the Scenario from an instantiated simulation. The results should match the original Scenario used.
Trait Implementations§
source§impl Clone for TripManager
impl Clone for TripManager
source§fn clone(&self) -> TripManager
fn clone(&self) -> TripManager
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TripManager
impl Debug for TripManager
source§impl<'de> Deserialize<'de> for TripManager
impl<'de> Deserialize<'de> for TripManager
source§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>,
Auto Trait Implementations§
impl Freeze for TripManager
impl RefUnwindSafe for TripManager
impl Send for TripManager
impl Sync for TripManager
impl Unpin for TripManager
impl UnwindSafe for TripManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.