Model

class Model(val simulationName: String = "Simulation", pathToOutputDirectory: Path = KSL.createSubDirectory(simulationName.replace(" ", "_") + "_OutputDir"), var autoCSVReports: Boolean = false, eventCalendar: CalendarIfc = PriorityQueueEventCalendar()) : ModelElement, ExperimentIfc

Constructors

Link copied to clipboard
constructor(simulationName: String = "Simulation", pathToOutputDirectory: Path = KSL.createSubDirectory(simulationName.replace(" ", "_") + "_OutputDir"), autoCSVReports: Boolean = false, eventCalendar: CalendarIfc = PriorityQueueEventCalendar())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The reset next sub stream option This option indicates whether the random variables used during the replication within the experiment will be reset to their next sub-stream after running each replication. The default is TRUE. This ensures that the random variables will jump to the next sub-stream within their current stream at the end of a replication. This will cause the random variables in each subsequent replication to start in the same sub-stream in the underlying random number streams if the replication is repeatedly used and the ResetStartStreamOption is set to false (which is the default) and then jump to the next sub-stream (if this option is on). This option has no effect if there is only 1 replication in an experiment.

Link copied to clipboard

A flag to control whether the model element reacts to after experiment actions.

Link copied to clipboard

A flag to control whether the model element reacts to after replication actions.

Link copied to clipboard

The simulation may end by a variety of means, this checks if the simulation ended because it ran all of its replications, true if all completed

Link copied to clipboard
open override val antitheticOption: Boolean

Indicates whether antithetic replications should be run. The default is false. If set the user must supply an even number of replications; otherwise an exception will be thrown. The replications will no longer be independent; however, pairs of replications will be independent. Thus, the number of independent samples will be one-half of the specified number of replications

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The base time units for the simulation model. By default, this is 1.0.

Link copied to clipboard

A flag to control whether the model element reacts to before experiment actions.

Link copied to clipboard

A flag to control whether the model element reacts to before replication actions.

Link copied to clipboard
val beginExecutionTime: Instant

Returns system time in nanoseconds that the simulation started

Link copied to clipboard
Link copied to clipboard
open override val currentReplicationId: Int

The identifier for the current replication. Each replication in the set of replications for the experiment has a unique identifier. This returns the identifier for the current replication. An identifier of 0 represents that no replications have been run

Link copied to clipboard
open override val currentReplicationNumber: Int

The current number of replications that have been run for this experiment

Link copied to clipboard

Indicates the current status of the model element for observers of ModelElement.Status

Link copied to clipboard

Gets the clock time in nanoseconds since the simulation was initialized

Link copied to clipboard
val endExecutionTime: Instant

Returns system time in nanoseconds that the simulation ended

Link copied to clipboard
open override var experimentalControls: Map<String, Double>

Holds values for each controllable parameter of the simulation model.

Link copied to clipboard
open override val experimentId: Int

The identity of the experiment

Link copied to clipboard
open override var experimentName: String

The name of the experiment

Link copied to clipboard
Link copied to clipboard

Causes garbage collection System.gc() to be invoked after each replication. The default is false

Link copied to clipboard
Link copied to clipboard
open override val id: Int
Link copied to clipboard

A flag to control whether the model element reacts to initialization actions

Link copied to clipboard

Checks if the simulation is in the created state. If the simulation is in the created execution state this method will return true

Link copied to clipboard

A flag to indicate whether the simulation is done A simulation can be done if:

Link copied to clipboard

Checks if the simulation is in the ended state. After the simulation has been ended this property will return true

Link copied to clipboard

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 maximumAllowedExecutionTime

Link copied to clipboard

Checks if the simulation is in the initialized state After the simulation has been initialized this method will return true

Link copied to clipboard

The complement of isRunning

Link copied to clipboard

Checks if the simulation is in the completed step state After the simulation has successfully completed a replication this property will be true

Link copied to clipboard

A model is running if it has been told to simulate (i.e. simulate() or runNextReplication()) but has not yet been told to end().

Link copied to clipboard

The simulation may end by a variety of means, this method checks if the simulation ended but was unfinished, not all replications were completed.

Link copied to clipboard
open override var label: String?
Link copied to clipboard

