Skip to content

Commit 4df74d0

Browse files
authored
Lower default threshold for skipped failed choices to 0.1% (#1063)
* change default to 0.1% hh allowed to be skipped * [skip ci] update doc * add to change log
1 parent 82cbefd commit 4df74d0

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

activitysim/core/configuration/top.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def _check_store_skims_in_shm(self):
790790
.. versionadded:: 1.6
791791
"""
792792

793-
fraction_of_failed_choices_allowed: float = 0.1
793+
fraction_of_failed_choices_allowed: float = 0.001
794794
"""
795795
Threshold for the fraction of households that can be skipped before failing the model run,
796796
used in conjunction with `skip_failed_choices`.

docs/dev-guide/changes.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@ branch (i.e., the main branch on GitHub), but not yet released in a stable versi
1414
of ActivitySim. See below under the various version headings for changes in
1515
released versions.
1616

17+
### Skipping Failed Choices
18+
19+
A new feature is introduced to ActivitySim to skip failed choices during model execution.
20+
By default, ActivitySim will skip any failed choices during a model run, i.e., `skip_failed_choices` is set to `True`.
21+
A failed choice occurs when the computed utilities for all alternatives are zero, or infinite, or nan, which can happen due to
22+
data issues or model specification problems. A warning message is logged when a failed choice is encountered,
23+
and the corresponding household (along with its persons, vehicles, tours, trips, etc) will be excluded from further model steps.
24+
At the end of the model run, a summary of all skipped households is provided in the log file for user reference. Users can set
25+
a threshold for the maximum allowed percentage of skipped households `fraction_of_failed_choices_allowed`,
26+
and if the percentage of skipped households exceeds this threshold,
27+
the model run will be terminated with an error. The default threshold is set to `0.001`, 0.1% of households.
28+
29+
This feature helps to ensure that the model can continue running even in the presence of data or specification issues,
30+
while also providing visibility into such issues that need to be addressed.
31+
See more information in ActivitySim's users guide "Skip Failed Choices" and code updates in [PR #1023](https://github.com/ActivitySim/activitysim/pull/1023)
32+
33+
##### Potential Impact on Existing Model Runs:
34+
35+
With `skip_failed_choices` defaulted to `True` and an allowed failure threshold defaulted as 0.1% of households,
36+
failures that were previously silently masked will now generate warnings, be explicitly skipped, and counted toward the threshold.
37+
As a result, model runs that previously completed "successfully" may now fail earlier,
38+
surfacing underlying specification or data issues that require attention rather than being silently absorbed. If an agency does not
39+
want to address the underlying issues immediately, they can set `skip_failed_choices` to `False` to maintain the previous model results,
40+
but it is recommended to review the log file for any warnings about failed choices and address them as soon as possible to ensure model quality.
41+
1742
### Shadow Price Zones Reopening
1843

1944
We fixed an issue with reopening work and school zones during iterative shadow pricing using the

docs/users-guide/ways_to_run.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ For interaction_simulate models, users can manually specify trace IDs to perform
312312
Users can configure ActivitySim to not skip failed choices by setting the
313313
``skip_failed_choices`` option to ``False`` in the settings file. When this option is disabled, the system will fall back to
314314
using the legacy ``overflow_protection`` mechanism to handle such cases. Specifically, if the computed utilities lead to zero or infinite exponentiated values,
315-
overflow protection will adjust the utilities to prevent numerical overflow during exponentiation and arbitarily making a choice.
316-
No loggings will be made for these cases. When ``skip_failed_choices`` is enabled,
317-
ActivitySim will not use the legacy ``overflow_protection`` mechanism to handle failed choices.
315+
the legacy ``overflow_protection`` will adjust the utilities to prevent numerical overflow during exponentiation and arbitarily making a choice, however, no loggings will be made for these cases.
316+
When ``skip_failed_choices`` is enabled, ActivitySim will not use the legacy ``overflow_protection`` mechanism to handle failed choices.
317+
318+
.. note::
319+
When an agency turns on ``skip_failed_choices`` for the first time in an existing ActivitySim implementation,
320+
warning messages may appear in the log for failed choices that were previously handled silently by the legacy ``overflow_protection`` mechanism.
321+
These warnings are expected and reflect the change in behavior: failed choices are now explicitly skipped and traced rather than silently handled.
322+
In some cases, model runs may crash if the number of skipped failed choices exceeds the configured ``fraction_of_failed_choices_allowed`` threshold.

0 commit comments

Comments
 (0)