-
Notifications
You must be signed in to change notification settings - Fork 12
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
Adds real metrics for diseases to the log #115
base: master
Are you sure you want to change the base?
Conversation
I ran into an issue where if you change the number of starting diseases per agent, in sugarscape.py, each disease is added multiple times. The number of times it's added is not correlated with the number of starting diseases per agent either. |
The intended behavior is that |
@colinhanrahan Everything in config.json is the same except startingDiseasesPerAgent is anything but [0, 0]. |
Everything I'm seeing with |
@colinhanrahan sugarscape.py, line 178-201
The disease loop is in the agent loop, so if an agent gets assigned the same disease as another agent, a duplicate is appended to self.diseases |
Oh, I see. You can either put that in a conditional and only add the disease if it's not already in For more built-in stability, we could use a set since diseases are unique and unordered. |
I'm not sure if this is an error, but when |
It's not an error with the current implementation, but we could change the implementation if necessary. We endow each agent with
|
I consolidated the diseases' metrics so far into the logfile. The naming scheme so far is runtimeStats["disease{disease.ID}{metric}"]. |
Yeah, it looks like CSV variables are sorted alphabetically (
diseaseStats = {f"disease{disease.ID}RValue": 0 for disease in self.diseases}
self.runtimeStats.update(diseaseStats) And runtime stats are sorted alphabetically in
+3. Maybe the runtime stats don't need to be sorted at all — you could ask NKH when he becomes available again. They should be in a consistent order regardless so I don't understand the comment Edit: the above comment might have been because dictionaries didn't officially maintain insertion order until Python 3.7. If that is the case, we should be good to remove the sorting. |
I started implemented my feature to start diseases at different set timesteps. However, if the |
I'm also not sure where to put the |
How is the start timestep per disease intented to work with I'm also seeing some zombie agents that don't move but don't die — I'll investigate this, but these are always caused by agents being removed from |
The disease is assigned a randomized timestep and then entered in a 2D array called |
Edit: Move it to after |
I moved it to after |
Move it into self.timestep += 1
self.infectAgents()
if self.end == True or (len(self.agents) == 0 and self.keepAlive == False):
self.toggleEnd() That seems to work pretty well on my side. |
I saw that you added another comment through my notifications, but I can't see it right now. If you deleted it please disregard. The diseases are introduced at the beginning of the timestep. If you're checking the diseases per agent at the end of the timestep (or after any agents have completed their their timestep), it's likely that the diseases will have spread ("duplicated"). If Do either of those fix your issue? If not, can you give me some more detail? |
There are some agents who do not move, and I don't know if it's because they can't move or they're zombies. |
Zombie agents will have negative sugar and metabolism and their age won't increase over time. Sick agents with 0 functional range will have 0 vision and/or 0 movement. |
I modified agent behavior to avoid any cell with sick agents in the vicinity when they're not sick, and to avoid only areas with the same tribe if the agent is sick. @colinhanrahan Can you please check that it is implemented correctly? |
A thought for the self-quarantining and the exiling behavior: These should be configurable parameters for the agent (such as That way, there's less likely to be gridlock. Agents may not find too many cells with good scores, but they're still likely to move since those cells next to sick/healthy individuals aren't completely removed from consideration. They're simply less appealing. |
@nkremerh the quarantine behavior is commented, and I believe everything is done that we were planning to add for now. |
Adds metrics for all diseases logged individually. Disease stats are currently stored in a separate log file, which can be either a CSV file or JSON file.