Implement experimental DataCollector API v3
Given that the fall semester is starting soon, there is not enough time to build a comprehensive new data collection API. So this is what I have cooked this afternoon. It addresses https://github.com/projectmesa/mesa/discussions/1944#discussioncomment-8364109:
- You can collect based on agent types using custom groups
- Also via custom groups
- Single-use measure is not yet addressed
- Not yet measured for performance
- There is
to_dfin this PR, and this feature is actually used in visualization - TODO
- TODO, but this doesn't affect the API
- I prefer 2-level grouping instead of flat dictionary. This allows for easy export to DF
- TODO
and https://github.com/projectmesa/mesa/discussions/1944#discussioncomment-8439418:
- same as 2 above
- already implemented
- already implemented in
to_df
TODO:
- [ ] error handling
- [ ] documentation
- [ ] testing
- [ ] examples
For example, see https://github.com/projectmesa/mesa-examples/pull/151.
Performance benchmarks:
| Model | Size | Init time [95% CI] | Run time [95% CI] |
|---|---|---|---|
| Schelling | small | π΅ -0.2% [-0.5%, +0.1%] | π΅ -0.7% [-0.8%, -0.5%] |
| Schelling | large | π΅ +0.3% [-0.6%, +1.1%] | π΅ -0.2% [-0.8%, +0.4%] |
| WolfSheep | small | π΅ -0.4% [-1.6%, +0.9%] | π΅ -0.7% [-1.0%, -0.4%] |
| WolfSheep | large | π΅ -0.9% [-1.6%, -0.3%] | π΅ -1.1% [-2.5%, -0.2%] |
| BoidFlockers | small | π΅ -1.3% [-1.8%, -0.7%] | π΅ -0.6% [-1.3%, +0.1%] |
| BoidFlockers | large | π΅ -1.2% [-1.8%, -0.8%] | π΅ +0.0% [-0.6%, +0.7%] |
Thanks for this effort! It doesnβt look too bad, could you give some example usages of more complicated usage scenarios?
Which example do you want me to port? Is wolf-sheep (agents by type) sufficient?
I don't need a full model port, I would like some (more complex) API usage examples. Something in the form of:
- https://github.com/projectmesa/mesa/discussions/1944#discussion-6040717
- https://github.com/projectmesa/mesa/issues/348#issuecomment-1777533710
@EwoutH this should be a sufficient illustration: https://github.com/projectmesa/mesa-examples/pull/158. It has agents by type.