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

Move core example models back (v2) #2358

Merged
merged 118 commits into from
Oct 15, 2024
Merged

Conversation

EwoutH
Copy link
Member

@EwoutH EwoutH commented Oct 15, 2024

This PR moves several core examples back to the main Mesa repository, organized into Basic and Advanced categories:

Basic Examples:

  • Boltzmann Wealth
  • Boid Flockers
  • Conway's Game of Life
  • Virus on Network
  • Schelling Segregation

Advanced Examples:

  • Epstein Civil Violence
  • Sugarscape with Traders
  • Wolf-Sheep Predation
  • Demographic Prisoner's Dilemma on Grid

It uses some ideas discussed in #2330 (comment), and the division of models originates from #2349 (comment).

It keeps the git history, with the only side effect that the PR numbers now link to the wrong repo (there's no easy way to fix this).

Moving these examples back into the main Mesa repository:

  • Allows opening PRs that show how both code and models change in tandem
  • Removes the need for two PRs for each feature (but still allows it)
  • Simplifies version control, ensuring each example works with the exact commit/release of Mesa
  • Enables more comprehensive testing of these examples within our CI pipeline, including batch runs and visualizations
  • These diverse, high-quality examples will directly help users test a model after installing Mesa.

After this PR is merged, these examples can be updated further to become fully exemplary.

@projectmesa/maintainers, like with the previous PR, I kindly request your review.

jackiekazil and others added 30 commits December 5, 2022 02:29
Additionally:
- Include interactive version with single run, batch run and server options
- Update .gitignore to ignore IDE environment files
* - Add sugarcape_g1mt that is consistent with complexity tutorial
- Include interactive version with single run, batch run and server options
- Update .gitignore to ignore IDE environment files

* - update eat function based on user identified bug in Complexity Explorer Tutorial
- update Readme so batch run does not get an argument error
- update run so data processing of batchrunner does not get a key error
* Use Pathlib

Code by Phil Robare (versilimidude2)

* Use pre-commit

* Dropped unused imports

* used pre-commit to run pyupgrade, trim whitespace

* Remove pathlib changes

These belong in a separate PR.

* remove redundant black, move comment

as per rht's suggestions

---------

Co-authored-by: Catherine Devlin <[email protected]>
* Use Pathlib

Code by Phil Robare (versilimidude2)

* Use pre-commit

* Dropped unused imports

* used pre-commit to run pyupgrade, trim whitespace

* Remove pathlib changes

These belong in a separate PR.

* remove redundant black, move comment

as per rht's suggestions

---------

Co-authored-by: Catherine Devlin <[email protected]>
* fix bug where agent gives money to itself in the boltzmann model example
* [pre-commit.ci] auto fixes from pre-commit.com hooks

---------

Co-authored-by: Houssam Kherraz <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
… option; modified most other examples in the same way
… option; modified most other examples in the same way
…a#33)

- update maybe_sell_spice() so calculate_MRS() takes potential sugar and spice based on trade
- update calculate_MRS() with kwargs so it can take potential trade but defaults to agents sugar and spice
Update increases agent_reporter due to number of trades creating memory issues
- Update data collection so non-relevant data rmeoved on each step (i.e. sugar and spice agents don't have trade partners)
* Implement Streamlit UI for Boltzmann wealth model

* change slider text

* change slider text

* update readme

---------

Co-authored-by: Ankit Kumar <[email protected]>
See PR projectmesa#36 for the app.py implementation if it.
* Initialize Game of Life example

* set slider text

* udpate readme

* Implement Streamlit UI for Boltzmann wealth model

* resolve merge conflicts

---------

Co-authored-by: Ankit Kumar <[email protected]>
EwoutH and others added 10 commits September 21, 2024 10:43
Replace shuffle().do() in 18 models with the performance optimized shuffle_do() method.
…mesa#202)

This PR completes the migration from schedulers to AgentSet functionality across the mesa-examples repository for all regular (non-`gis`/-`rl`) examples. Key changes include:

- Replaced `RandomActivation`, `SimultaneousActivation`, and `RandomActivationByType` schedulers with appropriate AgentSet methods
- Updated `Model.step()` implementations to use AgentSet activation
- Removed references to `schedule.steps`, `schedule.agents`, and `schedule.agents_by_type`
- Updated agent addition/removal logic to work with AgentSets
- Adjusted data collection and visualization code to use `Model.steps` and `Model.agents`

For more details on migrating from schedulers to AgentSets, see the migration guide: https://mesa.readthedocs.io/en/latest/migration_guide.html#time-and-schedulers
…mesa#202)

This PR completes the migration from schedulers to AgentSet functionality across the mesa-examples repository for all regular (non-`gis`/-`rl`) examples. Key changes include:

- Replaced `RandomActivation`, `SimultaneousActivation`, and `RandomActivationByType` schedulers with appropriate AgentSet methods
- Updated `Model.step()` implementations to use AgentSet activation
- Removed references to `schedule.steps`, `schedule.agents`, and `schedule.agents_by_type`
- Updated agent addition/removal logic to work with AgentSets
- Adjusted data collection and visualization code to use `Model.steps` and `Model.agents`

For more details on migrating from schedulers to AgentSets, see the migration guide: https://mesa.readthedocs.io/en/latest/migration_guide.html#time-and-schedulers
* refactor: Simplify Schelling code

1. Remove unused model attributes
2. Make `similar` calculation more natural language readable

* Remove unused argument doc

* Add type hints to agent class

* refactor: Simplify self.running expression
Add a Readme for the Example folder, largely taken from the mesa-examples Readme.
@EwoutH EwoutH added feature Release notes label docs Release notes label example Changes the examples or adds to them. labels Oct 15, 2024
@EwoutH EwoutH added this to the v3.0 milestone Oct 15, 2024

This comment was marked as off-topic.

Don't run ruff on the examples for now, and fix the remaining pre-commit issues (mainly codespell).
Copy link
Member

@quaquel quaquel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good.

I guess all the requirements.txt files can be removed since from now on these will be up to date?

@EwoutH
Copy link
Member Author

EwoutH commented Oct 15, 2024

Thanks!

I guess all the requirements.txt files can be removed since from now on these will be up to date?

Yes, I will open a tracking issues with things that can be improved / cleaned up, and try to tick as many of boxes feasible once this is merged.

@Corvince
Copy link
Contributor

Approved the PR itself, but not sure if all the discussion points from v1 have been resolved?

@EwoutH
Copy link
Member Author

EwoutH commented Oct 15, 2024

Thanks!

but not sure if all the discussion points from v1 have been resolved?

Define resolved ;)

Full consensus among 7 maintainer (on very little detail)? No. Majority agrees on major points? Yes. Clear plan to move forward? I also believe so.

But yeah, I would like to get a little more alignment in today’s meeting.

@EwoutH
Copy link
Member Author

EwoutH commented Oct 15, 2024

@tpike3 @jackiekazil we discussed it in the meeting, but could you give your formal approval, mainly for historical reference?

Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per 15 Oct Dev session I agree

@EwoutH
Copy link
Member Author

EwoutH commented Oct 15, 2024

With jackie also in approval in the meeting, we have 5 core maintainers in agreement.

Thanks for the quick and insightful discussion everyone!

@EwoutH EwoutH merged commit 6a60350 into projectmesa:main Oct 15, 2024
10 of 12 checks passed
@EwoutH
Copy link
Member Author

EwoutH commented Oct 15, 2024

The big checklist to start working on:

@EwoutH EwoutH deleted the add-examples branch October 26, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Release notes label example Changes the examples or adds to them. feature Release notes label
Projects
None yet
Development

Successfully merging this pull request may close these issues.