MASON-INTEREST-L Archives

September 2013

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
F Witmer <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Thu, 5 Sep 2013 10:26:00 -0600
Content-Type:
multipart/alternative
Parts/Attachments:
text/plain (2683 bytes) , text/html (3882 bytes)
Great, thanks for the quick reply -- it's all so easy once you get it right!



On Thu, Sep 5, 2013 at 10:10 AM, Sean Luke <[log in to unmask]> wrote:

> No, the schedule is properly initialized.  But the very first thing the
> start() method does is clear out the schedule.  So here's what your program
> does.
>
> 1. Create the schedule, then insert the Steppable to be stepped, all in
> the constructor.
> 2. Call start(), which deletes the Steppable.
> 3. Step the schedule, which terminates immediately because it now has
> nothing in it.
>
> You should be calling start(), then inserting steppables (typically in an
> overridden start() method), then stepping the schedule.
>
> Sean
>
>
> On Sep 5, 2013, at 11:55 AM, F Witmer wrote:
>
> > I am having trouble scheduling events in the SimState.  I'm guessing I'm
> missing something basic here -- perhaps the schedule has to be initialized?
>  When I add steppable agents or anonymous steppable objects, the step
> function does not get called.  Below is a simplified version to show the
> problem.  Using doLoop() or calling schedule.step() myself, the print
> statement in masterStep() does not execute.
> >
> > This setup seems to mirror that in the tutorials and documentation, so
> I'm not sure what I'm missing here.
> >
> > -frank
> >
> >
> > package schedPackage;
> >
> > import sim.engine.SimState;
> > import sim.engine.Steppable;
> >
> > public class ScheduleTest extends SimState {
> >     private static final long serialVersionUID = 1L;
> >
> >       public ScheduleTest(long seed) {
> >               super(seed);
> >
> >               Steppable masterStep = new Steppable() {
> >             private static final long serialVersionUID = 1;
> >             @Override
> >             public void step(SimState state) {
> >               masterStep();
> >             }
> >         };
> >               if (schedule.scheduleRepeating(masterStep) == null) {
> >                       System.out.println("ERROR: scheduling of
> masterStep failed");
> >               }
> >
> >       }
> >
> >       public void masterStep() {
> >               System.out.println("Master step executing");
> >       }
> >
> >       public static void main(String[] args) {
> >               //doLoop(ScheduleTest.class, args);
> >               //System.exit(0);
> >               //*
> >               SimState state = new
> ScheduleTest(System.currentTimeMillis());
> >               System.out.println("Starting sim...");
> >               state.start();
> >               do {
> >                       if (!state.schedule.step(state)) break;
> >               } while(state.schedule.getSteps() < 50);
> >               state.finish();
> >               System.exit(0);
> >               //*/
> >       }
> >
> > }
> >
>


ATOM RSS1 RSS2