mesa icon indicating copy to clipboard operation
mesa copied to clipboard

Add support for drawing discrete grids

Open quaquel opened this issue 1 year ago • 3 comments

Addresses #2377. This code needs refinement (e.g., duplication of agent potrayal code from voroinoi grid).

@Corvince, @EwoutH any pointers on how to develop and test this type of thing?

I am pretty sure the code is correct, but if I try to run one of the examples with it from the command line, it errors (because it uses the wrong mesa version).

quaquel avatar Oct 18 '24 16:10 quaquel

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.8% [-2.2%, +0.7%] 🔵 +0.5% [+0.3%, +0.7%]
BoltzmannWealth large 🔵 -1.4% [-1.8%, -1.0%] 🔵 -2.5% [-3.0%, -1.9%]
Schelling small 🔵 -1.6% [-1.9%, -1.4%] 🔵 -1.4% [-1.6%, -1.1%]
Schelling large 🔵 -0.9% [-1.9%, -0.0%] 🟢 -5.2% [-6.3%, -3.9%]
WolfSheep small 🔵 -1.0% [-1.3%, -0.8%] 🔵 -0.9% [-1.1%, -0.7%]
WolfSheep large 🔵 +0.8% [-0.0%, +1.8%] 🔵 +0.3% [-1.7%, +2.7%]
BoidFlockers small 🔵 -1.0% [-1.7%, -0.2%] 🔵 -0.9% [-1.8%, +0.1%]
BoidFlockers large 🔵 -1.1% [-1.8%, -0.4%] 🔵 -1.2% [-1.8%, -0.7%]

github-actions[bot] avatar Oct 18 '24 16:10 github-actions[bot]

Uninstall your current mesa, pip install . -e and then solara run app.py is what I found out working.

EwoutH avatar Oct 19 '24 08:10 EwoutH

Uninstall your current mesa, pip install . -e and then solara run app.py is what I found out working.

Thanks! This gave me the idea for a slightly different approach: insert the correct version of mesa into sys.path at the top. Based on this, I can confirm that this code works as intended.

Let me know what else would be needed to complete this PR since its my first contribution to the visualization side of things.

quaquel avatar Oct 19 '24 17:10 quaquel

insert the correct version of mesa into sys.path at the top. Based on this, I can confirm that this code works as intended.

That's the other obvious way to go, both have their advantages based on what your working on.

@Corvince I'm also quite new to this stack, could you please review this one?

EwoutH avatar Oct 20 '24 16:10 EwoutH

One improvement for this function would be to use the _get_agent_data when drawing the new grids. I got a weird error, and using _get_agent_data would have prevented and handled that. I wrote it up here:

  • #2407

EwoutH avatar Oct 23 '24 19:10 EwoutH

One improvement for this function would be to use the _get_agent_data when drawing the new grids. I got a weird error, and using _get_agent_data would have prevented and handled that

I looked at that and I could not use it because that method is hard coded to only work with _Grid: for agents, pos in space.coord_iter().

quaquel avatar Oct 23 '24 20:10 quaquel