swarm-support
[Top][All Lists]
Advanced

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

Re: "at the same time"


From: Alex Lancaster
Subject: Re: "at the same time"
Date: 08 Jul 2000 04:37:58 -0600
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.6

>>>>> "DA" == David Aliaga <address@hidden> writes:

DA> Lets suppose I have 4 agents and everyone can do 3 actions:
DA> Action1 Action2 Action3

DA> So I make the following actiongroup:

DA> modelActions = [ActionGroup create: self];
DA> [modelActions createActionForEach: agentList  message: M(action1)];
DA> [modelActions createActionForEach: agentList  message: M(action2)];
DA> [modelActions createActionForEach: agentList  message: M(action3)];

DA> agentList is the list that has the agents

DA> It is suppose that all the actions in an action group happen "at
DA> the same time" but the question is How do they happen really?

DA> My 2 options are:

DA> -Agent1 Action1
DA> -Agent1 Action2
DA> -Agent1 Action3
DA> -Agent2 Action1
DA> -Agent2 Action2
DA> -Agent2 Action3
DA> -Agent3 Action1
DA> -Agent3 Action2
DA> -Agent3 Action3

DA> or: (what I think it is the most "correct")

DA> -Agent1 Action1
DA> -Agent2 Action1
DA> -Agent3 Action1
DA> -Agent4 Action1
DA> -Agent1 Action2
DA> -Agent2 Action2
DA> -Agent3 Action2
DA> -Agent4 Action2
DA> -Agent1 Action3
DA> -Agent2 Action3
DA> -Agent3 Action3
DA> -Agent4 Action3

In the example piece of code you have given above, you will get the
second kind of behaviour (which is, presumably, the one you want).  

By default, an "ActionGroup" is sequential, which means that the
Actions will be executed in the order that they are added in the code.
Since each of your Actions is actually a ForEachAction on a list, the
messages sent to each agent on the agentList will also be executed in
a sequential order (again a ForEachAction is sequential by default).
Which means that the "execution order" will be as you indicated in the
second example, of course as far as "simulation time" goes, they are
all executed at the same Swarm timestep.

DA> or there is no definite way to know (it is kind of random since it
DA> is "at the same time") Thanks

Swarm Schedules are never "random" (unless you want them to be), since
the points of Swarm is reproducibility, so there is always a definite
answer.  

If you wanted to have the order of ActionGroup be "random" (or in
reality "pseudorandom" since you can always generate the same sequence
given the same random number seed) then you would indicate that by
setting the "defaultOrder" on the ActionGroup to be "Randomized":

 modelActions = [[ActionGroup create: self] setDefaultOrder: Randomized];

[Note: This will randomize the order in which each of the for loops on
the agentList get executed, but _not_ on the order in which the lists
themselves, are traversed!]

Likewise for each of the forEach loops:

 [[modelActions createActionForEach: agentList  message: M(action1)]
                setDefaultOrder: Randomized];

etc...

In fact, if you wanted the first behaviour you could do something like
the following:

 modelActions = [ActionGroup create: self];
 [modelActions createActionForEach: agentList  message: M(actions)];

and then define a new method "actions" inside each agent:

 - actions {
    [self action1];
    [self action2];
    [self action3];
 }

or otherwise create a structure to ensure that each agent was sent the
each of the action1, action2, action3 in a sequential order.

Alex
-- 
Alex Lancaster * address@hidden * www.santafe.edu/~alex * 505 984-8800 x242
Santa Fe Institute (www.santafe.edu) & Swarm Development Group (www.swarm.org)


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