the left traversal count for pre-order traversal of the model element tree

Link copied to clipboard
open override var lengthOfReplication: Double

The specified length of each planned replication for this experiment. The default is Double.POSITIVE_INFINITY.

Link copied to clipboard

The length of time from the start of an individual replication to the warm-up event for that replication.

Link copied to clipboard

The responses as a list of StatisticIfc

Link copied to clipboard

The maximum allotted (suggested) execution (real) clock for the entire iterative process in nanoseconds. This is a suggested time because the execution time requirement is only checked after the completion of an individual step After it is discovered that cumulative time for executing the step has exceeded the maximum time, then the iterative process will be ended (perhaps) not completing other steps.

The maximum allowable execution time "wall" clock time for an individual replication to complete processing in nanoseconds. Set the maximum allotted (suggested) execution (real) clock for a replication. This is a proposed value because the execution time requirement is only checked after the completion of each replication After it is discovered that cumulative time for executing the replication has exceeded the maximum time, then the process will be ended (perhaps) not completing other replications.

Link copied to clipboard

the model that contains this element

Link copied to clipboard

Returns a string representation of the model element and its child model elements. Useful for realizing the model element hierarchy.

Link copied to clipboard

A flag to control whether the model element participates in monte carlo actions.

Link copied to clipboard
override val name: String
Link copied to clipboard

Gets the number of model elements contained by this model elements.

Link copied to clipboard
open override var numberOfReplications: Int

The number of replications to run for this experiment

Link copied to clipboard

Indicates the number of times the streams should be advanced prior to running the experiment

Link copied to clipboard

Returns the replications completed since the simulation was last initialized

Link copied to clipboard
open override val numChunks: Int

Indicates if the replications associated with this experiment are part of set of experiments with the same name. A chunk is an ordered subset of replications for an experiment. This field indicates the number of chunks within the experiment. There should be at least 1 chunk. If there is 1 chunk then all replications of the experiment are run as one chunk (simulation run)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Indicates the previous status of the model element for observers of ModelElement.Status This allows the transition to be noted by observers

Link copied to clipboard
open override val repIdRange: IntRange

The range of replication identifiers for the experiment based on the starting replication identifier and the number of replications to be executed.

Link copied to clipboard

A flag to control whether a warning is issued if the user does not set the replication run length

Link copied to clipboard

A flag to control whether the model element reacts to end replication actions.

Link copied to clipboard

A flag to indicate whether each replication within the experiment should be re-initialized at the beginning of each replication. True means that it will be re-initialized.

Link copied to clipboard
open override var resetStartStreamOption: Boolean

The reset start stream option This option indicates whether the random variables used during the experiment will be reset to their starting stream prior to running the first replication. The default is FALSE. This ensures that the random variable's streams WILL NOT be reset prior to running the experiment. This will cause different experiments or the same experiment run multiple times that use the same random variables (via the same model) to continue within their current stream. Therefore, the experiments will be independent when invoked within the same program execution. To get common random number (CRN), run the experiments in different program executions OR set this option to true prior to running the experiment again within the same program invocation.

Link copied to clipboard

The names of all the response variables and counters in the model

Link copied to clipboard
Link copied to clipboard

the right traversal count for pre-order traversal of the model element tree

Link copied to clipboard
open override var runErrorMsg: String
Link copied to clipboard
open override val runName: String

An optional label for the chunk

Link copied to clipboard

If the model parameters change then the user is responsible for calling extractParameters(model) on the returned RVParameterSetter

Link copied to clipboard
Link copied to clipboard

The spatial model associated with this model element. By default, each model element uses its parent model element's spatial model unless changed via this property. This changes the spatial model for this model element and no others.

Link copied to clipboard
open override var startingRepId: Int

The starting id for the sequence of identifiers used to label the replications of the experiment

Link copied to clipboard

The simulation may end by a variety of means, this method checks if the simulation ended because it was stopped, true if it was stopped via stop()

Link copied to clipboard

The current simulation time

Link copied to clipboard

The time interval between TimedUpdate events. The default is zero, indicating no timed update

Link copied to clipboard

Specifies whether this model element participates in time update event specified by its parent

Link copied to clipboard

