Skip to content

Conversation

@jpn--
Copy link
Member

@jpn-- jpn-- commented Dec 18, 2025

This pull request updates the trip destination model to improve compatibility with the "sharrow" mode by ensuring that all TAZs (Traffic Analysis Zones) are represented in aggregated data structures, even if some TAZs have no associated MAZs (Micro Analysis Zones). This change helps align the model's alternatives with TAZ-based skim matrices, which is particularly important when using the sharrow framework.

Sharrow compatibility and TAZ completeness:

  • Updated aggregate_size_term_matrix to accept an optional all_tazs parameter, ensuring that the resulting TAZ size term matrix includes all TAZs, filling in zeros for any TAZs without MAZs.
  • Modified destination_presample to pass the complete set of TAZs to aggregate_size_term_matrix when sharrow is enabled, guaranteeing all TAZs are present in the matrix.
  • Ensured that the alternatives DataFrame in destination_presample is reindexed to include all TAZs with zero fill when sharrow is active, so that the alternatives vector aligns with the TAZ skim structure.

Closes #1022.

@jpn--
Copy link
Member Author

jpn-- commented Dec 24, 2025

In writing a unit tests for this PR, I discovered a second problem: for two zone systems, thedtype for imported MAZ-to-MAZ data was not being controlled to match the dtype of the similarly named TAZ-to-TAZ skim, e.g. the MAZ data could be stored as float64 while the TAZ data is stored as float32. This has minor impacts on runtime, but can cause subtle bugs in handling 2-zone skim data with sharrow with the "fastmath" option turned on. This is not the first time that "fastmath" has tripped us up (there is already a note in the documentation about turning it off when finding these exact kinds of errors. It is super hard to diagnose these problems when they do occur so I decided the best course is to change the default on "fastmath" to False. Users can easily turn it back on for individual components when the performance gains are useful.

@jpn-- jpn-- requested a review from stefancoe December 24, 2025 01:04
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.

'utility not aligned' error when running sharrow in test mode using uv, but not in conda using same version of Activitysim.

1 participant