Add global option to skip households on simulation failure #1023
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #892.
Status: Draft - core functionality implemented, remaining: logging and documentation.
Summary
Adds a new
skip_failed_choicessetting that allows ActivitySim to skip households that cause choice model failures instead of being masked and forced a choice by theoverflow_pretectionor 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/)logit.pyto temporarily mark failed choices with-99and track skipped households in statestate.pyto dynamically drop data that belong to the skipped householdsimulate.pyandinteraction_sample_simulate.pyto handle failed choicesreport_bad_choices()to log skipped householdsConfiguration
skip_failed_choices: bool = Truesetting intop.pyModel Updates (
activitysim/abm/models/)household_idin chooser columns across location choice models for trackingweight * (valid_hh / total_hh)Testing
test/skip_failed_choicesto deliberately trigger failures and validates households being skippedUsage
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
Truefor production robustnesshousehold_idto chooser columns (remove when PR Access to global constants and removing chooser col filtering #1017 merges)