Specifies the havingPriority of this model element's timed update event.

Link copied to clipboard
Link copied to clipboard

Indicates whether the warm-up action occurred sometime during the simulation for this model element. False indicates that the warm-up action has not occurred

Link copied to clipboard

Specifies if this model element will be warmed up when the warmup action occurs for its parent. The warm-up flag indicates whether this model element will be warmed up when its parent warm up event/action occurs. The default value for all model elements is true. A value of true implies that the model element allows its parent's warm up event to call the warm-up action. A value of false implies that the model element does not allow its parent's warm up event to call the warm-up action. False does not necessarily mean that the model element will not be warmed up. It may, through the use of the lengthOfWarmUp property, have its own warm up event and action.

Link copied to clipboard

Specifies the priority of this model element's warm up event.

Functions

Link copied to clipboard
fun addStream(stream: RNStreamIfc)
Link copied to clipboard

Advances the streams, held by the model, n times. If n <= 0, no advancing occurs

Link copied to clipboard

Causes random number streams that have been added to the model to immediately advance their random number sequence to the next sub-stream if the stream permits advancement via the advanceToNextSubStreamOption.

Link copied to clipboard
Link copied to clipboard

Cancels the timed update event for this model element.

Link copied to clipboard

Cancels the warm-up event for this model element.

Link copied to clipboard
open override fun changeRunParameters(runParameters: ExperimentRunParametersIfc)

Changes the experiment run parameters for the experiment. This does not include the current number of replications or the experiment's id. Any property in ExperimentRunParametersIfc may be changed.

Link copied to clipboard

Checks if this model element or any model element directly above this model element in the hierarchy of model elements all the way until the top Model participates in the warm-up action.

Link copied to clipboard
fun containsModelElement(modelElementName: String): Boolean

Checks to see if the model element has been registered with the Model using it's uniquely assigned name.

Link copied to clipboard
Link copied to clipboard
fun counter(name: String): Counter?

Returns the counter associated with the name or null if named element is not in the model.

Link copied to clipboard
fun day(): Double

Returns the value of a 1-day time interval in terms of the base time unit

Link copied to clipboard
fun endSimulation(msg: String? = null)

Causes the simulation to end after the current replication is completed

Link copied to clipboard
open override fun experimentInstance(): Experiment

Returns a new Experiment based on this experiment.

Link copied to clipboard

Extracts a data class representing the experiment's run parameters

Link copied to clipboard

Find the first parent that has its own warm up event this guarantees that all elements below the found model element do not have their own warm-up event. A model element that has its own warm up event also opts out of the warm-up action. If the returned parent is the Model, then all are controlled by the model (unless they opt out). Elements can opt out and not have their own warm-up event. Thus, they have no warm up at all.

Link copied to clipboard

Returns the model element that has the provided unique id or null if not found

Returns the model element associated with the name. In some sense, this model violates encapsulation for ModelElements, but since the client knows the unique name of the ModelElement, we assume that the client knows what they are doing.

Link copied to clipboard

Fills up the supplied StringBuilder carrying a string representation of the model element and its child model elements Useful for realizing the model element hierarchy.

Link copied to clipboard

This method returns the planned time for the warm-up for this model element.

Link copied to clipboard
open override fun hasExperimentalControls(): Boolean
Link copied to clipboard
open override fun hasMoreReplications(): Boolean

Checks if the current number of replications that have been executed is less than the number of replications specified.

Link copied to clipboard

Returns true if additional replications need to be run

Link copied to clipboard

Checks if the model's rvParameterSetter property has been accessed and thus that an RVParameterSetter was requested for the model

Link copied to clipboard
fun hour(): Double

Returns the value of a 1-hour time interval in terms of the base time unit

Link copied to clipboard

Fills a StringBuilder carrying the model element names in the order that they will be initialized

Link copied to clipboard

Initializes the simulation in preparation for running

Link copied to clipboard

Checks if a warm-up event is scheduled for any model element directly above this model element in the hierarchy of model elements all the way until the top Model.

Link copied to clipboard

Checks if current status is the supplied status

Link copied to clipboard

Checks if a timed update event has been scheduled for this model element

Link copied to clipboard

Checks if a warm-up event has been scheduled for this model element

