Skip to content

Make random number generator optional in creation of AgentSet, take R… #2789

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

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

Conversation

verisimilidude2
Copy link

Merge branch into main

Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.7% [-1.4%, -0.1%] 🔵 -0.6% [-0.9%, -0.4%]
BoltzmannWealth large 🔵 -0.6% [-1.5%, +0.3%] 🔵 -1.6% [-3.9%, +0.5%]
Schelling small 🔵 +0.1% [-0.1%, +0.3%] 🔵 -0.4% [-0.7%, -0.1%]
Schelling large 🔵 -0.3% [-0.9%, +0.2%] 🔵 -0.5% [-2.1%, +0.8%]
WolfSheep small 🔵 -0.1% [-0.4%, +0.2%] 🔵 +0.3% [+0.1%, +0.5%]
WolfSheep large 🔵 -0.4% [-1.4%, +0.7%] 🔵 -0.0% [-0.4%, +0.5%]
BoidFlockers small 🔵 -0.8% [-1.3%, -0.2%] 🔵 -0.5% [-0.7%, -0.2%]
BoidFlockers large 🔵 +0.4% [-0.5%, +1.1%] 🔵 -0.0% [-0.4%, +0.3%]

@verisimilidude2
Copy link
Author

Change int cast that Ruff complained about

@quaquel
Copy link
Member

quaquel commented May 20, 2025

Looks good to me. A few minor requests

  1. Can you expand the PR description
  2. Can you resolve the conflict

Thanks!

@jackiekazil
Copy link
Member

Agree with @quaquel.
Thank you for the contribution @verisimilidude2! Looking forward to getting this merged in with those updates.

@jackiekazil jackiekazil added the bug Release notes label label May 21, 2025
@verisimilidude2
Copy link
Author

@quaquel I'm not sure how one changes the PR description. The diff on the note on the AgentSet class pretty much describes what I did:
Was:
A UserWarning is issued if random=None. You can resolve this warning by explicitly
passing a random number generator. In most cases, this will be the seeded random number
generator in the model. So, you would do random=self.random in a Model or Agent instance.
Now:
If random is None then the random number generator in the model of the first agent is used.
If the agents list is empty a user warning is issued and the agent set is an empty list
with no random number generator

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

Successfully merging this pull request may close these issues.

3 participants