swarm-support
[Top][All Lists]
Advanced

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

Scheduling on the fly?


From: Alex Lancaster
Subject: Scheduling on the fly?
Date: 11 Feb 1998 18:52:29 -0700

Hi Roger!

I have a tricky activity library question. I want my observerSwarm to
manage (almost)-separate runs of a modelSwarm, in which the methods in
the modelSwarm:

-buildActions;
-activateIn: (id) swarmContext;

are *themselves* scheduled by the schedule of the observerSwarm. In
other words, is it possible to build a schedule "on the fly" as it
were. That is, I need to be able to call the buildActions in the
modelSwarm is called *after* the activateIn ("activation") of the
top-level "observerSwarm". Failing this, is there another way to do
what I am trying to do?

My objective is to be able to start and stop runs of a modelSwarm, in
which *some* (not all) of the agents in the modelSwarm will be
"dropped" and re-created from run to run. Hence I need to
"re-generate" the schedule to point to the right (i.e. new) agents.

Can I do it?

  --- Alex

My current buildActions in my observerSwarm (which doesn't work) looks
something like this:

-buildActions {
  startSimActions = [ActionGroup create: [self getZone]];
  [startSimActions createActionTo: bugPop 
                    message: M(buildFood)];
  [startSimActions createActionTo: bugPop 
                    message: M(buildBugs)];
  [startSimActions createActionTo: self  
                   message: M(buildFoodDisplay)];
  [startSimActions createActionTo: self  
                   message: M(buildBugDisplay)];

  // here's where I build the new Schedule
  [startSimActions createActionTo: bugPop 
                    message: M(buildBugActions)];

  // here's where I need do the activation:
  [startSimActions createActionTo: bugPop 
                    message: M(activateBugModelIn:) : self];

  endSimActions = [ActionGroup create: [self getZone]];
  [endSimActions createActionTo: bugPop 
                message: M(stopBugModel)];
  [endSimActions createActionTo: bugPop 
                message: M(newGeneration)];
  [endSimActions createActionTo: bugPop 
                message: M(evaluate)];

  [endSimActions createActionTo: self  
                 message: M(dropFoodDisplay)];
  [endSimActions createActionTo: self
                 message: M(dropBugDisplay)];

  [endSimActions createActionTo: bugPop 
                 message: M(dropBugs)];
  [endSimActions createActionTo: bugPop 
                 message: M(dropFood)];

  gaSchedule = [Schedule createBegin: [self getZone]];
  [gaSchedule setRepeatInterval: timePerGen];
  [gaSchedule setRelativeTime: 1];
  gaSchedule = [gaSchedule createEnd];

  [gaSchedule at: 0 createAction: startSimActions];
  printf("Scheduling start of sim. actions at 0\n");
  for (i = 0; i < timePerGen; i++) {
    [gaSchedule at: i createActionTo: self  message: M(_updateDisplay_)];
    [gaSchedule at: i createActionTo: probeDisplayManager message: M(update)];
    [gaSchedule at: i createActionTo: actionCache  message: M(doTkEvents)];
    printf("Scheduling display of simulation at %d\n", i);
  }
  [gaSchedule at: (timePerGen-1) createAction: endSimActions];
  printf("Scheduling end of sim. actions at %d\n", (timePerGen-1));
  
  return self;
}

Then I activate it later:

-activateIn: (id) swarmContext {
  // First, activate ourselves (just pass along the context).
  [super activateIn: swarmContext];

  // Now activate omur schedule in ourselves. This arranges for the
  // execution of the schedule we built.

  [gaSchedule activateIn: self];

  // Activate returns the swarm activity - the thing that's ready to run.
  return [self getActivity];

}

I think I now know why this doesn't work - because the schedules in
the modelSwarm are unknown to the observerSwarm when the observerSwarm
is activated and thus aren't properly merged into the top level
schedule. How to get around this?

-- 
  Alex Lancaster         |   e-mail: address@hidden
  Swarm Developer        |      web: http://www.santafe.edu/~alex
  Santa Fe Institute     |      tel: +1-(505) 984-8800 (ext 242)
------------------------------------------------------------------

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