mesa icon indicating copy to clipboard operation
mesa copied to clipboard

Implement experimental DataCollector API v3

Open rht opened this issue 1 year ago β€’ 6 comments

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:

  1. You can collect based on agent types using custom groups
  2. Also via custom groups
  3. Single-use measure is not yet addressed
  4. Not yet measured for performance
  5. There is to_df in this PR, and this feature is actually used in visualization
  6. TODO
  7. TODO, but this doesn't affect the API
  8. I prefer 2-level grouping instead of flat dictionary. This allows for easy export to DF
  9. TODO

and https://github.com/projectmesa/mesa/discussions/1944#discussioncomment-8439418:

  1. same as 2 above
  2. already implemented
  3. already implemented in to_df

TODO:

  • [ ] error handling
  • [ ] documentation
  • [ ] testing
  • [ ] examples

rht avatar Aug 10 '24 14:08 rht

For example, see https://github.com/projectmesa/mesa-examples/pull/151.

rht avatar Aug 10 '24 14:08 rht

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%]

github-actions[bot] avatar Aug 10 '24 14:08 github-actions[bot]

Thanks for this effort! It doesn’t look too bad, could you give some example usages of more complicated usage scenarios?

EwoutH avatar Aug 10 '24 15:08 EwoutH

Which example do you want me to port? Is wolf-sheep (agents by type) sufficient?

rht avatar Aug 10 '24 18:08 rht

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 avatar Aug 10 '24 18:08 EwoutH

@EwoutH this should be a sufficient illustration: https://github.com/projectmesa/mesa-examples/pull/158. It has agents by type.

rht avatar Aug 13 '24 14:08 rht