nkremerh / sugarscape

Development repository for the Digital Terraria Lab implementation of the Sugarscape agent-based societal simulation.
https://github.com/digital-terraria-lab/sugarscape
MIT License
7 stars 12 forks source link

bentham*LookaheadTop and egoist*LookaheadTop broken #19

Closed nkremerh closed 4 months ago

nkremerh commented 10 months ago

The behavior of the bentham*LookaheadTop and egoist*LookaheadTop decision models appears broken on first glance. Any model ending in Top should be selecting the locally optimum choice, yet this seems to always result in quick societal death during data collection (while the more naive Binary models do not). There is likely a logic bug that needs to be diagnosed and patched. Another avenue worth investigating is if the configuration options used during data collection prevent the Top models from making good choices.

nkremerh commented 8 months ago

Maybe fixed due to many code changes to agent decision model behavior. Will need to verify.

colinhanrahan commented 8 months ago

This might be affected by the naive extent calculation in ethics.py, which currently is highest when neighbor.vision is smallest rather than highest when the proportion of the current agent's neighborhood shared with the neighbor's neighborhood is highest.

nkremerh commented 8 months ago

Nevermind. When running the simulation out to 750 timesteps over 20 seeds, I get the following report:

        Decision Model         Died  Worse Better
    benthamNoLookaheadTop     :  20     0     0  
    egoisticNoLookaheadTop    :  20     0     0  
   benthamNoLookaheadBinary   :   0     0    20  
  egoisticNoLookaheadBinary   :  12     0     8  
        rawSugarscape         :  12     0     8
nkremerh commented 8 months ago

Same configuration while using the half lookahead decision models:

        Decision Model         Died  Worse Better
   benthamHalfLookaheadTop    :   1     0    19  
   egoisticHalfLookaheadTop   :   6     0    14  
  benthamHalfLookaheadBinary  :   0     0    20  
 egoisticHalfLookaheadBinary  :  10     1     9  
        rawSugarscape         :  15     0     5
colinhanrahan commented 8 months ago

A benthamNoLookaheadBinary timestep: Screenshot 2024-02-28 8 23 02 PM A benthamNoLookaheadTop timestep: Screenshot 2024-02-28 8 22 06 PM I might just be hallucinating, but it really seems like *Binary simulations are more likely to place agents in cells with von Neumann-adjacent agents and *Top models shy away from this behavior, leading to much lower reproduction rates. This is speculation, but you can step through a few seeds yourself and see what you think. The ethical calculation might apply some penalty when moving to cells with von Neumann-adjacent agents (certainty might have something to do with it). This penalty could be overlooked in the randomness of *Binary but still show up in *Top.

I'll test radial vision/movement and, if necessary, add Moore neighbor reproduction to further investigate this.

colinhanrahan commented 8 months ago

Setting certainty to 1 (removing it from the equation) does improve the survival of *Top models but causes interesting clumping behavior and a relatively unsuccessful population over time (~200 agents, sometimes increasing or decreasing). Screenshot 2024-02-28 9 02 52 PM It might be worth running a larger test with certainty removed just to see what happens.

colinhanrahan commented 8 months ago

I think I figured something out. Picture a cardinal agent with 3 agents in the neighborhood on the vertical axis and 0 agents on the horizontal axis. For any cell on the vertical axis, those other agents might be able to move there, so you'll get opportunity costs from all of them and subtract from the ethical score of the cell. However, none of the agents on the vertical axis can see any of the cells on the horizontal axis, so the opportunity costs will be 0. So opportunity costs incentivize agents to "stay out of each other's sights." Even with radial vision and movement, I think agents will be hesitant to get too close to each other (using *Top decision) because opportunity costs from other close agents will outweigh the benefits of the cell, encouraging agents to move out of other agents' visions. Using a *Binary model, agents will be von Neumann neighbors to each other more often just by random chance, spawning more children overall.

Out of curiosity, I just tried removing opportunity costs (removing the multiplications by -1, everything else is the same) and my *Top model was very successful. I don't fully understand why, given that the calculated neighborValueOfCells are not real and will not ever be real for the neighbor. Maybe it's closer to egoism — a decent cell with sugar and spice would be good for any agent, so it's good for the current agent?

Logically, opportunity costs should not be removed. However, I'm concerned that the current felicific calculus inherently encourages agents to stay away from each other, because we are not considering the positive effects of closeness and von Neumann neighbors like trading and reproduction. I think that the interaction between opportunity costs and reproduction should be changed in order to ensure the success of *Top models. Something like a fully implemented findPotentialNiceOfCell() would probably better demonstrate *Top's abilities.

nkremerh commented 4 months ago

Update on this after the plethora of changes this summer:

Model population performance:
        Decision Model         Extinct Worse Better
        benthamBinary         :   4     0    196 
          benthamTop          :  40     0    160

The Top model doesn't seem as absolutely self-destructive as before. The average population was around 600 for Top (around 800 if you don't count the extinct societies) while around 1,100 for Binary (same when counting extinct societies, we were unlucky with those 4 seeds, it's usually 0 or 1 extinction per 100 seeds).

I will perform the same experiment and crank up the selfishnessFactor to 75% to see if that's necessary for the Top model to dominate. Looking at the graphs without counting the extinctions, the Top model performs very slightly above the Binary model in all but population.

Edit: dialing up selfishnessFactor to 75% did not meaningfully change any outcomes. The results remain the same.

Closing this issue for now as the catastrophic outcomes previously encountered in the Top models seem to have been resolved now.