Skip to content

World prototype#3034

Closed
EwoutH wants to merge 8 commits intomesa:mainfrom
EwoutH:world
Closed

World prototype#3034
EwoutH wants to merge 8 commits intomesa:mainfrom
EwoutH:world

Conversation

@EwoutH
Copy link
Copy Markdown
Member

@EwoutH EwoutH commented Dec 28, 2025

Some pathfinding on the World idea.

So far:

  • Implemented the World part (the continuous stuff)
  • Updated on example model (boid flockers). Seems to work (valid behavior) but updating visualisation is a bitch (so much space type checks everywhere...)
boid_flockers.mp4

TODO:

  • Write tests
  • Integrate with discrete spaces

@EwoutH EwoutH added the feature Release notes label label Dec 28, 2025
@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.2% [-0.5%, +0.2%] 🔵 -0.3% [-0.4%, -0.1%]
BoltzmannWealth large 🔵 -2.1% [-2.6%, -1.8%] 🔵 -0.6% [-1.3%, +0.0%]
Schelling small 🔵 -1.1% [-2.0%, -0.1%] 🔵 -2.5% [-2.9%, -2.0%]
Schelling large 🔵 -0.8% [-1.3%, -0.3%] 🔵 +0.2% [-0.6%, +1.0%]
WolfSheep small 🔵 -2.9% [-3.7%, -2.2%] 🔵 -0.9% [-1.2%, -0.7%]
WolfSheep large 🔵 -4.2% [-7.6%, -2.1%] 🔵 -0.8% [-1.3%, -0.4%]
BoidFlockers small 🟢 -24.0% [-24.4%, -23.7%] 🔴 +1277.5% [+1271.7%, +1283.2%]
BoidFlockers large 🟢 -28.5% [-29.0%, -27.9%] 🔴 +1942.7% [+1936.5%, +1948.2%]

- Vectorized get_neighbors_in_radius()
- New calculate_difference_vectors() method
Uses calculate_difference_vectors() to get all deltas at once
Computes distances with vectorized np.linalg.norm(deltas, axis=1)
Uses boolean masking (close_mask = distances < self.separation) instead of filtering
All neighbor direction aggregation is vectorized

The main bottleneck (neighbor finding + distance calculations):
- Old: O(n) Python loop with individual distance calculations
- New: O(1) numpy array operations on all n agents at once
@EwoutH EwoutH added trigger-benchmarks Special label that triggers the benchmarking CI and removed trigger-benchmarks Special label that triggers the benchmarking CI labels Dec 28, 2025
@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +1.5% [+1.2%, +1.9%] 🔵 -0.5% [-0.7%, -0.4%]
BoltzmannWealth large 🔵 +1.1% [+0.7%, +1.5%] 🔵 +1.5% [+0.7%, +2.2%]
Schelling small 🔵 +0.5% [-0.5%, +1.5%] 🔵 -0.6% [-1.1%, -0.1%]
Schelling large 🔵 +1.3% [+0.2%, +2.5%] 🔵 +2.2% [+1.1%, +3.5%]
WolfSheep small 🔵 -0.2% [-1.0%, +0.5%] 🔵 -0.0% [-0.2%, +0.1%]
WolfSheep large 🔵 -0.3% [-4.7%, +2.7%] 🔵 +5.0% [+2.4%, +7.6%]
BoidFlockers small 🟢 -21.7% [-22.0%, -21.4%] 🔴 +119.7% [+118.9%, +120.5%]
BoidFlockers large 🟢 -26.7% [-27.4%, -26.0%] 🔴 +167.5% [+166.6%, +168.5%]

@EwoutH EwoutH added trigger-benchmarks Special label that triggers the benchmarking CI and removed trigger-benchmarks Special label that triggers the benchmarking CI labels Dec 28, 2025
@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -2.3% [-3.2%, -1.3%] 🔵 +0.1% [-0.0%, +0.2%]
BoltzmannWealth large 🔵 +0.3% [-0.6%, +1.5%] 🔵 +3.2% [+0.1%, +7.1%]
Schelling small 🔵 -0.3% [-1.3%, +0.7%] 🔵 -0.4% [-0.9%, +0.1%]
Schelling large 🔵 -0.4% [-1.0%, +0.0%] 🔵 -0.2% [-1.3%, +1.0%]
WolfSheep small 🔵 -1.0% [-1.9%, -0.4%] 🔵 +0.8% [+0.6%, +0.9%]
WolfSheep large 🔵 -1.6% [-5.0%, +0.3%] 🔵 -0.5% [-1.9%, +0.8%]
BoidFlockers small 🟢 -27.9% [-28.3%, -27.5%] 🔴 +127.3% [+126.5%, +128.3%]
BoidFlockers large 🟢 -30.7% [-31.0%, -30.4%] 🔴 +186.2% [+185.4%, +187.1%]

@EwoutH
Copy link
Copy Markdown
Member Author

EwoutH commented Dec 28, 2025

Not ideal, not disastrous. Our current ContinuousSpace implementation is quite good.

I'm building some intuition at least.

@EwoutH
Copy link
Copy Markdown
Member Author

EwoutH commented Jan 22, 2026

To be continued in #2585

@EwoutH EwoutH closed this Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant