Skip to content

Commit

Permalink
Provide slice option for passengers. (Fast-Trips#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clint Daniels committed Jun 29, 2018
1 parent 7cd60ec commit 81f3978
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fasttrips/Assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,9 +1327,10 @@ def put_passengers_on_vehicles(pathset_links_df, veh_trips_df):

veh_trips_df_len = len(veh_trips_df)

passengers_df = Passenger.get_chosen_links(pathset_links_df)
passengers_df = Passenger.get_chosen_links(pathset_links_df, transit_only=True, copy=False)

# only care about trips
passengers_df = passengers_df.loc[passengers_df[Passenger.PF_COL_ROUTE_ID].notnull()]
#passengers_df = passengers_df.loc[passengers_df[Passenger.PF_COL_ROUTE_ID].notnull()]

# Group to boards by counting trip_list_id_nums for a (trip_id, A_id as stop_id)
passenger_trips_boards = passengers_df.loc[passengers_df[Assignment.SIM_COL_PAX_BUMP_ITER].isnull(), # unbumped passengers
Expand Down
12 changes: 10 additions & 2 deletions fasttrips/Passenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ def choose_paths(choose_for_everyone, iteration, pathfinding_iteration, simulati


@staticmethod
def get_chosen_links(pathset_links_df):
def get_chosen_links(pathset_links_df, transit_only=False, copy=True):
"""
Given the pathset paths and pathset links, returns the pathset links for the ones marked as chosen.
"""
Expand All @@ -1042,4 +1042,12 @@ def get_chosen_links(pathset_links_df):
pathset_links_df[Assignment.SIM_COL_PAX_CHOSEN] = pathset_links_df[Assignment.SIM_COL_PAX_CHOSEN].astype('category')
pathset_links_df[Assignment.SIM_COL_PAX_CHOSEN].cat.set_categories(Assignment.CHOSEN_CATEGORIES, ordered=True, inplace=True)

return pathset_links_df.loc[pathset_links_df[Assignment.SIM_COL_PAX_CHOSEN]>Assignment.CHOSEN_NOT_CHOSEN_YET,].copy()
slicer = pathset_links_df[Assignment.SIM_COL_PAX_CHOSEN]>Assignment.CHOSEN_NOT_CHOSEN_YET

if transit_only:
slicer = slicer & pathset_links_df[Passenger.PF_COL_ROUTE_ID].notnull()

if copy:
return pathset_links_df.loc[slicer,].copy()

return pathset_links_df.loc[slicer,]

0 comments on commit 81f3978

Please sign in to comment.