swarm-support
[Top][All Lists]
Advanced

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

Decentralized Scheduling (not exactly asynchronous


From: Paul E. Johnson
Subject: Decentralized Scheduling (not exactly asynchronous
Date: Thu, 08 Jun 2000 10:42:36 -0500

In the model swarm level, in the buildActions method I changed from the
usual ActionGroup/createActionForEach approach (as in heatbugs) to try
to decentralize the simulation.  If you remember the model Marcus wrote
that he called "Repeater", in which each agent is a Swarm and has a
schedule that controls when he takes his actions, you have the idea.  I
have an objc version of that program called "pjrepeater.m" in the
WorkingExampleCode directory. 

I succeeded in decentralizing the scheduling in that way, so the agents
step exactly as if the model swarm is scheduling the agents and they all
step in exactly the same order.  That is, each agent has methods that
say at time X something is supposed to happen, and since the main Swarm
schedule is a "first come, first serve" thing, it retains the order that
would have happened if the model swarm itself had done the
"createActionForEach" thing.  

I want to keep open that possibility, for comparison purposes, but now I
want to randomize the agent steps that are scheduled at a given time. 
How do I do it?  I'm reading lots of emails about ConcurrentGroup and
especially the floating point time thread from this spring, but I just
don't understand how this all fits together.  Since each agent is
keeping its own schedule, I don't understand how to make all events at
time X happen in a random order.  

Currently, in the agent's step method, the last thing it does is
schedule itself for the next time period, so the ModelSwarm only has to
send a step method at time 0 and then the agents go on their own.  But
they act in exactly the same order, ever time.  

I've looked at many possibilities in the mail archive, but finally just
have to ask for instruction. 

So I have this code:

In ModelSwarm:

- buildActions
{
  [super buildActions];
 [citizenList forEach: M(buildActions)];

 startupSchedule = [Schedule createBegin: self];
 [startupSchedule setAutoDrop: 1];
 startupSchedule = [startupSchedule createEnd];

 [startupSchedule at: 0 createActionForEach: citizenList message:
M(step)];
  return self;
}

- activateIn: swarmContext
{
  [super activateIn: swarmContext];
  [citizenList forEach: M(activateIn:):self];
  [startupSchedule activateIn: self];
  return [self getActivity];
}


And the Agent is a Swarm (not SwarmObject) and has this scheduling 

- scheduleYourselfAt: (int) x
{
  [schedule at: x createActionTo: self message: M(step)];
  return self;
}

- buildActions
{
  [super buildActions];
  schedule= [Schedule createBegin: self];
  [schedule setAutoDrop: 1];
  schedule = [schedule createEnd];

  return self;
}

- activateIn: swarmContext
{
  printf(" schedule activated \n");
   [super activateIn: swarmContext];
   [schedule activateIn: self ];
 
   return [self getActivity];
}

-step
{
  [self  scheduleYourselfAt: getCurrentTime() +1];

  printf("Citizen %d  time %d, idnum, (int) getCurrentTime());

  return self;
}

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