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 Simulation
sim
-
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 void
addInitAction(Consumer<Simulation> action)
Adds aConsumer<Simulation>
that is called after creating the simulation components to perform additional initialization tasks.protected void
afterRun()
This method is called immediately afterExperiment.performRun()
, but beforeExperiment.done()
.protected void
beforeRun()
This method is called immediately beforeExperiment.performRun()
, but afterExperiment.init()
.SimulationExperiment
clone()
protected Simulation
createSim()
protected void
createSimComponents()
protected void
done()
This method can be overridden to perform any required clean-up.double
getInitialSimTime()
SimProcessUtil.SimAction
getMainProcess()
SimComponent
getModelRoot()
Simulation
getSim()
Returns the simulation object created ininit()
.Instant
getSimTimeStartInstant()
long
getSimTimeToMillisFactor()
double
getSimulationLength()
double
getStatsResetTime()
protected void
init()
This method is called to perform any initializations required before the experiment is run.protected void
initSim()
protected void
performRun()
Contains the code to actually do something useful.protected void
print(SimPrintMessage event)
protected void
produceResults()
Populates the result mapExperiment.resultMap
with values produced during experiment execution.void
setInitialSimTime(double initialSimTime)
Sets the starting time for the simulation clock.void
setMainProcess(SimProcessUtil.SimAction mainProcess)
void
setModelRoot(SimComponent rootComponent)
void
setSimTimeStartInstant(Instant simTimeStartInstant)
void
setSimTimeToMillisFactor(long simTimeToMillisFactor)
void
setSimTimeToMillisFactor(TemporalUnit u)
Specifies the time unit of the (double-valued) simulation time.void
setSimulationLength(double simulationLength)
Sets the maximum simulation time.void
setStatsResetTime(double statsResetTime)
Sets the statistics reset time.double
toSimTime(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:Experiment
This method is called to perform any initializations required before the experiment is run.- Overrides:
init
in 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:Experiment
This method is called immediately beforeExperiment.performRun()
, but afterExperiment.init()
.- Overrides:
beforeRun
in classExperiment
-
performRun
protected void performRun()
Description copied from class:Experiment
Contains the code to actually do something useful. This is the only abstract method that sub-classes are required to implement.- Specified by:
performRun
in classExperiment
-
afterRun
protected void afterRun()
Description copied from class:Experiment
This method is called immediately afterExperiment.performRun()
, but beforeExperiment.done()
.- Overrides:
afterRun
in classExperiment
-
done
protected void done()
Description copied from class:Experiment
This method can be overridden to perform any required clean-up. It is executed immediately afterExperiment.afterRun()
, but beforeExperiment.produceResults()
andExperiment.finish()
.- Overrides:
done
in classExperiment
-
produceResults
protected void produceResults()
Description copied from class:Experiment
Populates the result mapExperiment.resultMap
with values produced during experiment execution. The Experiment always adds the two results "runTime" and "expAborted".- Overrides:
produceResults
in classExperiment
-
toSimTime
public double toSimTime(Duration d)
Converts a given JavaDuration
(i.e., a time span) to the corresponding (relative) simulation time.- Specified by:
toSimTime
in 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 anIllegalStateException
if not simulation was set before.- Specified by:
getSim
in 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:
clone
in classExperiment
-
-