Skip to content

Conversation

@i-am-sijia
Copy link
Contributor

@i-am-sijia i-am-sijia commented Nov 20, 2025

This PR addresses issue #892.

Status: Draft - core functionality implemented, remaining: logging and documentation.

Summary

Adds a new skip_failed_choices setting that allows ActivitySim to skip households that cause choice model failures instead of being masked and forced a choice by the overflow_pretection or crashing the entire simulation. This improves robustness for large-scale production runs where occasional edge cases shouldn't halt the model.

Key Changes

Core Logic (activitysim/core/)

  • Modified logit.py to temporarily mark failed choices with -99 and track skipped households in state
  • Added functionality in state.py to dynamically drop data that belong to the skipped household
  • Updated simulate.py and interaction_sample_simulate.py to handle failed choices
  • Enhanced report_bad_choices() to log skipped households

Configuration

  • Added skip_failed_choices: bool = True setting in top.py

Model Updates (activitysim/abm/models/)

  • Retained household_id in chooser columns across location choice models for tracking
  • Modified shadow price calculations to exclude skipped households
  • Updated trip matrices to adjust household expansion weights: weight * (valid_hh / total_hh)
  • Added null trip mode handling in trip mode choice and school escorting

Testing

  • Added new unit test test/skip_failed_choices to deliberately trigger failures and validates households being skipped

Usage

# settings.yaml
skip_failed_choices: true

Access skipped household info via:

  • state.get("num_skipped_households", 0)
  • state.get("skipped_household_ids", set())

Final count logged at end of simulation in the activitysim.log.

Notes

@jpn-- jpn-- added this to Phase 11 Dec 2, 2025
@jpn-- jpn-- moved this to In Progress in Phase 11 Dec 2, 2025
@i-am-sijia
Copy link
Contributor Author

For components where we intentionally allow some choices to fail without being skipped, the allow_zero_probs option is already set to True, which exempts them from this new feature. Therefore, it may not be necessary to introduce this as a component-level setting. In addition, keeping it as a global setting helps reduce manual errors, avoid confusion, and prevent inconsistencies across the implementation.

@jpn-- jpn-- moved this from In Progress to Under Review in Phase 11 Dec 11, 2025
@jpn-- jpn-- self-requested a review December 11, 2025 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Under Review

Development

Successfully merging this pull request may close these issues.

1 participant