Link copied to clipboard

Returns the value of a 1 millisecond time interval in terms of the base time unit

Link copied to clipboard
fun minute(): Double

Returns the value of a 1-minute time interval in terms of the base time unit. For example, if the time unit is set to hours, then minute() should return 0.0166 (TIME_UNIT_MINUTE/TIME_UNIT_HOUR)

Link copied to clipboard
open override fun numberOfReplications(numReps: Int, antitheticOption: Boolean)

Sets the desired number of replications for the experiment

Link copied to clipboard
fun print(histAndFreq: Boolean = true)

Prints basic text results to the console.

Link copied to clipboard

Returns the random variable associated with the name or null if named element is not in the model. Note that this will also return ANY instances of subclasses of RandomVariable

Link copied to clipboard
Link copied to clipboard

Causes the specified model element to be removed from the model regardless of its location within the model hierarchy. Any model elements attached to the supplied model element will also be removed.

Link copied to clipboard
Link copied to clipboard

Causes random number streams that have been added to the model to immediately reset their random number sequence to the beginning of their starting stream if the stream permits resetting via the resetStartStreamOption

Link copied to clipboard

Causes random number streams that have been added to the model to immediately reset their random number sequence to the beginning of their current sub-stream.

Link copied to clipboard
fun response(name: String): Response?

Returns the response associated with the name or null if named element is not in the model. Note that this will also return ANY instances of subclasses of Response (i.e. including TWResponse)

Link copied to clipboard

Runs the next replication if there is one

Link copied to clipboard
fun second(): Double

Returns the value of a 1-second time interval in terms of the base time unit

Link copied to clipboard

Sets the after experiment option of all model elements (children) contained by this model element.

Sets the after replication flag of all model elements (children) contained by this model element.

Sets the before experiment option of all model elements (children) contained by this model element.

Sets the before replication flag of all model elements (children) contained by this model element.

Link copied to clipboard

Sets the initialization option of all model elements (children) contained by this model element.

Link copied to clipboard

Sets the monte carlo option flag of all model elements (children) contained by this model element.

Sets the end replication option flag of all model elements (children) contained by this model element. Determines whether the replicationEnded() method will be called

Link copied to clipboard

This method can be used to ensure that all model elements within the model use the same spatial model.

Link copied to clipboard

Sets the timed update option flag of all model elements (children) contained by this model element.

Link copied to clipboard

Sets the warm-up option flag of all model elements (children) contained by this model element.

Link copied to clipboard
fun simulate()

Runs all remaining replications based on the current settings

fun simulate(numReps: Int = 1, runLength: Double, warmUp: Double = 0.0, expName: String? = null)

A convenience method for running a simulation

Link copied to clipboard
fun statisticalBatching(batchingInterval: Double = 0.0, name: String? = null): StatisticalBatchingElement

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

Link copied to clipboard

Returns the TWResponse associated with the name or null if named element is not in the model. Note that this will also return ANY instances of subclasses of TWResponse

Link copied to clipboard
open override fun toString(): String

Includes the model name, the id, the model element name, the parent name, and parent id

Detaches the CSVExperimentReport from the model.

Link copied to clipboard

Tells the model to stop collecting and reporting within and across replication statistics as comma separated value (CSV) files.

Link copied to clipboard

Detaches the CSVReplicationReport from the model.

Attaches the CSVExperimentReport to the model if not attached.

Link copied to clipboard

Tells the model to capture statistical output for within replication and across replication responses to comma separated value files. If you do not want both turned on, or you want to control the reporting more directly then use the individual functions for this purpose. Turning on the reporting only effects the next simulation run. So, turn on the reporting before you simulate. If you want the reporting all the time, then just supply the autoCSVReports option as true when you create the model.

Link copied to clipboard

Attaches the CSVReplicationReport to the model if not attached. If you turn on the reporting, you need to do it before running the simulation.

Link copied to clipboard
fun validateInputKeys(inputKeys: Set<String>, conCatString: Char = rvParamConCatChar): Boolean

Checks if the supplied set of strings are valid inputs (controls or random variable parameters).

Link copied to clipboard
fun week(): Double

Returns the value of a 1-week time interval in terms of the base time unit