Skip to content

Commit

Permalink
forgot to add the line that actually updates the 'earliest' column
Browse files Browse the repository at this point in the history
  • Loading branch information
mxndrwgrdnr committed Jun 30, 2020
1 parent 8d30dd7 commit 155c53b
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions activitysim/abm/models/trip_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def update_tour_earliest(trips, outbound_choices):
----------
trips: pd.DataFrame
outbound_choices: pd.Series
time periods depart choices, one per trip (except for trips with zero probs)
time periods depart choices, one per trip (except for trips with
zero probs)
Returns
-------
modifies trips in place
Expand All @@ -110,16 +111,20 @@ def update_tour_earliest(trips, outbound_choices):
trips['outbound_departure'] = outbound_choices.reindex(trips.index)

# get max outbound trip departure times for all person-tours
max_outbound_person_departures = trips.groupby(['person_id', 'tour_id'])['outbound_departure'].max()
max_outbound_person_departures = trips.groupby(
['person_id', 'tour_id'])['outbound_departure'].max()

# append max outbound trip departure times to trips
trips['max_outbound_departure'] = list(zip(trips['person_id'], trips['tour_id']))
trips['max_outbound_departure'] = trips.max_outbound_departure.map(max_outbound_person_departures)

# set the trips "earliest" column equal to the max outbound departure time if
# the max outbound departure time is greater than the current value of "earliest"
num_inbound = len(trips[~trips['outbound']])
num_updated = len(trips[(trips['earliest'] < trips['max_outbound_departure']) & (~trips['outbound'])])
trips['max_outbound_departure'] = list(
zip(trips['person_id'], trips['tour_id']))
trips['max_outbound_departure'] = trips.max_outbound_departure.map(
max_outbound_person_departures)

# set the trips "earliest" column equal to the max outbound departure
# time if the max outbound departure time is greater than the current
# value of "earliest"
trips['earliest'] = trips[[
'earliest', 'max_outbound_departure']].max(axis=1)


def clip_probs(trips, probs, model_settings):
Expand Down

0 comments on commit 155c53b

Please sign in to comment.