Hi, thank you very much for your help I am sorry for the slow reply but I have been trying to get this to work for the last week and I still don't seem to be able to do it :-( I understand from my model class I call: Stoppable stopThis = schedule.scheduleRepeating(agent1); instead of just schedule.scheduleRepeating(agent1). I think i am right in saying this then goes over to my agent class and repeatedly runs my steppable method: public void step(SimState state) { if (mutantNeighbours.numObjs > 0 && higherFitness == false) { walkLandscape(); if (higherFitness == true) { higherFitness = false; getOneMutantNeighbours(); } } else { System.out.println("*** Higher Fitness Values Found ***"); System.out.println("Fitness Value: "+ localPeak); meanFitness += localPeak; peakFound = true; // ** THIS IS WHERE I THEN WANT TO FINISH THE SIMULATION ** // stopThis.stop(); } So I have to call stopThis.stop() yes? but I called Stoppable stopThis = schedule.scheduleRepeating(agent1) in my model classes start method so the stopThis.stop() will not be recognised in my agent class. I tried making Stoppable stopThis a static variable in the model class as the agent class extends the model class but this didn't seem to stop the simulation just throw Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException instead. I just want it to stop the simulation record the results then then run it again N times. I am sorry to be a pain and I am sure this is really simple I am just missing the concept of it I think, I apologise but please understand it is my first time ever with agent based programming. :-( Please help Thanks in advance Rick Sean Luke wrote: > On Apr 15, 2007, at 5:21 AM, Rick wrote: > >> What I want to do is run a simulation until a flag = true store that >> result and then run the same simulation again (x number of times). >> Preferably with the results at the end of each simulation being >> displayed in a chart. (simulations could run one after another or all >> together should not matter that much, would maybe like to have an >> option for either though if one is not a lot more complex than the >> other. >> >> The problem I am getting at the moment is stopping the >> schedule.scheduleRepeating() I just cant do it! think i have tried >> everything but it does not seem to stop. > > There are various issues here: > > - Handling the chart redisplaying itself > [for later discussion] > - Restarting an entire simulation > [if you're running from the command line, the easiest way to > do this to run N simulation runs via your outer simulation stepper -- > for example, you could just say sim.app.blah.Blah -repeat R ] > - killing a repeat > > Killing a repeat is easy. When you call scheduleRepeating, you get > back an object called a Stoppable. > > Stoppable stopThis = schedule.scheduleRepeating(agent1); > > All you have to do is squirrel away this Stoppable until the time > comes when you'd like the repeat to stop, at which time you call > > stopThis.stop() > > You might schedule a "stopper" in the future which does this at a > preordained time: > > final Stoppable stopThis = schedule.scheduleRepeating(agent1); > schedule.scheduleOnce(theTimeInTheFuture, new Steppable() > { > public void step(SimState state) > { > stopThis.stop(); > } > }); > > Mark is correct about killing a whole simulation, but you should only > do that if you can't find all the repeated scheduled items you set up. > > Sean