swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] How to remove agents in run-time?


From: Steve Railsback
Subject: Re: [Swarm-Support] How to remove agents in run-time?
Date: Mon, 06 Apr 2009 15:05:29 -0700
User-agent: Thunderbird 2.0.0.21 (X11/20090320)

Emerson Aguiar Noronha wrote:
Hello all,

In my simulation I need to remove agents in run-time, accordling to
agent's local rules. I've tried to do this using a method implemented in
the simulation's model. This method is called in ActionForEach, this code
remove an agent from the simulation's data structures, and I've tried to
remove it from the actionGroup in many ways.

What happens is that the agent is removed from the grid and from my
simulation's data structure. However, the swarm action still calls the
removed agent's step method. I've looked-up for this instance but I can't
found it.

Hello Emerson,

Are you scheduling the step method using an actionGroup and a statement something like: [stepActions createActionForEach: agentList message: M(step)] ?

To remove an agent so it no longer gets it's "step" method called, you need to remove it from the list used in the "createActionsForEach" statement (in the above example, "agentList"). (You also still need to remove it from all the grids and other data structures.)

Unfortunately, you cannot remove the agent from the list while the actionGroup is still executing: an agent cannot be removed from the agentList during it's "step" method, because that messes up the scheduler as it goes through the agentList telling each agent to do "step".

So the usual approach is, during "step", to put the agent to be removed on a list of dead agents. Then, add a separate action that happens after "step" that removes all the dead agents from the model.

There is an example in Version 12 of StupidModel, which you can get here:

http://condor.depaul.edu/~slytinen/abm/StupidModel/

Steve Railsback



reply via email to

[Prev in Thread] Current Thread [Next in Thread]