Variable

open class Variable @JvmOverloads constructor(parent: ModelElement, theInitialValue: Double = 0.0, allowedDomain: Interval = Interval(), name: String? = null) : ModelElement, VariableIfc(source)

Simulation models may use many variables that define the state of the component/system being modeled. Within the context of stochastic simulation the values of the variables may change during the execution of a replication (i.e., the generation of a sample path). It is important to ensure that each replication starts in the same state (i.e., with the same initial conditions). Thus, if variable values change during the replication, the value of the variable must be returned to its initial value prior to the execution of the next replication. The purpose of this class is to facilitate the specification of the initial value and the resetting to the initial value prior to the experiments and the future replications. Additionally, the value of a variable might need to be constrained to a legally specified range or interval. Because of the random nature of simulation, model logic might attempt to set the value of a variable outside its legal set of values. This class allows the specification of a valid interval for the variable. If the user attempts to set the value outside this interval, then an exception will be thrown. This facilitates validation of the model.

Author

rossetti@uark.edu

Parameters

parent

the parent (containing) model element for this variable

theInitialValue

the initial value, defaults to 0.0

allowedDomain

the validity interval, defaults to NEGATIVE_INFINITY, POSITIVE_INFINITY

name

The name of the variable will be auto-defined if null.

Inheritors

Constructors

Link copied to clipboard
constructor(parent: ModelElement, theInitialValue: Double = 0.0, allowedDomain: Interval = Interval(), name: String? = null)

Properties

Link copied to clipboard
open override val domain: Interval
Link copied to clipboard
@set:KSLControl(controlType = ControlType.DOUBLE)
open override var initialValue: Double

Sets the initial value of the variable. Only relevant prior to each replication. Changing during a replication has no effect until the next replication.

Link copied to clipboard
open override var previousTimeOfChange: Double
Link copied to clipboard
open override var previousValue: Double

The previous value, before the current value changed

Link copied to clipboard
open override var timeOfChange: Double
Link copied to clipboard
open override var value: Double

Functions

Link copied to clipboard
protected open fun assignInitialValue(value: Double)

Assigns the value of the variable to the supplied value. Ensures that time of change is 0.0 and previous value and previous time of change are the same as the current value and current time without notifying any update observers

Link copied to clipboard
protected open fun assignValue(newValue: Double)
Link copied to clipboard
open fun asString(): String
Link copied to clipboard
protected open override fun beforeExperiment()

This method should be overridden by subclasses that need logic to be performed prior to an experiment. The beforeExperiment method allows model elements to be set up prior to the first replication within an experiment. It is called once before any replications occur.

Link copied to clipboard
protected open override fun initialize()

This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called