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
sourceimpl 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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourceimpl 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<'_>
)
sourceimpl 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)
sourceimpl TripManager
impl TripManager
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 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)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_person(&self, p: PersonID) -> Option<&Person>
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 trip_to_person(&self, id: TripID) -> Option<PersonID>
pub fn all_arrivals_at_border(
&self,
at: IntersectionID
) -> Vec<(Time, AgentType)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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
sourceimpl Clone for TripManager
impl Clone for TripManager
sourcefn clone(&self) -> TripManager
fn clone(&self) -> TripManager
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TripManager
impl Debug for TripManager
sourceimpl<'de> Deserialize<'de> for TripManager
impl<'de> Deserialize<'de> for TripManager
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
sourceimpl Serialize for TripManager
impl Serialize for TripManager
Auto Trait Implementations
impl RefUnwindSafe for TripManager
impl Send for TripManager
impl Sync for TripManager
impl Unpin for TripManager
impl UnwindSafe for TripManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub 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,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub 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
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
pub fn as_any(&self) -> &(dyn Any + 'static)
pub 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
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
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
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more