Package jsl.simulation
Class Simulation
- java.lang.Object
-
- jsl.simulation.Simulation
-
- All Implemented Interfaces:
ObservableIfc
,ExperimentGetIfc
,IterativeProcessIfc
,GetNameIfc
public class Simulation extends java.lang.Object implements ObservableIfc, IterativeProcessIfc, ExperimentGetIfc
Simulation represents a model and experiment that can be run. It encapsulates a model to which model elements can be attached. It allows an experiment and its run parameters to be specified. It allows reporting of results to text files via a SimulationReporter. If you want to store simulation results in a database, then use the JSLDatabaseObserver class to observe the simulation with an instance of the JSLDatabase class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Simulation.ReplicationExecutionProcess
This class implements the IterativeProcess behavior for the Simulation
-
Constructor Summary
Constructors Constructor Description Simulation()
Creates a simulation within a default name using the default executiveSimulation(java.lang.String simName)
Creates a simulation to run a model using the default scheduling executive.Simulation(java.lang.String simName, java.nio.file.Path pathToOutputDirectory)
Creates a simulation to run a model using the default scheduling executive.Simulation(java.lang.String simName, java.nio.file.Path pathToOutputDirectory, Executive executive)
Creates a simulation to run a model using the supplied scheduling executive.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObserver(ObserverIfc observer)
Allows an observer to be added to the simulation.protected void
afterExperiment()
This method is automatically called at the end of the experiment Sub-classes can inject behavior within hereprotected void
afterReplication()
This method is automatically called after each replication Sub-classes can inject behavior within hereboolean
allStepsCompleted()
Checks if the simulation completed all of its replicationsprotected void
beforeExperiment()
This method is automatically called at the start of the experiment Sub-classes can inject behavior within hereprotected void
beforeReplication()
This method is automatically called before each replication Sub-classes can inject behavior within hereboolean
contains(ObserverIfc observer)
Returns true if the observer is already attachedint
countObservers()
Returns how many observers are currently observing the observablevoid
deleteObserver(ObserverIfc observer)
Allows the deletion (removing) of an observer from the observablevoid
deleteObservers()
Deletes all the observers from the observablevoid
end()
Causes the simulation to end after the current replication is completedvoid
end(java.lang.String msg)
Causes the simulation to end after the current replication is completedboolean
executionTimeExceeded()
Checks if the simulation stopped because of real clock timeboolean
getAdvanceNextSubStreamOption()
Returns how many times the random number streams will be advanced before the simulation starts.boolean
getAntitheticOption()
Indicates whether or not the antithetic streams have been turn on or offlong
getBeginExecutionTime()
The absolute time in milliseconds that the simulation was startedint
getCurrentReplicationNumber()
Returns the current number of replications completedjava.util.Optional<ExecutiveTraceReport>
getDefaultExecutiveTraceReport()
Gets a reference to the default event tracing report.long
getElapsedExecutionTime()
The time in milliseconds between when the simulation was started and the simulation endedlong
getEndExecutionTime()
The absolute time in milliseconds that the simulation endedExecutive
getExecutive()
The Executive associated with the simulationExperimentGetIfc
getExperiment()
The Experiment associated with the simulationlong
getExperimentId()
Returns the id for this objectjava.lang.String
getExperimentName()
Gets the name.boolean
getGarbageCollectAfterReplicationFlag()
Returns whether or not System.gc() is called after each replicationjava.lang.StringBuilder
getHalfWidthSummaryReport()
java.lang.StringBuilder
getHalfWidthSummaryReport(double confLevel)
java.lang.StringBuilder
getHalfWidthSummaryReport(java.lang.String title, double confLevel)
long
getId()
double
getLengthOfReplication()
Provides the length of each replicationdouble
getLengthOfWarmUp()
Provides the length of the warm up period for each replicationIPLogReport
getLogReport()
Gets the IPLogReport that was attached to the simulationlong
getMaximumAllowedExecutionTime()
Returns the real clock time in milliseconds for how long the simulation is allowed to runlong
getMaximumAllowedExecutionTimePerReplication()
Gets in real clock time (milliseconds) the amount of time available for each replication within the simulation.Model
getModel()
The Model associated with the simulationjava.lang.String
getName()
int
getNumberOfReplications()
Returns the number of replications for the experimentint
getNumberOfStreamAdvancesPriorToRunning()
Returns the number of times that the streams should be advanced prior to running the experimentlong
getNumberStepsCompleted()
For the IterativeProcessIfc.OutputDirectory
getOutputDirectory()
java.nio.file.Path
getOutputDirectoryPath()
boolean
getRepLengthWarningMessageOption()
boolean
getReplicationInitializationOption()
Returns whether or not replications will be initialized prior to running each replicationboolean
getResetStartStreamOption()
Returns whether or not the start stream will be reset prior to executing the simulationjava.util.Optional<StatisticalBatchingElement>
getStatisticalBatchingElement()
boolean
getStoppingFlag()
Returns the stopping flagjava.lang.String
getStoppingMessage()
The message supplied with stop()boolean
hasMoreReplications()
Checks if the current number of replications that have been executed is less than the number of replications specified.boolean
hasNextReplication()
Returns true if additional replications need to be runvoid
initialize()
Initializes the simulation in preparation for runningboolean
isCreated()
Checks if the iterative process is in the created state.boolean
isDone()
Checks if the simulation is done processing replicationsboolean
isEnded()
Checks to see if the simulation is in the ended state If it is ended, it may be for a number of reasonsboolean
isExecutionTimeExceeded()
Returns if the elapsed execution time exceeds the maximum time allowed.boolean
isInitialized()
Checks if the simulation has been initialized.boolean
isRunning()
Checks if the simulation is running.boolean
isRunningStep()
Indicates that the iterative process is currently running an individual stepboolean
isStepCompleted()
Part of the IterativeProcessIfc.boolean
isUnfinished()
Checks if the replications were finishedSimulationReporter
makeSimulationReporter()
Constructs a SimulationReporter instance that uses this Simulation instanceboolean
noStepsExecuted()
Indicates that the iterative process ended because of no stepsLogPrintWriter
out()
void
printHalfWidthSummaryReport()
Prints the default half-width summary report to the consolevoid
printHalfWidthSummaryReport(double confLevel)
void
printHalfWidthSummaryReport(java.lang.String title, double confLevel)
void
run()
Runs all remaining replications based on the current settingsvoid
run(int numReps, double runLength)
A convenience method for running a simulationvoid
run(java.lang.String expName, int numReps, double runLength)
A convenience method for running a simulationvoid
run(java.lang.String expName, int numReps, double runLength, double warmUp)
A convenience method for running a simulationvoid
runNext()
Runs the next replication if there is onevoid
setAdvanceNextSubStreamOption(boolean b)
Sets the option to have the streams advance to the beginning of the next substream after each replicationvoid
setAdvanceStreamNumber(int n)
Sets the number of streams to advance prior to running an experimentprotected void
setExperiment(Experiment e)
Set the simulation experiment to the same attribute values as the supplied experimentvoid
setExperimentName(java.lang.String name)
Sets the name of the underlying experimentvoid
setGarbageCollectAfterReplicationFlag(boolean flag)
Determines whether or not System.gc() is called after each replicationvoid
setLengthOfReplication(double lengthOfReplication)
Sets the length of the replications in simulation time.void
setLengthOfWarmUp(double lengthOfWarmUp)
Allows the length of the warm up period for each replication to be setvoid
setMaximumExecutionTime(long milliseconds)
Sets a real clock time for how long the entire simulation can lastvoid
setMaximumExecutionTimePerReplication(long milliseconds)
Sets in real clock time (milliseconds) the amount of time available for each replication within the simulation.void
setNumberOfReplications(int numReps)
Sets the number of replications to be executed.void
setNumberOfReplications(int numReps, boolean antitheticOption)
Sets the number of replications to be executed and whether or not the antithetic option is on.void
setRepLengthWarningMessageOption(boolean flag)
False turns off the messagevoid
setReplicationInitializationOption(boolean repInitOption)
Sets whether or not the replication should be initialized before each replicationvoid
setResetStartStreamOption(boolean b)
If set to true then the streams will be reset to the start of the stream prior to running the experiments.void
stop()
This sets a flag to indicate to the process that is should stop after the next step is completed.void
stop(java.lang.String msg)
This sets a flag to indicate to the process that is should stop after the next step is completed.boolean
stoppedByCondition()
Checks if the simulation has ended because it was stoppedjava.lang.String
toString()
void
turnOffDefaultEventTraceReport()
Turns off a default tracing report for the Executive to trace event execution to a filevoid
turnOffLogReport()
Turns of the default logging reportvoid
turnOnDefaultEventTraceReport()
Turns on a default tracing report for the Executive to trace event execution to a filevoid
turnOnDefaultEventTraceReport(java.lang.String name)
Turns on a default tracing report for the Executive to trace event execution to a filevoid
turnOnLogReport()
void
turnOnLogReport(java.lang.String reportFileName)
void
turnOnLogReport(java.nio.file.Path pathToFile)
Turns on a default logging report with the provided nameStatisticalBatchingElement
turnOnStatisticalBatching()
A StatisticalBatchingElement is used to control statistical batching for single replication simulations.void
turnOnTimer(long milliseconds)
Turns on a default timer and task to report on simulation progressvoid
writeHalfWidthSummaryReport(java.io.PrintWriter out)
void
writeHalfWidthSummaryReport(java.io.PrintWriter out, double confLevel)
void
writeHalfWidthSummaryReport(java.io.PrintWriter out, java.lang.String title, double confLevel)
-
-
-
Field Detail
-
LOGGER
public static final org.slf4j.Logger LOGGER
for logging
-
myModel
protected final Model myModel
The model to simulate
-
-
Constructor Detail
-
Simulation
public Simulation()
Creates a simulation within a default name using the default executive
-
Simulation
public Simulation(java.lang.String simName)
Creates a simulation to run a model using the default scheduling executive.- Parameters:
simName
- the name of the simulation
-
Simulation
public Simulation(java.lang.String simName, java.nio.file.Path pathToOutputDirectory)
Creates a simulation to run a model using the default scheduling executive.- Parameters:
simName
- the name of the simulationpathToOutputDirectory
- the path to the output directory for the simulation files
-
Simulation
public Simulation(java.lang.String simName, java.nio.file.Path pathToOutputDirectory, Executive executive)
Creates a simulation to run a model using the supplied scheduling executive.- Parameters:
simName
- the name of the simulationpathToOutputDirectory
- the path to the output directory for the simulation filesexecutive
- the executive, if null the default executive is used
-
-
Method Detail
-
getOutputDirectory
public final OutputDirectory getOutputDirectory()
- Returns:
- the defined OutputDirectory for the simulation
-
getOutputDirectoryPath
public final java.nio.file.Path getOutputDirectoryPath()
- Returns:
- the path to the simulation's output directory
-
out
public final LogPrintWriter out()
- Returns:
- the pre-defined default text output file for the simulation
-
getName
public final java.lang.String getName()
- Specified by:
getName
in interfaceGetNameIfc
- Returns:
- a string representing the name of the object
-
getId
public final long getId()
-
getExperiment
public final ExperimentGetIfc getExperiment()
The Experiment associated with the simulation- Returns:
- the experiment
-
getModel
public final Model getModel()
The Model associated with the simulation- Returns:
- the model
-
getExecutive
public final Executive getExecutive()
The Executive associated with the simulation- Returns:
- the Executive
-
turnOnStatisticalBatching
public final StatisticalBatchingElement turnOnStatisticalBatching()
A StatisticalBatchingElement is used to control statistical batching for single replication simulations. This method creates and attaches a StatisticalBatchingElement to the model. For convenience, it also returns the created element- Returns:
- the StatisticalBatchingElement
-
getStatisticalBatchingElement
public final java.util.Optional<StatisticalBatchingElement> getStatisticalBatchingElement()
- Returns:
- an optional of the StatisticalBatchingElement because it may or may not be attached
-
deleteObservers
public final void deleteObservers()
Description copied from interface:ObservableIfc
Deletes all the observers from the observable- Specified by:
deleteObservers
in interfaceObservableIfc
-
deleteObserver
public final void deleteObserver(ObserverIfc observer)
Description copied from interface:ObservableIfc
Allows the deletion (removing) of an observer from the observable- Specified by:
deleteObserver
in interfaceObservableIfc
- Parameters:
observer
- the observer to delete
-
countObservers
public final int countObservers()
Description copied from interface:ObservableIfc
Returns how many observers are currently observing the observable- Specified by:
countObservers
in interfaceObservableIfc
- Returns:
- number of observers
-
addObserver
public final void addObserver(ObserverIfc observer)
Allows an observer to be added to the simulation. The observer observes an IterativeProcess that manages the execution of the replications. Each step in the IterativeProcess represents an entire replication.- Specified by:
addObserver
in interfaceObservableIfc
- Parameters:
observer
- the observer
-
contains
public boolean contains(ObserverIfc observer)
Description copied from interface:ObservableIfc
Returns true if the observer is already attached- Specified by:
contains
in interfaceObservableIfc
- Parameters:
observer
- the observer to check- Returns:
- true if attached
-
hasNextReplication
public final boolean hasNextReplication()
Returns true if additional replications need to be run- Returns:
- true if additional replications need to be run
-
initialize
public final void initialize()
Initializes the simulation in preparation for running- Specified by:
initialize
in interfaceIterativeProcessIfc
-
runNext
public final void runNext()
Runs the next replication if there is one- Specified by:
runNext
in interfaceIterativeProcessIfc
-
run
public final void run(int numReps, double runLength)
A convenience method for running a simulation- Parameters:
numReps
- the number of replicationsrunLength
- the length of the simulation replication
-
run
public final void run(java.lang.String expName, int numReps, double runLength)
A convenience method for running a simulation- Parameters:
expName
- the name of the experimentnumReps
- the number of replicationsrunLength
- the length of the simulation replication
-
run
public final void run(java.lang.String expName, int numReps, double runLength, double warmUp)
A convenience method for running a simulation- Parameters:
expName
- the name of the experimentnumReps
- the number of replicationsrunLength
- the length of the simulation replicationwarmUp
- the length of the warm up period
-
run
public final void run()
Runs all remaining replications based on the current settings- Specified by:
run
in interfaceIterativeProcessIfc
-
end
public final void end(java.lang.String msg)
Causes the simulation to end after the current replication is completed- Specified by:
end
in interfaceIterativeProcessIfc
- Parameters:
msg
- A message to indicate why the simulation was stopped
-
end
public final void end()
Causes the simulation to end after the current replication is completed- Specified by:
end
in interfaceIterativeProcessIfc
-
isUnfinished
public final boolean isUnfinished()
Checks if the replications were finished- Specified by:
isUnfinished
in interfaceIterativeProcessIfc
- Returns:
- true if unfinished
-
executionTimeExceeded
public final boolean executionTimeExceeded()
Checks if the simulation stopped because of real clock time- Specified by:
executionTimeExceeded
in interfaceIterativeProcessIfc
- Returns:
- true if exceeded
-
isStepCompleted
public final boolean isStepCompleted()
Part of the IterativeProcessIfc. Checks if a step in the process is completed. A step is a replication Checks if the state of the simulation is that it just completed a replication- Specified by:
isStepCompleted
in interfaceIterativeProcessIfc
- Returns:
- true if completed
-
isRunning
public final boolean isRunning()
Checks if the simulation is running. Running means that it is executing replications- Specified by:
isRunning
in interfaceIterativeProcessIfc
- Returns:
- true means it is running
-
isInitialized
public final boolean isInitialized()
Checks if the simulation has been initialized. If it is initialized, then it is ready to run replications- Specified by:
isInitialized
in interfaceIterativeProcessIfc
- Returns:
- true if initialized
-
isEnded
public final boolean isEnded()
Checks to see if the simulation is in the ended state If it is ended, it may be for a number of reasons- Specified by:
isEnded
in interfaceIterativeProcessIfc
- Returns:
- true if end
-
isCreated
public final boolean isCreated()
Description copied from interface:IterativeProcessIfc
Checks if the iterative process is in the created state. If the iterative process is in the created state this method will return true- Specified by:
isCreated
in interfaceIterativeProcessIfc
- Returns:
- true if in the created state
-
stoppedByCondition
public final boolean stoppedByCondition()
Checks if the simulation has ended because it was stopped- Specified by:
stoppedByCondition
in interfaceIterativeProcessIfc
- Returns:
- true if stopped by condition
-
isDone
public final boolean isDone()
Checks if the simulation is done processing replications- Specified by:
isDone
in interfaceIterativeProcessIfc
- Returns:
- true if done
-
allStepsCompleted
public final boolean allStepsCompleted()
Checks if the simulation completed all of its replications- Specified by:
allStepsCompleted
in interfaceIterativeProcessIfc
- Returns:
- true if all
-
setMaximumExecutionTime
public final void setMaximumExecutionTime(long milliseconds)
Sets a real clock time for how long the entire simulation can last- Specified by:
setMaximumExecutionTime
in interfaceIterativeProcessIfc
- Parameters:
milliseconds
- the max allowed
-
getMaximumAllowedExecutionTime
public final long getMaximumAllowedExecutionTime()
Returns the real clock time in milliseconds for how long the simulation is allowed to run- Specified by:
getMaximumAllowedExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- the max allowed
-
getEndExecutionTime
public final long getEndExecutionTime()
The absolute time in milliseconds that the simulation ended- Specified by:
getEndExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- the end time (in real clock time)
-
getElapsedExecutionTime
public final long getElapsedExecutionTime()
The time in milliseconds between when the simulation was started and the simulation ended- Specified by:
getElapsedExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- the elapsed time (in real clock time)
-
getBeginExecutionTime
public final long getBeginExecutionTime()
The absolute time in milliseconds that the simulation was started- Specified by:
getBeginExecutionTime
in interfaceIterativeProcessIfc
- Returns:
- the begin time (in real clock time)
-
getStoppingMessage
public final java.lang.String getStoppingMessage()
The message supplied with stop()- Specified by:
getStoppingMessage
in interfaceIterativeProcessIfc
- Returns:
- the stopping message
-
turnOnTimer
public final void turnOnTimer(long milliseconds)
Turns on a default timer and task to report on simulation progress- Specified by:
turnOnTimer
in interfaceIterativeProcessIfc
- Parameters:
milliseconds
- time for timer task
-
turnOnLogReport
public final void turnOnLogReport()
-
turnOnLogReport
public final void turnOnLogReport(java.lang.String reportFileName)
- Parameters:
reportFileName
- the name of the report
-
turnOnLogReport
public final void turnOnLogReport(java.nio.file.Path pathToFile)
Turns on a default logging report with the provided name- Specified by:
turnOnLogReport
in interfaceIterativeProcessIfc
- Parameters:
pathToFile
- the path to the file
-
turnOffLogReport
public final void turnOffLogReport()
Turns of the default logging report- Specified by:
turnOffLogReport
in interfaceIterativeProcessIfc
-
getNumberStepsCompleted
public final long getNumberStepsCompleted()
For the IterativeProcessIfc. Returns the number of steps (replications) completed- Specified by:
getNumberStepsCompleted
in interfaceIterativeProcessIfc
- Returns:
- number of steps completed
-
getLogReport
public final IPLogReport getLogReport()
Gets the IPLogReport that was attached to the simulation- Specified by:
getLogReport
in interfaceIterativeProcessIfc
- Returns:
- the IPLogReport
-
getCurrentReplicationNumber
public final int getCurrentReplicationNumber()
Returns the current number of replications completed- Specified by:
getCurrentReplicationNumber
in interfaceExperimentGetIfc
- Returns:
- the number as a double
-
hasMoreReplications
public final boolean hasMoreReplications()
Description copied from interface:ExperimentGetIfc
Checks if the current number of replications that have been executed is less than the number of replications specified.- Specified by:
hasMoreReplications
in interfaceExperimentGetIfc
- Returns:
- true if more
-
getNumberOfReplications
public final int getNumberOfReplications()
Returns the number of replications for the experiment- Specified by:
getNumberOfReplications
in interfaceExperimentGetIfc
- Returns:
- the number of replications
-
getNumberOfStreamAdvancesPriorToRunning
public final int getNumberOfStreamAdvancesPriorToRunning()
Description copied from interface:ExperimentGetIfc
Returns the number of times that the streams should be advanced prior to running the experiment- Specified by:
getNumberOfStreamAdvancesPriorToRunning
in interfaceExperimentGetIfc
- Returns:
- number of streams to advance
-
setResetStartStreamOption
public final void setResetStartStreamOption(boolean b)
If set to true then the streams will be reset to the start of the stream prior to running the experiments. True facilitates the use of common random numbers.- Parameters:
b
- true means option is on
-
setAdvanceNextSubStreamOption
public final void setAdvanceNextSubStreamOption(boolean b)
Sets the option to have the streams advance to the beginning of the next substream after each replication- Parameters:
b
- true means option is on
-
setReplicationInitializationOption
public final void setReplicationInitializationOption(boolean repInitOption)
Sets whether or not the replication should be initialized before each replication- Parameters:
repInitOption
- true for initialize
-
setNumberOfReplications
public final void setNumberOfReplications(int numReps, boolean antitheticOption)
Sets the number of replications to be executed and whether or not the antithetic option is on. If the antithetic option is on then the number of replications should be divisible by 2 so that antithetic pairs can be formed.- Parameters:
numReps
- number of replicationsantitheticOption
- true means option is on
-
setNumberOfReplications
public final void setNumberOfReplications(int numReps)
Sets the number of replications to be executed. The antithetic option is off- Parameters:
numReps
- number of replications
-
setMaximumExecutionTimePerReplication
public final void setMaximumExecutionTimePerReplication(long milliseconds)
Sets in real clock time (milliseconds) the amount of time available for each replication within the simulation. If the replication lasts longer than the supplied time it will be stopped- Parameters:
milliseconds
- clock time for a replication
-
setLengthOfWarmUp
public final void setLengthOfWarmUp(double lengthOfWarmUp)
Allows the length of the warm up period for each replication to be set- Parameters:
lengthOfWarmUp
- in simulation time
-
setLengthOfReplication
public final void setLengthOfReplication(double lengthOfReplication)
Sets the length of the replications in simulation time.- Parameters:
lengthOfReplication
- the length of the replication
-
getExperimentName
public final java.lang.String getExperimentName()
Description copied from interface:ExperimentGetIfc
Gets the name.- Specified by:
getExperimentName
in interfaceExperimentGetIfc
- Returns:
- The name of object.
-
getExperimentId
public final long getExperimentId()
Description copied from interface:ExperimentGetIfc
Returns the id for this object- Specified by:
getExperimentId
in interfaceExperimentGetIfc
- Returns:
- the id
-
getResetStartStreamOption
public final boolean getResetStartStreamOption()
Returns whether or not the start stream will be reset prior to executing the simulation- Specified by:
getResetStartStreamOption
in interfaceExperimentGetIfc
- Returns:
- true if option is on
-
getAdvanceNextSubStreamOption
public final boolean getAdvanceNextSubStreamOption()
Returns how many times the random number streams will be advanced before the simulation starts.- Specified by:
getAdvanceNextSubStreamOption
in interfaceExperimentGetIfc
- Returns:
- true if option is on
-
getReplicationInitializationOption
public final boolean getReplicationInitializationOption()
Returns whether or not replications will be initialized prior to running each replication- Specified by:
getReplicationInitializationOption
in interfaceExperimentGetIfc
- Returns:
- true if replications will be initialized
-
getMaximumAllowedExecutionTimePerReplication
public final long getMaximumAllowedExecutionTimePerReplication()
Gets in real clock time (milliseconds) the amount of time available for each replication within the simulation. If the replication lasts longer than the supplied time it will be stopped- Specified by:
getMaximumAllowedExecutionTimePerReplication
in interfaceExperimentGetIfc
- Returns:
- the clock time allowed
-
getLengthOfWarmUp
public final double getLengthOfWarmUp()
Provides the length of the warm up period for each replication- Specified by:
getLengthOfWarmUp
in interfaceExperimentGetIfc
- Returns:
- the length of the warm up period
-
getLengthOfReplication
public final double getLengthOfReplication()
Provides the length of each replication- Specified by:
getLengthOfReplication
in interfaceExperimentGetIfc
- Returns:
- the length of the replication
-
getAntitheticOption
public final boolean getAntitheticOption()
Indicates whether or not the antithetic streams have been turn on or off- Specified by:
getAntitheticOption
in interfaceExperimentGetIfc
- Returns:
- true means option is on
-
setGarbageCollectAfterReplicationFlag
public final void setGarbageCollectAfterReplicationFlag(boolean flag)
Determines whether or not System.gc() is called after each replication- Parameters:
flag
- true means yes
-
getGarbageCollectAfterReplicationFlag
public final boolean getGarbageCollectAfterReplicationFlag()
Returns whether or not System.gc() is called after each replication- Specified by:
getGarbageCollectAfterReplicationFlag
in interfaceExperimentGetIfc
- Returns:
- true means yes
-
setAdvanceStreamNumber
public final void setAdvanceStreamNumber(int n)
Sets the number of streams to advance prior to running an experiment- Parameters:
n
- the number to advance
-
getRepLengthWarningMessageOption
public final boolean getRepLengthWarningMessageOption()
- Returns:
- true if the flag permits the message to be printed
-
setRepLengthWarningMessageOption
public final void setRepLengthWarningMessageOption(boolean flag)
False turns off the message- Parameters:
flag
- false turns of the message
-
setExperimentName
public final void setExperimentName(java.lang.String name)
Sets the name of the underlying experiment- Parameters:
name
- the name to set
-
setExperiment
protected final void setExperiment(Experiment e)
Set the simulation experiment to the same attribute values as the supplied experiment- Parameters:
e
- the experiment
-
turnOnDefaultEventTraceReport
public final void turnOnDefaultEventTraceReport(java.lang.String name)
Turns on a default tracing report for the Executive to trace event execution to a file- Parameters:
name
- the name of the file
-
turnOnDefaultEventTraceReport
public final void turnOnDefaultEventTraceReport()
Turns on a default tracing report for the Executive to trace event execution to a file
-
turnOffDefaultEventTraceReport
public final void turnOffDefaultEventTraceReport()
Turns off a default tracing report for the Executive to trace event execution to a file
-
getDefaultExecutiveTraceReport
public final java.util.Optional<ExecutiveTraceReport> getDefaultExecutiveTraceReport()
Gets a reference to the default event tracing report. May be null if not turned on.- Returns:
- the ExecutiveTraceReport
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getHalfWidthSummaryReport
public java.lang.StringBuilder getHalfWidthSummaryReport()
- Returns:
- a StringBuilder with the Half-Width Summary Report and 95 percent confidence
-
getHalfWidthSummaryReport
public java.lang.StringBuilder getHalfWidthSummaryReport(double confLevel)
- Parameters:
confLevel
- the confidence level of the report- Returns:
- a StringBuilder with the Half-Width Summary Report
-
getHalfWidthSummaryReport
public java.lang.StringBuilder getHalfWidthSummaryReport(java.lang.String title, double confLevel)
- Parameters:
title
- the titleconfLevel
- the confidence level- Returns:
- a StringBuilder representation of the half-width summary report
-
printHalfWidthSummaryReport
public void printHalfWidthSummaryReport()
Prints the default half-width summary report to the console
-
printHalfWidthSummaryReport
public void printHalfWidthSummaryReport(double confLevel)
- Parameters:
confLevel
- the confidence level of the report
-
printHalfWidthSummaryReport
public void printHalfWidthSummaryReport(java.lang.String title, double confLevel)
- Parameters:
title
- the title of the reportconfLevel
- the confidence level of the report
-
writeHalfWidthSummaryReport
public void writeHalfWidthSummaryReport(java.io.PrintWriter out)
- Parameters:
out
- the place to write to
-
writeHalfWidthSummaryReport
public void writeHalfWidthSummaryReport(java.io.PrintWriter out, double confLevel)
- Parameters:
out
- the place to write toconfLevel
- the confidence level of the report
-
writeHalfWidthSummaryReport
public void writeHalfWidthSummaryReport(java.io.PrintWriter out, java.lang.String title, double confLevel)
- Parameters:
out
- the place to write totitle
- the title of the reportconfLevel
- the confidence level of the report
-
makeSimulationReporter
public SimulationReporter makeSimulationReporter()
Constructs a SimulationReporter instance that uses this Simulation instance- Returns:
- the SimulationReporter
-
beforeExperiment
protected void beforeExperiment()
This method is automatically called at the start of the experiment Sub-classes can inject behavior within here
-
afterExperiment
protected void afterExperiment()
This method is automatically called at the end of the experiment Sub-classes can inject behavior within here
-
beforeReplication
protected void beforeReplication()
This method is automatically called before each replication Sub-classes can inject behavior within here
-
afterReplication
protected void afterReplication()
This method is automatically called after each replication Sub-classes can inject behavior within here
-
isExecutionTimeExceeded
public final boolean isExecutionTimeExceeded()
Description copied from interface:IterativeProcessIfc
Returns if the elapsed execution time exceeds the maximum time allowed. Only true if the maximum was set and elapsed time is greater than or equal to getMaximumAllowedExecutionTime()- Specified by:
isExecutionTimeExceeded
in interfaceIterativeProcessIfc
- Returns:
- true if the execution time exceeds getMaximumAllowedExecutionTime()
-
getStoppingFlag
public final boolean getStoppingFlag()
Description copied from interface:IterativeProcessIfc
Returns the stopping flag- Specified by:
getStoppingFlag
in interfaceIterativeProcessIfc
- Returns:
- true if the process has been told to stop via stop()
-
stop
public final void stop()
Description copied from interface:IterativeProcessIfc
This sets a flag to indicate to the process that is should stop after the next step is completed. This is different than end(). Calling end() immediately places the process in the End state. The process needs to be in a valid state before end() can be used. Calling stop tells the process to eventually get into the end state. stop() can be used to arbitrarily stop the process based on some user defined condition.- Specified by:
stop
in interfaceIterativeProcessIfc
-
stop
public final void stop(java.lang.String msg)
Description copied from interface:IterativeProcessIfc
This sets a flag to indicate to the process that is should stop after the next step is completed. This is different than end(). Calling end() immediately places the process in the End state. The process needs to be in a valid state before end() can be used. Calling stop tells the process to eventually get into the end state. stop() can be used to arbitrarily stop the process based on some user defined condition.- Specified by:
stop
in interfaceIterativeProcessIfc
- Parameters:
msg
- A string to represent the reason for the stopping
-
isRunningStep
public final boolean isRunningStep()
Description copied from interface:IterativeProcessIfc
Indicates that the iterative process is currently running an individual step- Specified by:
isRunningStep
in interfaceIterativeProcessIfc
- Returns:
- true if the step is in progress
-
noStepsExecuted
public final boolean noStepsExecuted()
Description copied from interface:IterativeProcessIfc
Indicates that the iterative process ended because of no steps- Specified by:
noStepsExecuted
in interfaceIterativeProcessIfc
- Returns:
- True if no steps are executed
-
-