Esempio n. 1
0
 def __init__(self, agent: MagAgent):
     self.person_id = agent.p_num
     self.pnum = agent.mag_pnum
     self.hhid = agent.mag_hhid
     home = self.random_apn(agent.home_maz)
     self.home_maz = home[0]
     self.home_apn = home[1]
     self.home_coord = coordinate(x=home[2], y=home[3])
     self.events = tuple([])
     self.create_plan(agent)
Esempio n. 2
0
 def __init__(self, trips: pd.DataFrame):
     self.trips = trips
     self.pnum = self.trips.iat[0, MagConvIndex.pnum]
     self.hhid = self.trips.iat[0, MagConvIndex.hhid]
     self.home_maz = self.trips.iat[0, MagConvIndex.orig_loc]
     home = self.random_apn(self.home_maz)
     self.home_apn = home[0]
     self.home_coord = coordinate(x=home[1], y=home[2])
     self.events = tuple([])
     self.create_plan()
Esempio n. 3
0
 def standard_event_creation(self, trip):
     ''' Give actor APNs and coordinate for trips based off MAZ/trip type'''
     leg = MatsimLeg(mode_encode[trip[MagConvIndex.mode]],
                     trip[MagConvIndex.orig_end],
                     trip[MagConvIndex.leg_time])
     dest = self.random_apn(trip[MagConvIndex.dest_loc])
     act = MatsimAct(end_time=trip[MagConvIndex.dest_start]+\
                     trip[MagConvIndex.dest_dur],
                     duration=trip[MagConvIndex.dest_dur],
                     purpose=purpose_encode[trip[MagConvIndex.dest_type]],
                     coord=coordinate(dest[2],
                                      dest[3]),
                     apn=dest[1],
                     maz=dest[0])
     return [leg, act]
Esempio n. 4
0
 def final_events_creation(self, trip) -> Tuple[MatsimLeg, MatsimAct]:
     ''' If a MatsimAct is the last Act in a Plan,
         it has no end time and no duration. Purpose = Home. '''
     final_act = list()
     final_act.append(
         MatsimLeg(mode_encode[trip[MagConvIndex.mode]],
                   trip[MagConvIndex.orig_end],
                   trip[MagConvIndex.leg_time]))
     dest = self.random_apn(trip[MagConvIndex.dest_loc])
     final_act.append(MatsimAct(end_time=trip[MagConvIndex.dest_dur]+\
                                trip[MagConvIndex.dest_start],
                                duration=trip[MagConvIndex.dest_dur],
                                purpose=purpose_encode[trip[MagConvIndex.dest_type]],
                                coord=coordinate(dest[2],
                                                 dest[3]),
                                apn=dest[1],
                                maz=dest[0]))
     return final_act
Esempio n. 5
0
 def standard_event_creation(self, trip_num: int):
     ''' Give actor APNs and coordinate for trips based off MAZ/trip type
         trip_num: Index of trip to access from trips (DataFrame)'''
     trip = self.trips.iloc[trip_num]
     leg = MatsimLeg(mode_encode[trip.iat[MagConvIndex.mode]],
                     trip.iat[MagConvIndex.orig_end],
                     trip.iat[MagConvIndex.leg_time])
     dest_maz = trip.iat[MagConvIndex.dest_loc]
     dest = self.random_apn(dest_maz)
     act = MatsimAct(end_time=trip.iat[MagConvIndex.dest_start]+\
                     trip.iat[MagConvIndex.dest_dur],
                     duration=trip.iat[MagConvIndex.dest_dur],
                     purpose=purpose_encode[trip.iat[MagConvIndex.dest_type]],
                     coord=coordinate(dest[1],
                                      dest[2]),
                     apn=dest[0],
                     maz=dest_maz)
     return (leg, act)
Esempio n. 6
0
 def initial_act_creation(self, trip) -> MatsimAct:
     ''' If a MatsimAct is the first Act in a Plan,
         it has an end time but no duration. Purpose = Home. '''
     if purpose_encode[trip[MagConvIndex.orig_type]] is 'home':
         orig_coord = self.home_coord
         orig_apn = self.home_apn
         orig_maz = self.home_maz
     else:
         rand_apn = self.random_apn(trip[MagConvIndex.orig_loc])
         orig_coord = coordinate(rand_apn[2], rand_apn[3])
         orig_apn = rand_apn[1]
         orig_maz = rand_apn[0]
     initial_act = MatsimAct(end_time=trip[MagConvIndex.orig_end],
                             duration=False,
                             purpose=purpose_encode[0],
                             coord=orig_coord,
                             apn=orig_apn,
                             maz=orig_maz)
     return initial_act
Esempio n. 7
0
 def final_events_creation(self) -> Tuple[MatsimLeg, MatsimAct]:
     ''' If a MatsimAct is the last Act in a Plan,
         it has no end time and no duration. Purpose = Home. '''
     final_trip = self.trips.iloc[-1]
     leg = MatsimLeg(mode_encode[final_trip.iat[MagConvIndex.mode]],
                     final_trip.iat[MagConvIndex.orig_end],
                     final_trip.iat[MagConvIndex.leg_time])
     dest_maz = final_trip.iat[MagConvIndex.dest_loc]
     dest = self.random_apn(dest_maz)
     act = MatsimAct(end_time=final_trip.iat[MagConvIndex.dest_dur]+\
                                final_trip.iat[MagConvIndex.dest_start],
                                duration=final_trip.iat[MagConvIndex.dest_dur],
                                purpose=purpose_encode[
                                    final_trip.iat[MagConvIndex.dest_type]],
                                coord=coordinate(dest[1],
                                                 dest[2]),
                                apn=dest[0],
                                maz=dest_maz)
     return (leg, act)
Esempio n. 8
0
 def initial_act_creation(self) -> MatsimAct:
     ''' If a MatsimAct is the first Act in a Plan,
         it has an end time but no duration. Purpose = Home. '''
     initial_trip = self.trips.iloc[0]
     if purpose_encode[initial_trip.iat[MagConvIndex.orig_type]] is 'home':
         orig_coord = self.home_coord
         orig_apn = self.home_apn
         orig_maz = self.home_maz
     else:
         orig_maz = initial_trip.iat[MagConvIndex.orig_loc]
         rand_apn = self.random_apn(orig_maz)
         orig_apn = rand_apn[0]
         orig_coord = coordinate(rand_apn[1], rand_apn[2])
     initial_act = MatsimAct(
         end_time=initial_trip.iat[MagConvIndex.orig_end],
         duration=False,
         purpose='home',
         coord=orig_coord,
         apn=orig_apn,
         maz=orig_maz)
     return initial_act