-
Notifications
You must be signed in to change notification settings - Fork 14
Fix Sugarscape example compatibility with Mesa 3.0 #131
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
base: main
Are you sure you want to change the base?
Fix Sugarscape example compatibility with Mesa 3.0 #131
Conversation
t updates the Sugarscape example to work with Mesa 3.0 by addressing several compatibility issues: - Fixed model initialization to properly pass seed to Mesa base class - Updated agent creation and tracking to use Mesa 3.0's automatic ID assignment - Replaced deprecated scheduler methods with direct agent iteration for stability - Modified Sugar agent step method to correctly handle cell occupation checks - Removed manual agent list management that conflicted with Mesa's built-in tracking
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #131 +/- ##
=======================================
Coverage ? 91.78%
=======================================
Files ? 11
Lines ? 1680
Branches ? 0
=======================================
Hits ? 1542
Misses ? 138
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@adamamer20, please have a look if it works fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put >= than the last version of mesa (3.1.4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamamer20, I think mesa does not use python 3.11, so instead of just changing mesa ~=3.0.0
to mesa >=3.1.4
i can implement a conditional dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great practice to test the changes but do not commit this result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use pytest for testing purposes.
@adamamer20 have a look if its fine now, as I mentioned earlier, I have implemented a conditional dependency instead of putting mesa >= 3.1.4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new mesa model is not working correctly. You shouldn't save the agents in a custom list, but you should add them to the model
|
||
# Process Sugar agents directly | ||
for sugar in self.sugars: | ||
sugar.step() | ||
|
||
def run_model(self, step_count=200): | ||
for i in range(step_count): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not actually adding any agents to the model so everytime you run_model from performance_comparison.py
, the number of agents is always 0 and you don't actually do anything.
pyproject.toml
Outdated
"mesa>=3.1.4; python_version >= '3.11'", | ||
"mesa~=3.0.0; python_version < '3.11'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"mesa>=3.1.4; python_version >= '3.11'", | |
"mesa~=3.0.0; python_version < '3.11'", | |
"mesa>=3.1.5", |
This wasn't a bad idea but let's just simplify and bump up the version to 3.11
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
updates the Sugarscape example to work with Mesa 3.0 by addressing several compatibility issues: