Skip to content

Fix Schedule validation for start > end#3326

Merged
quaquel merged 4 commits intomesa:mainfrom
souro26:schedule-validation-check-fix
Feb 16, 2026
Merged

Fix Schedule validation for start > end#3326
quaquel merged 4 commits intomesa:mainfrom
souro26:schedule-validation-check-fix

Conversation

@souro26
Copy link
Copy Markdown
Contributor

@souro26 souro26 commented Feb 16, 2026

Summary

This fix ensures that the Schedule class correctly validates when the start time is after the end time, raising a ValueError to prevent an invalid scheduling window. It addresses the issue where models could be misconfigured with an invalid schedule, leading to unexpected behavior.

Fixes #3321

Bug / Issue

The Schedule class currently allows a start time that is later than the end time, which creates an invalid execution window. This behavior is inconsistent with the purpose of defining valid execution intervals for models and can lead to models running in a broken state.

Implementation

  • Added validation logic in __post_init__ to ensure that if both start and end are set, start must not be greater than end.
  • A ValueError is raised when the invalid configuration is detected, preventing the model from running with an invalid schedule.

Testing

Added a test case in test_schedule_run.py to check that the Schedule raises a ValueError when start > end.

Additional Notes

This fix ensures better configuration and prevents mistakes that could cause models to fail without warning.

@souro26 souro26 force-pushed the schedule-validation-check-fix branch from 8608874 to 5f1bef7 Compare February 16, 2026 16:12
@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +2.5% [+2.1%, +3.0%] 🔵 +0.5% [+0.3%, +0.8%]
BoltzmannWealth large 🔴 +3.5% [+3.2%, +3.7%] 🔴 +10.4% [+9.8%, +11.0%]
Schelling small 🔴 +3.5% [+3.2%, +3.9%] 🔵 +1.2% [+1.1%, +1.3%]
Schelling large 🔵 +1.2% [+0.3%, +1.9%] 🔵 +3.1% [+0.9%, +5.3%]
WolfSheep small 🔵 +1.2% [+0.7%, +1.6%] 🔵 +1.0% [+0.8%, +1.1%]
WolfSheep large 🔵 +2.5% [+1.2%, +3.8%] 🔵 +4.0% [+1.9%, +6.2%]
BoidFlockers small 🔵 -0.5% [-1.0%, -0.1%] 🔵 +0.2% [+0.0%, +0.4%]
BoidFlockers large 🔵 -0.1% [-0.8%, +0.5%] 🔵 -0.4% [-0.6%, -0.3%]

@quaquel quaquel merged commit 40943f6 into mesa:main Feb 16, 2026
14 checks passed
@quaquel quaquel added enhancement Release notes label backport-candidate PRs we might want to backport to an earlier branch labels Feb 16, 2026
Krishsharma179 pushed a commit to Krishsharma179/mesa that referenced this pull request Feb 21, 2026
* Fix Schedule validation for start > end

* ruff issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jan Kwakkel <[email protected]>
EwoutH pushed a commit that referenced this pull request Mar 15, 2026
* Fix Schedule validation for start > end

* ruff issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jan Kwakkel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate PRs we might want to backport to an earlier branch enhancement Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid execution window when in Schedule when start > end

2 participants