swarm-support
[Top][All Lists]
Advanced

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

Re: freedom using Activity


From: Paul E. Johnson
Subject: Re: freedom using Activity
Date: Tue, 09 May 2000 08:45:34 -0500

David Aliaga wrote:
>> 
> But I would like to
> write using the Swarm style and philosophy.The problem
> is I feel limitations in the "Activity" part of the
> coding.
> 
> For example. In C-style I have this
> 
> Run_simulation()
> {
>   Initialize_positions();
> 
>   while( not condition)
>     {
>       Execute_trials();
>       Move_some_positions();
>      }
> }
> 
> Execute_trials()
> {
>    while(alive)
>    {
>      agents_do_A();
>      agents_do_B();
>      agents_do_C();
> }
> 
> That means that I do Execute_trials until the agent
> "die", then change something and run again the trial.
> I have no idea how to implement these 2 levels in
> swarm, especially because in the examples the agents
> seem to live "forever"
> I can make some code to accomplish what I want but I
> feel its forced and not natural, for example:
> 
> mact=[actionGroup create:self];
> [mact createActionForEach: agentlist message:
> M(action_A)];
> [mact createActionForEach: agentlist message:
> M(action_B)];
> [mact createActionForEach: agentlist message:
> M(action_C)];
> [mact createActionForEach: agentlist message:
> M(verify_if_alive)];
> [mact createActionForEach: agentlist message:
> M(move_something_if_dead)];
> 
> and then put mact in schedule but I still feel it is
> not the swarm way forcing 2 levels into one. any
> opinion.
> 
> Thank You
> 
> David
Welcome to the group.  I think in the User Guide there is a section "How
do I kill off those poor devils" or something like that, and it is based
on the example code "sss", the swarm sugar scape.  You can get that in
the swarm ftp.  That model has agents that can get killed and removed
from the simulation.  The basic idea is to put some kind of a method in
the agent itself so it knows when to die.  Then it messages to the model
swarm and tells it "kill me" and the model swarm adds that agent to a
list of victims to be recycled at a later time, when it is safe.  The
recycler removes the agents from the list of agents and does other
cleanup. 

The sort of schedule you have works well, because the agents can be
removed from the list in the recycler and the operations go on and are
applied to the ones that remain.  The last two steps you have appear to
be basically within the spirit of sss.

I don't think I quite understand the part of your question about doing
something over after the agents die.  If the sim is ongoing, you can
create new agents and let the model run additional steps.  Swarm seems
to me mostly intended to run a model one time.  We've worked on an
example of a simultion that can repeat, but it doesn't work the way I'd
like.  I think if you are planning to process something over and over
again, you might consider making you app accept command line arguments. 
I've been working on a thing about that, perhaps you will be a tester:

http://lark.cc.ukans.edu/~pauljohn/ps909/simpleObserverBug3-5.tar.gz

If you want to run something over and over again, design the simulation
so it can take command line parameters.


-- 
Paul E. Johnson                         email: address@hidden
Dept. of Political Science              http://lark.cc.ukans.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]