MASON-INTEREST-L Archives

September 2013

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Content-Type:
text/plain; charset="us-ascii"
Date:
Thu, 5 Sep 2013 12:10:19 -0400
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Subject:
From:
Sean Luke <[log in to unmask]>
Content-Transfer-Encoding:
8bit
In-Reply-To:
MIME-Version:
1.0 (Apple Message framework v1085)
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Parts/Attachments:
text/plain (66 lines)
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