Yes, just the First Approach. (It has four parts.) Alan Isaac
2) Is there supposed to be a specific stopping criteria for our move procedures? When I reread Part I, I feel like there should be 1) a possibility for a full Moore neighborhood to be occupied, but given my current world that seems unlikely and 2) that there should be some limitations on move if the neighborhood is full.
the move action must terminate, even if all neighboring locations are occupied (This is a requirement imposed on your move algorithm.)
""" Template Model 4: Probe Object State """
from Template_Model_Part_3 import *
class GUI04(GridWorldGUI):
def gui(self):
self.add_button('Set Up', 'setup')
self.add_button('Run','run')
self.add_button('Stop','stop')
self.add_slider('Initial Number of Agents','n_agents',10,200,10)
self.add_slider('Maximum Extraction Rate','agent_max_ext',0.0,2.0,0.1)
def get_agent_sizes():
agents=self.subject.get_agents(self.subject.AgentType)
return list(agent.size for agent in agents)
class World04(World03):
def schedule(self):
ask(self.patches, 'produce')
ask(self.agents, 'move')
ask(self.agents, 'change_size')
n_agents = number_of_agents
agent_max_ext =agent_max_extract
if __name__ == '__main__':
myworld = World04(topology=TorusGrid(shape=world_shape))
mypatches = myworld.create_patches(Cell03) #setup patches
myagents = myworld.create_agents(New_Agent3, number=number_of_agents)
myobserver = GUI04(myworld)
for i in range(1,maximum_iterations):
stopping_condition= max(myobserver.get_agent_sizes)
if stopping_condition <100:
myworld.run()
"""
References
Isaac, A. G. (2011). The ABM template models: A reformulation with reference implementations. Journal of Artificial
Societies and Social Simulation 14(5), http://jasss.soc.surrey.ac.uk/14/2/5.html.
"""
For each iteration, the model checks the max size of all the agents, and as long as this value falls below 100, the model is run.
for i in range(1,maximum_iterations):
stopping_condition= max(myobserver.get_agent_sizes)
if stopping_condition >= 100:
myworld.stop()
stopping_condition= max(myobserver.get_agent_sizes())
if stopping_condition >= 100:
However, where exactly in the following run code from source to implement this stopping condition is a bit puzzling:
"""Return None. Run the simulation by repeatedly calling the schedule. """ maxiter = maxiter or self.maxiter self._stop = False while self.keep_running() \ and (self._iteration < (maxiter or self._iteration+1)): self._iteration += 1 #self.logger.debug('Begin iteration {0}'.format(self._iteration)) self.notify_observers('_begin_iteration') #schedule is run once each iteration self.schedule() #updating can be less frequent if not (self._iteration % self._update_frequency): #self.logger.debug('_update') self.notify_observers('update') self.notify_observers('_end_iteration') #self.logger.debug('End iteration {0}'.format(self._iteration)) self.clean_up()