Thanks Ernesto. I will consider that.
Other things being equal, I prefer to use default MASON strategies as much as possible, since Sean and other contributors have thought through things that I haven't, and being
lazy efficient, I try to avoid understanding more about MASON source than I have to.
I'm surprised if there isn't a method that fires after all of the runs are done. Sean seems to have thought of everything else!
Your suggestion prompted me to see whether I could access the value set by the -repeat command line option directly. Then I could test whether the job number is equal to the repeat number in finish(). Unfortunately, "-repeat" is processed in
SimState.doLoop(), and the repeat value is kept local to doLoop() and is not copied into an instance variable accessible elsewhere. So to get that value, I'd have to process the command line myself, or more likely I'd use a separate command line option system
that I have for my application-specific options. But I'd prefer to avoid that for the same reason: It's safer to depend on MASON default procedures when possible.
You can You might be better off at this point to just modify your main method so that it runs a bunch of simulation and then calls whatever you need to call before quitting.
You can always run the model the explicit way like this:
if (!state.schedule.step(state)) break;
while(state.schedule.getSteps() < STEPS_PER_RUN);
chain a bunch of them together, extract information from the state object (perhaps with a custom method) and call whatever method you want after you have run a bunch of them.
SimState.finish() is called at the end of every run, i.e. every job when you use -repeat on the command line. Is there a function that's only called after the last run? I have been looking, but haven't found one.
A related, nitpicky question: Page 92 of the v. 19 (June 2015) manual describes the doLoop(...) methods in sim.engine.SimState, and says that when the methods run ".... Finally, stop() is called on the instance." For the first doLoop method,
at least, the instance in question is clearly a SimState, since "The
generator will be called to produce an instance of the desired SimState subclass." However, SimState doesn't have a stop() method. Is this a typo? Should it be finish()? (Or is this is a reference to a Stoppable that's available from the SimState?)
Marshall Abrams, Associate Professor
Department of Philosophy, University of Alabama at Birmingham
Mail: HB 414A, 900 13th Street South, Birmingham, AL 35294-1260; Office: HB 418