Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement experimental DataCollector API v3 #2199

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

rht
Copy link
Contributor

@rht rht commented Aug 10, 2024

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 #1944 (comment):

  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 #1944 (comment):

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

TODO:

  • error handling
  • documentation
  • testing
  • examples

@rht
Copy link
Contributor Author

rht commented Aug 10, 2024

For example, see projectmesa/mesa-examples#151.

Copy link

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

if group is self.model:
return reporter(group)
if isinstance(reporter, str):
if hasattr(group, "get"):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be replaced with isinstance(group, AgentSet) or isinstance of Group.

@EwoutH
Copy link
Member

EwoutH commented Aug 10, 2024

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

@rht
Copy link
Contributor Author

rht commented Aug 10, 2024

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

@EwoutH
Copy link
Member

EwoutH commented Aug 10, 2024

I don't need a full model port, I would like some (more complex) API usage examples. Something in the form of:

@rht
Copy link
Contributor Author

rht commented Aug 13, 2024

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

@rht rht mentioned this pull request Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants