swarm-support
[Top][All Lists]
Advanced

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

Problem with removing agent from the model in java swarm


From: Hu, Jianjun
Subject: Problem with removing agent from the model in java swarm
Date: Fri, 21 Jun 2002 10:37:31 -0400

I am running difficulty into the javaswarm when I want to remove the agent
from the agent  list.  I just can't remove the dead agent from the list.
In addition, when I add some new agent to the list,  these agents just be
neglected by the swarm kernel and won't get executed.
I am using swarm2.1.1 java version.

I guess the problem is that the javaswarm use the iterator to trace the
agent list when I register this list in buildaction. but later when I update
the agent list by removing or adding agents, the iterator that the kernel
keeps just fails and become invalid.

What's the solution or other possible reason?



In my  doveModelSwarm class's buildobject function, I add the intial list of
agent just like heatbugs
                tadpoleLayer.agentList =  new ArrayList();


                //create the tadpoles
                for( i=0;i<nTadples;i++){
                QTadpole newTadpole = new QTadpole(tadpoleLayer,this);
                tadpoleLayer.agentList.add(newTadpole );
                }
In buildaction function:  I register the agentlist for  simulation

    try {
      QTadpole proto = (QTadpole) tadpoleLayer.getAgentList().get (0);
      Selector sel =
        new Selector (proto.getClass (), "update", false);
      actionForEach =
        modelActions.createFActionForEachHomogeneous$call
        (tadpoleLayer.getAgentList(),
         new FCallImpl (this, proto, sel,
                        new FArgumentsImpl (this, sel, true)));
    } catch (Exception e) {
      e.printStackTrace (System.err);
    }

But after some steps, when I add new agent by
agentList.add(newAgent);
these agents are  just neglected by the kernel.

when I use agentList.remove(oldAgent).
This old agent can't be removed.


hmm????


Thank you very much

Jianjun Hu















                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

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