Skip to content

Fix for simulation-based shadow pricing segmentation - #1083

Open
i-am-sijia wants to merge 4 commits into
ActivitySim:mainfrom
wsp-sag:shadow-pricing-simu-fix
Open

i-am-sijia wants to merge 4 commits into
ActivitySim:mainfrom
wsp-sag:shadow-pricing-simu-fix

Conversation

@i-am-sijia

@i-am-sijia i-am-sijia commented Jun 16, 2026

Copy link
Copy Markdown
Member

Addressing #1082 with option 2 ...

Summary generated by Copilot (reviewed):

This pull request refactors how chooser segments are handled in the shadow pricing logic, making the configuration more flexible and robust. It uses CHOOSER_SEGMENT_COLUMN_NAME from the location choice model setting for chooser segmentation to keep shadow-pricing resampling consistent with segment_ids in location choice settings, adds better error handling for misconfigurations, and introduces new tests to cover these scenarios.

Shadow Pricing Configuration Improvements:

  • Removed the hardcoded SEGMENT_TO_NAME mapping from both the module-level dictionary and the ShadowPriceSettings class.
  • The ShadowPriceCalculator now uses the CHOOSER_SEGMENT_COLUMN_NAME from location choice model settings to determine the chooser segment column dynamically.

Error Handling Enhancements:

  • In update_shadow_prices, added explicit checks to raise a SystemConfigurationError if the configured chooser segment column is missing from persons_merged, or if there is no overlap between SEGMENT_IDS values and the values present in the chooser segment column.

Testing Improvements:

  • Added new unit tests to verify that shadow pricing works with customized chooser segments (e.g., a string column) and that misconfigurations (such as non-overlapping segment values) are properly detected and raise clear errors.
  • Updated test fixtures to include string-valued chooser segment columns for more comprehensive coverage.

@jpn--

jpn-- commented Aug 27, 2026

Copy link
Copy Markdown
Member

As discussed in engineering 8/27, this needs a unit test. @i-am-sijia will tackle this.

@i-am-sijia
i-am-sijia marked this pull request as ready for review September 21, 2026 18:41

This branch has not been deployed

No deployments
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.

2 participants