swarm-support
[Top][All Lists]
Advanced

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

Re: Event


From: Sven N. Thommesen
Subject: Re: Event
Date: Mon, 30 Jul 2001 19:45:39 -0500

At 07:07 AM 7/30/01, Olivier Jauze wrote:
hi all,

In my case, I know exactly when I have to stop a simulation beacause i know the number of running days. I would like to insert an event in the Observer that could stop the simulation at this time.
It woud be better than look at every time step if the number of days is reach.

But I can't insert this type of event.
What i have to do ?

Olivier,

here's one way to do it. In the BatchSwarm and/or the ObserverSwarm, you insert code like this:

// a. In method buildActions() insert a stop schedule like this (where 'experimentDuration'
// is the step at which you want the simulation to stop):

      stopSchedule = new ScheduleImpl(this.getZone(), true); // autodrop

      stopSchedule.at$createActionTo$message
           (experimentDuration, this, new Selector
                (this.getClass(), "stopRunning", false) );


// b. Then you need a method like this that executes when the above action is triggered:

    public void stopRunning () {

        System.out.println
                ("BatchSwarm: Quitting at " + Globals.env.getCurrentTime() );

        // (Do other desired housekeeping chores here)

        Globals.env.getCurrentSwarmActivity().terminate();

    }

That should take care of it. (Translate as needed if you are running objective-C.)

Cheers,
Sven Thommesen




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