swarm-support
[Top][All Lists]
Advanced

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

Re: Synchronous scheduling


From: D. D. Donalson
Subject: Re: Synchronous scheduling
Date: Sat, 21 Apr 2001 20:50:37 -0700

HJ,
 
   I just went through your code.  Right now what you have is a Stochastic Birth-Death Model.  There is really no need for agents as each moth is identical.  If you are not going to expand the moth definition, then you can simply keep track of the number of individuals you have and calculate the survivor/fecundity N times where N is the total number of individuals in the system.  You can then have a second variable N' that you add the new recruits to.  At the end of the loop, N=N' and then N'=0.  This still leaves you (Yoo?) the option of adding randomness to the fecundity. 
 
Are you planning on expanding this?  Even if you are, I don't see why you can't have the "step" function in your modelSwarm and then iterate through the moth list.  As long as the moths are not interacting with each other or different parts of the environment, I see no need for an asynchronous schedule.  In this model, it doesn't matter what order you do things in, the results will be the same.  As it is, the present simulation looks like it can be approximated quite well by a simple deterministic birth/death process.  (i.e. A certain % survive and they give birth.)
 
Cheers,
 
   D4
----- Original Message -----
Sent: Saturday, April 21, 2001 6:04 PM
Subject: Synchronous scheduling

Hello,
I'm in the process of developing a discrete-time population dynamics model of an insect.  I am building up from a simple model, in which agents simply reproduce then die or die without reproducing, in each time step.  To schedule this, I used buildActions from simpleObserverBug2 in the tutorial as a template:

- buildActions
{
  [super buildActions];

  modelActions = [ActionGroup create: self];
  [modelActions createActionForEach: mothList message: M(step)];

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

  return self;
}

[In MOTH.M:]

- step
{
unsigned i;

  if (survive == 1)
  {
    for (i=0; i < [myModel getFecundity]; i++)
    {
      [self giveBirth]; // New agents are assigned a "survive" value, then get added to mothList
    }
    [myModel removeMoth: self]; // I get removed from mothList
    [self drop];

    puts("I gave birth, then died.");
    fflush(stdout);
  }

  else if (survive == 0)
  {
    [myModel removeMoth: self]; // I get removed from mothList
    [self drop];

    puts("I died before giving birth.");
    fflush(stdout);
  }
return self;
}

The step code has two problems, I think, which need to be fixed.  One, since offspring get added to the same list as their parents, they too get sent the step message in the same time step as do their parents.  What I really want is for offspring to get added to the list in the following time step.  Two, the program crashes following the first moth removal (see below).  I'm less sure about what causes this - possibly a conflict between the createActionForEach call and the call to removeMoth from mothList?

      0 [main] NCP 1141 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
    647 [main] NCP 1141 stackdump: Dumping stack trace to NCP.EXE.stackdump

There are two possible solutions to these problems which I can think of given my limited programming knowledge.  One, I can put offspring into a temporary list, then dump them back into the main list at each time step.  This doesn't seem efficient, nor does it solve the crash problem caused by moth removal.  Two, the schedule can be made dynamic, kind of like the one used in Mousetrap?  I'm not sure about how to build this sort of schedule for this situation.

Does anyone have advice on how to deal with this kind of scheduling issue?  Examples you can point me to?  Or maybe there's a much simpler approach which is escaping me?

Thanks very much in advance.
Ho Jung Yoo



reply via email to

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