swarm-support
[Top][All Lists]
Advanced

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

Re: Is this the defects of Javaswarm? the swarm kernel neglect new added


From: Paul Johnson
Subject: Re: Is this the defects of Javaswarm? the swarm kernel neglect new added agents!
Date: Wed, 26 Jun 2002 09:32:13 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020606

I just noticed this letter from March in my Inbox, and I don't know that anybody has answered it.

To tell the truth, lately I have been circumventing this whole issue of createFActionForEach and such by just scheduing a method in ModelSwarm that simply iterates over the list. In my JelFarol (java El Farol) example (its in the ftp apps/java/contrib) I do it like this.

Here's a method that steps through the list

    public void stepAgents (){
        int x;
        Iterator iterator = agents.listIterator(0);
        Agent anAgent = null ;

        while (iterator.hasNext()){
            anAgent = (Agent) iterator.next();
            x = anAgent.makeChoice();
        }
     }



In buildActions, I have this:

   ActionGroup modelActions = new ActionGroupImpl(getZone());

  try {
            modelActions.createActionTo$message
(this, new Selector (this.getClass (), "stepAgents", false));
        } catch (Exception e) {
            e.printStackTrace (System.err);
            System.exit (1);
        }


        modelSchedule = new ScheduleImpl (getZone(), 1);
        modelSchedule.at$createAction (0, modelActions);


}

This approach works in a limited situation where you want all agents processed as a group in a certain section of time, and you don't want other actions to be thrown into the schedule in between your agents. This approach certainly does not work if you have 10 lists of agents and you want actions for them to be thrown onto the schedule at time X and then you expect Swarm to randomize them. But for one list, it makes sure they are handled.

This way is simpler and generally faster than the createFActionForEach regime. It is faster because it does not require the swarm scheduling system to do any work for each individual agent. All one must do is schedule a trip through the list.

I've been thinking a while, and I know a few people agree with me, that somebody ought to invest a lot of personal effort in writing down the convenient ways of scheduling in Swarm-2.1+. Marcus has provided useful notes here and there, but there still remains a pretty big translation job to synthesize it into a FAQ or User Guide. That is something that will probably get done as soon as I finish some other Swarm related jobs and member recruitment.


Hu, Jianjun wrote:

Help!

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


--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700




--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700


                 ==================================
  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]