Skip to content

Improve flocking benchmark #2054

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Feb 26, 2024
Merged

Improve flocking benchmark #2054

merged 2 commits into from
Feb 26, 2024

Conversation

coderbeta1
Copy link
Contributor

Changes Made:

  1. Changed self.velocity to self.direction: Both Velocity and Speed are agent attributes. This leads to unnecessary confusion. So I changed velocity to direction
  2. Seed: It is now not compulsory to give a seed value. This allows for easy randomness if needed.
  3. Default values: Code will work even if model values are not given
  4. General Changes: Made the code more descriptive for beginners

@coderbeta1 coderbeta1 marked this pull request as ready for review February 25, 2024 14:51
Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
Schelling small 🔵 +0.7% [+0.3%, +1.2%] 🔵 -0.4% [-0.6%, -0.2%]
Schelling large 🔵 +12.4% [-17.6%, +54.6%] 🔵 -3.4% [-4.3%, -2.5%]
WolfSheep small 🔵 -0.4% [-0.9%, +0.1%] 🔵 +0.1% [-0.1%, +0.3%]
WolfSheep large 🔵 +17.3% [-0.3%, +42.0%] 🔵 +0.4% [-1.0%, +1.6%]
BoidFlockers small 🔴 +6.7% [+5.7%, +7.5%] 🔵 +2.2% [+1.4%, +2.9%]
BoidFlockers large 🔴 +6.1% [+5.7%, +6.6%] 🔵 +2.5% [+2.0%, +3.1%]

Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
Schelling small 🔵 +0.1% [-0.3%, +0.5%] 🔵 -0.1% [-0.3%, +0.1%]
Schelling large 🔵 +11.3% [-19.9%, +51.4%] 🔵 -1.5% [-4.3%, +1.5%]
WolfSheep small 🔵 -0.6% [-1.1%, -0.1%] 🔵 +0.1% [-0.2%, +0.3%]
WolfSheep large 🔵 +14.7% [-2.6%, +38.8%] 🔵 -2.7% [-4.6%, -0.9%]
BoidFlockers small 🔵 +2.1% [+1.6%, +2.7%] 🔵 -2.1% [-2.8%, -1.4%]
BoidFlockers large 🔵 +2.4% [+1.8%, +3.0%] 🔵 +0.2% [-0.4%, +0.9%]

@@ -136,15 +137,15 @@ def make_agents(self):
x = self.random.random() * self.space.x_max
y = self.random.random() * self.space.y_max
pos = np.array((x, y))
velocity = np.random.random(2) * 2 - 1
direction = np.random.random(2) * 2 - 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I just saw the docstring says "headings" and this needs to be replaced with "directions" as well.

@rht
Copy link
Contributor

rht commented Feb 25, 2024

@coderbeta1 thank you for the needed corrections and improvements to the examples so far.

@coderbeta1 coderbeta1 requested a review from rht February 26, 2024 11:42
@rht rht merged commit 0ef48c0 into projectmesa:main Feb 26, 2024
quaquel pushed a commit to quaquel/mesa that referenced this pull request Apr 9, 2024
* Improve flocking

* Update flocking.py
@EwoutH EwoutH added the enhancement Release notes label label Apr 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement Release notes label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants