Package jasima.core.simulation
Class SimulationExperiment
- java.lang.Object
-
- jasima.core.experiment.Experiment
-
- jasima.core.simulation.SimulationExperiment
-
- All Implemented Interfaces:
SimOperations,Notifier<Experiment,Experiment.ExperimentEvent>,ValueStore,Serializable,Cloneable
- Direct Known Subclasses:
ShopExperiment
public class SimulationExperiment extends Experiment implements SimOperations
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jasima.core.experiment.Experiment
Experiment.ExperimentEvent, Experiment.ExperimentState, Experiment.UniqueNamesCheckingHashMap
-
Nested classes/interfaces inherited from interface jasima.core.simulation.util.SimOperations
SimOperations.SimEventType
-
-
Field Summary
Fields Modifier and Type Field Description protected Simulationsim-
Fields inherited from class jasima.core.experiment.Experiment
aborted, DEFAULT_SEED, error, EXCEPTION, EXCEPTION_MESSAGE, EXP_ABORTED, resultMap, RUNTIME
-
-
Constructor Summary
Constructors Constructor Description SimulationExperiment()SimulationExperiment(SimProcessUtil.SimAction mainProcess)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInitAction(Consumer<Simulation> action)Adds aConsumer<Simulation>that is called after creating the simulation components to perform additional initialization tasks.protected voidafterRun()This method is called immediately afterExperiment.performRun(), but beforeExperiment.done().protected voidbeforeRun()This method is called immediately beforeExperiment.performRun(), but afterExperiment.init().SimulationExperimentclone()protected SimulationcreateSim()protected voidcreateSimComponents()protected voiddone()This method can be overridden to perform any required clean-up.doublegetInitialSimTime()SimProcessUtil.SimActiongetMainProcess()SimComponentgetModelRoot()SimulationgetSim()Returns the simulation object created ininit().InstantgetSimTimeStartInstant()longgetSimTimeToMillisFactor()doublegetSimulationLength()doublegetStatsResetTime()protected voidinit()This method is called to perform any initializations required before the experiment is run.protected voidinitSim()protected voidperformRun()Contains the code to actually do something useful.protected voidprint(SimPrintMessage event)protected voidproduceResults()Populates the result mapExperiment.resultMapwith values produced during experiment execution.voidsetInitialSimTime(double initialSimTime)Sets the starting time for the simulation clock.voidsetMainProcess(SimProcessUtil.SimAction mainProcess)voidsetModelRoot(SimComponent rootComponent)voidsetSimTimeStartInstant(Instant simTimeStartInstant)voidsetSimTimeToMillisFactor(long simTimeToMillisFactor)voidsetSimTimeToMillisFactor(TemporalUnit u)Specifies the time unit of the (double-valued) simulation time.voidsetSimulationLength(double simulationLength)Sets the maximum simulation time.voidsetStatsResetTime(double statsResetTime)Sets the statistics reset time.doubletoSimTime(Duration d)Converts a given JavaDuration(i.e., a time span) to the corresponding (relative) simulation time.-
Methods inherited from class jasima.core.experiment.Experiment
abort, addErrorResults, addStandardResults, cancel, checkCancelledOrInterrupted, executeSubExperiment, finalActions, finish, getError, getInitialSeed, getLogLevel, getName, getPropsWithValues, getResults, getState, handleExecutionError, isCancelled, main, nestingLevel, nestingLevel, notifierImpl, print, print, print, print, printResults, readResolve, requireState, runExperiment, runExperimentAsync, runExperimentAsync, runExperimentInternal, runTimeReal, setInitialSeed, setLogLevel, setName, starting, state, toString, valueStoreImpl
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jasima.core.util.observer.Notifier
addListener, addListener, addListener, fire, fire, getListener, numListener, removeCurrentListener, removeListener
-
Methods inherited from interface jasima.core.simulation.util.SimOperations
activateEntity, addComponent, addResult, currentPrio, end, getRootComponent, initRndGen, initRndGen, isEndRequested, isTraceEnabled, schedule, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleAt, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, scheduleIn, schedulePeriodically, schedulePeriodically, scheduleProcess, scheduleProcess, simTime, simTimeAbs, simTimeToInstant, toSimTime, toSimTime, trace
-
Methods inherited from interface jasima.core.util.ValueStore
valueStoreContains, valueStoreGet, valueStoreGet, valueStoreGetAllKeys, valueStoreGetNumKeys, valueStorePut, valueStoreRemove, valueStoreUpdate
-
-
-
-
Field Detail
-
sim
protected transient Simulation sim
-
-
Constructor Detail
-
SimulationExperiment
public SimulationExperiment()
-
SimulationExperiment
public SimulationExperiment(SimProcessUtil.SimAction mainProcess)
-
-
Method Detail
-
init
protected void init()
Description copied from class:ExperimentThis method is called to perform any initializations required before the experiment is run.- Overrides:
initin classExperiment
-
initSim
protected void initSim()
-
createSim
protected Simulation createSim()
-
createSimComponents
protected void createSimComponents()
-
print
protected void print(SimPrintMessage event)
-
beforeRun
protected void beforeRun()
Description copied from class:ExperimentThis method is called immediately beforeExperiment.performRun(), but afterExperiment.init().- Overrides:
beforeRunin classExperiment
-
performRun
protected void performRun()
Description copied from class:ExperimentContains the code to actually do something useful. This is the only abstract method that sub-classes are required to implement.- Specified by:
performRunin classExperiment
-
afterRun
protected void afterRun()
Description copied from class:ExperimentThis method is called immediately afterExperiment.performRun(), but beforeExperiment.done().- Overrides:
afterRunin classExperiment
-
done
protected void done()
Description copied from class:ExperimentThis method can be overridden to perform any required clean-up. It is executed immediately afterExperiment.afterRun(), but beforeExperiment.produceResults()andExperiment.finish().- Overrides:
donein classExperiment
-
produceResults
protected void produceResults()
Description copied from class:ExperimentPopulates the result mapExperiment.resultMapwith values produced during experiment execution. The Experiment always adds the two results "runTime" and "expAborted".- Overrides:
produceResultsin classExperiment
-
toSimTime
public double toSimTime(Duration d)
Converts a given JavaDuration(i.e., a time span) to the corresponding (relative) simulation time.- Specified by:
toSimTimein interfaceSimOperations- Parameters:
d- The duration to be converted to simulation time.- Returns:
- The amount of simulation time.
- See Also:
Simulation.toSimTime(Duration)
-
getSim
public Simulation getSim()
Returns the simulation object created ininit(). Raises anIllegalStateExceptionif not simulation was set before.- Specified by:
getSimin interfaceSimOperations
-
setSimulationLength
public void setSimulationLength(double simulationLength)
Sets the maximum simulation time. A value of 0.0 means no such limit.- Parameters:
simulationLength- Stop simulation at this point in time.
-
getSimulationLength
public double getSimulationLength()
-
setStatsResetTime
public void setStatsResetTime(double statsResetTime)
Sets the statistics reset time. When this time is reached then theresetStats()methods of all components will be called. Statistics reset methods will also be executed once before the simulation starts (independently from this setting).- Parameters:
statsResetTime- The time when to call all statics reset methods.
-
getStatsResetTime
public double getStatsResetTime()
-
getInitialSimTime
public double getInitialSimTime()
-
setInitialSimTime
public void setInitialSimTime(double initialSimTime)
Sets the starting time for the simulation clock.
-
addInitAction
public void addInitAction(Consumer<Simulation> action)
Adds aConsumer<Simulation>that is called after creating the simulation components to perform additional initialization tasks.
-
getSimTimeStartInstant
public Instant getSimTimeStartInstant()
-
setSimTimeStartInstant
public void setSimTimeStartInstant(Instant simTimeStartInstant)
-
getSimTimeToMillisFactor
public long getSimTimeToMillisFactor()
-
setSimTimeToMillisFactor
public void setSimTimeToMillisFactor(long simTimeToMillisFactor)
-
setSimTimeToMillisFactor
public void setSimTimeToMillisFactor(TemporalUnit u)
Specifies the time unit of the (double-valued) simulation time. The default value is ChronoUnit.MINUTES.
-
getModelRoot
public SimComponent getModelRoot()
-
setModelRoot
public void setModelRoot(SimComponent rootComponent)
-
getMainProcess
public SimProcessUtil.SimAction getMainProcess()
-
setMainProcess
public void setMainProcess(SimProcessUtil.SimAction mainProcess)
-
clone
public SimulationExperiment clone()
- Overrides:
clonein classExperiment
-
-