Skip to content

Park-and-ride lot choice and capacity#1001

Open
dhensle wants to merge 54 commits into
ActivitySim:mainfrom
RSGInc:pnr_capacity
Open

Park-and-ride lot choice and capacity#1001
dhensle wants to merge 54 commits into
ActivitySim:mainfrom
RSGInc:pnr_capacity

Conversation

@dhensle

@dhensle dhensle commented Oct 8, 2025

Copy link
Copy Markdown
Contributor

Code changes for #965

@jpn--

jpn-- commented Jun 23, 2026

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

@jpn-- jpn-- left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good. That several agencies have collaborated and tested this already gives some extra confidence. Only a couple minor bugs/concerns to address.

persons = state.get_dataframe("persons")

# don't know a-priori how many park-and-ride tours there are at the start of the model run
# giving the buffer a size equal to the number of persons should be sufficient

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine most of the time, but in the outside chance that the number of PnR tours does exceed the number of persons, the model is going to crash hard later, probably just after line 159 where pad will become negative.

synced_choices = synced_choices.sort_index()

# now append any additional rows need to get size back to original length
pad = len(self.shared_pnr_choice) - len(synced_choices)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should intercept here if pad is negative, maybe crash gracefully explaining that the number of PnR tours was unexpectedly greater than the number of persons, instead of crashing with an arcane "negative dimensions are not allowed" error from deep in this code. (see initialization comment below)

.astype(int)
)

elif self.model_settings.RESAMPLE_STRATEGY == "random":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no testing of RESAMPLE_STRATEGY == "random"


# count the total number of pnr choices being resimulated
pnr_counts = (
current_sample.pnr_zone_id.value_counts()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried making a simple test for "random" but it failed here, current_sample seems to be a pd.Series.

The correct code might be:

pnr_counts = (
    tours_in_cap_zones.loc[current_sample.index, "pnr_zone_id"]
    .value_counts()
    .reindex(self.shared_pnr_occupancy_df.index)
    .fillna(0)
    .astype(int)
)

----------
choices : pandas.Series
zone id of location choice indexed by person_id
segment_ids : pandas.Series

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not take segment_ids

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants