Closed colinhanrahan closed 3 months ago
What if I told you this actually cut runtime in half?
I ran the same 100 seeds out to 500 timesteps (for ease of data collection) for the head of the current master branch and this branch using the benthamHalfLookahead
decision model. Both branches produced 100% better outcomes from their starting populations (this number can be obtained by running make plots
).
This branch, however, produced 10% lower population on average (1,000 for the master branch vs. 900 for this branch). Every other metric tracked was more or less the same.
Time for master branch:
real 13m56.042s
user 263m53.385s
sys 0m9.615s
Time for this branch:
real 7m49.831s
user 138m14.411s
sys 0m7.189s
Thoughts? Population size definitely contributes the most to runtime. A 10% difference in population leading to a nearly 50% reduction in runtime seems a bit extreme.
Comparing the two branches using Snakeviz on the same seed (and using benthamHalfLookaheadBinary
), it seems like almost every function is getting its runtime halved. That's pretty odd. Maybe the 10% difference is actually causing that big of a difference? I'll investigate this more.
- Updates agent initialization to find
cellsInRange
andneighborhood
, matching child creation
This addition is redundant with sugarscape.py
lines 144-146. The sugarscape.py
lines should be kept and my addition will be removed because all agents need to be created first in order for neighborhoods to be correct on the first timestep.
I ran a test on both branches where I ended runs based on the number of agents (I ended at 500) instead of the number of timesteps. This PR is more time intensive as expected. If you want to mass test this, modify line 604 in sugarscape.py
:
- while t <= timesteps and len(self.agents) > 0:
+ while t <= timesteps and len(self.agents) > 0 and len(self.agents) <= 500:
Note: one more findCellsInRange()
should be added to catchDisease()
for agents who already had their timestep but are catching a disease from another agent. I'll add it to the Kanban board.
56
cellsInRange
andneighborhood
, matching child creationcellsInRange
after they move to correctly reflect range after being cured by disease and in other agent's ethical calculationsJust for future reference, this will definitely increase runtime.