swarm-support
[Top][All Lists]
Advanced

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

scheduling and related questions


From: Rick Riolo
Subject: scheduling and related questions
Date: Mon, 26 Aug 1996 18:48:59 -0400 (EDT)

I have some questions, most related to scheduling of activity
(at one level or another).
Just a general note: what I'm looking for is not
abstract algorithms, but advice about what's the best
way to do this kinds of things in *Swarm*, i.e., given the way
Swarm objects like lists, indexes on them, etc, work.

Suppose I have a Pop object, which has
   id agents;     // a List 
which has a bunch of Agent objects in it.
Over time agents are created and destroyed.
(In one extreme case, they are *all* destroyed and
the list re-created each time step T.
In the other, sometimes none are changed during a time step.)
 
1. Suppose I want to activate my list of agents
   in a different random order each time step T.
   If I wanted to just have them processed in some
   unknown (but I assume fixed) order I guess I would send
   the following to my modelActions ActionGroup:   
      [modelActions createActionForEach: [pop getAgents] message: M(step)];
   as we see in heatbugs (if I recall correctly).
   A couple of questions: 
   a. What would I do to guarentee these agents are sent the step
      message in a different random order each time step T?
   b. How do I set the seed for whatever RNG Swarm uses
      for generating those agent list permutations down in schedules, 
      so that I can repeat the experiment exactly by setting the seed
      to a known seed once at the beginning of a run?

2. Suppose I have a small sublist of agent objects, eg suppose
   each agent has 
      id neighbors;   // a List of neighbor agents
   Suppose down in the [agent step] method somewhere I'd like to
   process an agent's neighbor list, again in a 
   different random order each time I go through it.
   What's the best (most efficient,cleanest) way to do that?

--------------------
Those first two questions I'd really like to know how to do well ASAP.
This last question is more just for my general edification.
So if you can quickly answer the first two and get to this one
later, that's fine!

Again, suppose I have a Pop object with 
 id  agents, newAgents;   // both are List's
with [pop getAgents] returning that first list.

3. I have a question about the following (admittedly naive) experiment.
   I set up a simple model schedule like this:

        modelActions = [ActionGroup create: [self getZone]];
        [modelActions createActionTo:      pop        message: 
M(startGeneration)];
        [modelActions createActionForEach: [pop getAgents] message: M(step)];
        [modelActions createActionTo:      pop        message: 
M(endGeneration)];

        modelSchedule = [Schedule createBegin: [self getZone]];
        [modelSchedule setRepeatInterval: 1];
        modelSchedule = [modelSchedule createEnd];
        [modelSchedule at: 0 createAction: modelActions];

    Now in [pop startGeneration] I wanted to use the current
    agent list (the list returned by [pop getAgents]) to create a list of
    newAgents, and then replace the current list of agents with those new ones.
    Then I wanted the step message to be sent to those new agents during 
    that same T step of the schedule.
    So (still thinking in non-objectiveC/Swarm terms) I put the 
    following in  pop-startGeneration:

        // do whatever to create the newAgents (all new objects) 
        // from the agents List, then...
        tmpList = agents;          // save pointer to agents
        agents = newAgents;        // agents now point to newAgents list 
        newAgents = tmpList;       // newAgents points to old list of agents
        [newAgents forEach: drop]; // get rid of those old agents!
        [newAgents removeAll];

    What I found was that during the T step right after this is first done,
    no agents get any of the messages sent to the agents in [pop getAgents].
    Then the next time step (new) agents do get messages.
    Then the next step none do, and so on.

    I gather that despite the fact that to me it looked like I was
    switching the agents id variable to point to the list of 
    new agents before (ie in pop-startGeneration) the schedule sends the 
    step message to the agents list, that's not what really happens.
    What does happen?

    What would be a good way to do this synchoronous creation
    of an entire new list of agents in pop-startGeneration,
    followed by sending all those new agents the step message?

thanks for your advice and help.

 - r
     
Rick Riolo                       address@hidden
Program for Study of Complex Systems (PSCS)
1061 Randall Lab     University of Michigan
Ann Arbor MI 48109-1120
http://pscs.physics.lsa.umich.edu/rlr-home.html



reply via email to

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