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

changed create agents in tutorial #2541

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

DarshPareek
Copy link

Summary

This PR changes the tutorials to make them consistent with Mesa 3.1

Motive

Make Mesa tutorial consistent with 3.1 release

Implementation

  • Changed intro_tutorial.ipynb
  • Changed MoneyModel.py

Usage Examples

class MoneyModel(mesa.Model):
    """A model with some number of agents."""

    def __init__(self, n=10, seed=None):
        """Initialize a MoneyModel instance.

        Args:
            N: The number of agents.
            width: width of the grid.
            height: Height of the grid.
        """
        super().__init__(seed=seed)
        self.num_agents = n
        

        # Create agents
        MoneyAgent.create_agents(self,n)


Copy link

github-actions bot commented Dec 9, 2024

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +0.8% [+0.2%, +1.3%] 🔵 +0.2% [+0.0%, +0.3%]
BoltzmannWealth large 🔵 +1.2% [+0.8%, +1.5%] 🔵 +0.3% [-0.3%, +0.9%]
Schelling small 🔵 +0.8% [+0.5%, +1.1%] 🔵 +0.3% [+0.1%, +0.4%]
Schelling large 🔵 +0.9% [+0.5%, +1.3%] 🔵 +3.6% [+2.5%, +4.8%]
WolfSheep small 🔵 +3.2% [+2.8%, +3.5%] 🔵 +0.9% [+0.7%, +1.0%]
WolfSheep large 🔴 +3.7% [+3.5%, +4.0%] 🔴 +7.0% [+5.5%, +8.5%]
BoidFlockers small 🔴 +8.0% [+7.5%, +8.6%] 🔵 +0.6% [-0.3%, +1.4%]
BoidFlockers large 🔴 +7.4% [+6.7%, +8.2%] 🔵 +0.6% [-0.0%, +1.2%]

Copy link
Member

@EwoutH EwoutH left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

docs/tutorials/intro_tutorial.ipynb Outdated Show resolved Hide resolved
@EwoutH
Copy link
Member

EwoutH commented Dec 9, 2024

I did assign @ashish-nagmoti to issue #2537 by the way. Next time please do check if an issue is assigned, and if it is, ask first.

@ashish-nagmoti would you like to review this PR instead?

@EwoutH EwoutH added the docs Release notes label label Dec 9, 2024
@DarshPareek
Copy link
Author

In the latest update I have changed the arguments to be more explicit in create_agents function and added

x = self.rng.integers(0, self.grid.width, size=(n,)) 
y = self.rng.integers(0, self.grid.height, size=(n,))

to make positioning of agents better

Copy link
Member

@EwoutH EwoutH left a comment

Choose a reason for hiding this comment

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

I’m good, but let’s see if Jan also is.

@quaquel
Copy link
Member

quaquel commented Dec 10, 2024

I am fine with this, although I personally would prefer to move self.grid.place_agent(a, (i, j)) into the MoneyAgent.

@EwoutH
Copy link
Member

EwoutH commented Dec 10, 2024

Personally I won't bother with updating the old spaces, we will replace them soon anyways.

@DarshPareek Could you make your PR title and description a bit more clear/descriptive?

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

Successfully merging this pull request may close these issues.

3 participants