Package microsim.engine
Class MultiRun
java.lang.Object
java.lang.Thread
microsim.engine.MultiRun
- All Implemented Interfaces:
Runnable,EngineListener,ExperimentBuilder
MultiRun is a template abstract class useful to guide the modeller to build
an automatic simulation launcher, able to change interactively parameters on
the basis of the last run.
The best way to understand hot it works is to see the MultiRun example in the JAS/examples directory.
The key methods of multi run are startModel() and nextModel(). The first one must create the simulation model(s), set its(their) parameters a vector containing them.
The jas engine will attach the returning list of model and execute the simulation. When the SIMULATION_END signal is sent to Sim.engine the multi run will execute the nextModel() method. Here user can observe the result of the last run and decide which parameters to use at next run. If method returns true another simulation run will be executed and the startModel() method will be called again, otherwise the progam will exit.
The best way to understand hot it works is to see the MultiRun example in the JAS/examples directory.
The key methods of multi run are startModel() and nextModel(). The first one must create the simulation model(s), set its(their) parameters a vector containing them.
The jas engine will attach the returning list of model and execute the simulation. When the SIMULATION_END signal is sent to Sim.engine the multi run will execute the nextModel() method. Here user can observe the result of the last run and decide which parameters to use at next run. If method returns true another simulation run will be executed and the startModel() method will be called again, otherwise the progam will exit.
Title: JAS
Description: Java Agent-based Simulation library
Copyright: Copyright (C) 2002 Michele Sonnessa
Company:
- Author:
- Michele Sonnessa, Ross Richardson
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static booleanprotected intprotected SimulationEngineprotected booleanprotected booleanFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddParameterDomain(ParameterDomain parameterDomain) getConfiguration(int counter) intintvoidgo()The go method starts the multi-run simulation.abstract booleanWhen a SIMULATION_END signal is sent to JAS by one of the running models, simulation is stopped and this method is called.voidonEngineEvent(SystemEventType event) Implementing the ISimEngineListener.voidrun()MultiRun is an independent thread.static voidsetCopyInputFolderStructure(boolean copyInputFolderStructure_) Sets whether to copy the input files into a new input folder within a new output folder for each simulation runvoidsetEngineListeners(List<EngineListener> engineListeners) voidsetExperimentBuilder(ExperimentBuilder experimentBuilder) voidsetMultiRunId(String multiRunId) voidsetMultiRunListeners(List<MultiRunListener> multiRunListeners) voidsetParameterDomains(List<ParameterDomain> parameterDomains) abstract StringMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yieldMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface microsim.engine.ExperimentBuilder
buildExperiment
-
Field Details
-
engine
-
counter
protected int counter -
executionActive
protected boolean executionActive -
toBeContinued
protected boolean toBeContinued -
copyInputFolderStructure
protected static boolean copyInputFolderStructure
-
-
Constructor Details
-
MultiRun
public MultiRun()Create a new multi run session.
-
-
Method Details
-
nextModel
public abstract boolean nextModel()When a SIMULATION_END signal is sent to JAS by one of the running models, simulation is stopped and this method is called. If it returns true the multi run will continue with the next run, otherwise the program will exit.- Returns:
- a value deciding if simulation is to be continued.
-
setupRunLabel
-
run
public void run()MultiRun is an independent thread. The run method controls the sequence of simulations. -
go
public void go()The go method starts the multi-run simulation. -
onEngineEvent
Implementing the ISimEngineListener. This method monitors the Sim.EVENT_SIMULATION_END signal. When it is raised the MultiRun class shutdowns current run and invokes the nextModel() method.- Specified by:
onEngineEventin interfaceEngineListener- Parameters:
event- a valid system eventID.
-
getEngine
-
getCounter
public int getCounter() -
getExperimentBuilder
-
setExperimentBuilder
-
getMultiRunListeners
-
setMultiRunListeners
-
getMultiRunId
-
setMultiRunId
-
getEngineListeners
-
setEngineListeners
-
getParameterDomains
-
setParameterDomains
-
addParameterDomain
-
getMaxConfigurations
public int getMaxConfigurations() -
getConfiguration
-
setCopyInputFolderStructure
public static void setCopyInputFolderStructure(boolean copyInputFolderStructure_) Sets whether to copy the input files into a new input folder within a new output folder for each simulation run- Parameters:
copyInputFolderStructure_- - set to true if wanting a copy of the input files to be stored in the output folder for each simulation run, otherwise set to false
-