-
Notifications
You must be signed in to change notification settings - Fork 948
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
DataCollector requires all agents to have the same Attributes #976
Comments
I would add the attribute with a default of |
@JonasJosef123 there is one alternative solution: in the data collector, instead of doing |
It's similar to the dictionary method |
Hello everybody! |
@TabernaA I would have to take a deeper look, but I think this is possible. For a maybe a quick solution did you look at the the Wolf-Sheep example which uses breeds of agents? https://github.com/projectmesa/mesa/tree/master/examples/wolf_sheep |
Yes, I do. But what I need is not the breed count but agent level variable. I am simply using lambda with the 'if condition' to keep only the type of agent I need and put None otherwise. The only problem is that it slows down a little bit the run and I have to manipulate a bit the dataframe afterwards. |
@TabernaA does #976 (comment) not answer the problem with defaulting to |
@JonasJosef123 In the last month there has been some discussion about this feature going on in #1419, you might find that interesting to follow! :) |
closed via #2300 |
Yes, we added the self.datacollector = DataCollector(
agenttype_reporters={
Wolf: {"sheep_eaten": "sheep_eaten"},
Sheep: {"wool": "wool_amount"}
}
) See #2300 for details indeed! |
What's the problem this feature will solve?
Hello @ALL
I am not sure if I am actually doing something wrong but in my code I have two different agents types that get different attributes when created. (however they are from the same agent class)
When I want to collect their specific attribute data with the data collector i get an "AttributeError" that my agents object has no such attribute. While this is true for agents 1-4 i created, agents 5-20 have that specific attribute. The only solution I found was to create the same attribute for the first 4 agents aswell and initialize it with None. For me this makes the code unnecessary flatulent. Is there a smart way around? For me it would be intuitive to check if the agent has this attribute and if not to automatically put "None" as a placeholder for the datacollector.
I am not really experience with python and mesa so I dont know if there exist some best practice solution to create different agents only through different classes or something like this.
Thanks for your help!
best regards,
Jonas
The text was updated successfully, but these errors were encountered: