Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Time module and all its Schedulers #2306

Merged
merged 6 commits into from
Sep 21, 2024

Conversation

EwoutH
Copy link
Member

@EwoutH EwoutH commented Sep 20, 2024

View the migration guide on how to replace the deprecated Schedulers with AgentSet functionality.

As concluded in #2231, this PR deprecates the whole Time module and all its Schedulers. This change aims to provide more flexibility and control in agent activation and time management, inspired by the NetLogo framework.

Changes

  1. Deprecated the entire mesa.time module.
  2. Added a module-level deprecation warning to mesa.time.
  3. Updated the migration guide to include instructions for replacing each scheduler with AgentSet functionality.
  4. Removed the tests/test_time.py file as it's no longer relevant.

Migration Guide

The migration guide has been updated to include detailed instructions on how to replace each scheduler with AgentSet functionality. This includes examples for:

  • BaseScheduler
  • RandomActivation
  • SimultaneousActivation
  • StagedActivation
  • RandomActivationByType

The guide also includes general notes on changes to related functionality, such as the automatic incrementing of Model.steps and the replacement of scheduler-specific methods with AgentSet methods.

For this PR, a rendered version of the migration guide can be viewed here.

Benefits

As discussed extensively in #1912 and #2231, replacing the time module with AgentSet functionality has several benefits. A short summary:

  1. Flexibility: Users can now create custom activation patterns without being restricted to predefined schedulers.
  2. Explicitness: The behavior of agent activation is now explicitly defined in the model, improving readability and maintainability.
  3. Simplicity: The codebase is simplified by removing the need for multiple scheduler classes.
  4. Consistency: This change aligns Mesa more closely with other agent-based modeling frameworks like NetLogo.

References

  • Original discussion: #1912
  • Decision discussion: #2231
  • Example updates: #183 and #201
  • This PR: #2306
  • Faster alternative for .shuffle().do(): #2283

PR checklist

  • Write migration guide
  • Update this PR message
  • Find a faster alternative for .shuffle().do() (see #2283)

Next Steps

  • Update all example models to use the new AgentSet functionality instead of schedulers.
  • Review and update any remaining documentation that references the deprecated schedulers.

@EwoutH EwoutH added the deprecation When a new deprecation is introduced label Sep 20, 2024
@EwoutH EwoutH added this to the v3.0 milestone Sep 20, 2024
Add a warning message that all the whole time module and all its schedulers are deprecated
This commit adds a new section to the migration guide explaining how to
replace the deprecated schedulers from the Time module with AgentSet
functionality. It covers:

- Replacements for BaseScheduler, RandomActivation, SimultaneousActivation,
  StagedActivation, and RandomActivationByType
- General notes on related changes, such as agent counting and management
- Examples of how to adapt code using the old scheduler methods
mesa/time.py Outdated Show resolved Hide resolved
@EwoutH EwoutH added the docs Release notes label label Sep 21, 2024
@EwoutH EwoutH marked this pull request as ready for review September 21, 2024 08:37
@EwoutH
Copy link
Member Author

EwoutH commented Sep 21, 2024

Updated the migration guide, so this PR is ready for review.

A rendered version of the migration guide can be viewed here.

@projectmesa projectmesa deleted a comment from github-actions bot Sep 21, 2024
@projectmesa projectmesa deleted a comment from github-actions bot Sep 21, 2024
mesa/time.py Outdated Show resolved Hide resolved
@EwoutH
Copy link
Member Author

EwoutH commented Sep 21, 2024

Moved the DepreciationWarning, and also added a nice visible warning to the docstring.

IMG_1466

Merging, will work on updating the examples next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation When a new deprecation is introduced docs Release notes label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants