EventGenerator

open class EventGenerator(parent: ModelElement, generateAction: GeneratorActionIfc? = null, timeUntilFirstRV: RandomIfc = ConstantRV.ZERO, timeBtwEventsRV: RandomIfc = ConstantRV.POSITIVE_INFINITY, maxNumberOfEvents: Long = Long.MAX_VALUE, timeOfTheLastEvent: Double = Double.POSITIVE_INFINITY, name: String? = null) : ModelElement, EventGeneratorIfc

This class allows for the periodic generation of events similar to that achieved by "Create" modules in simulation languages. This class works in conjunction with the EventGeneratorActionIfc which is used to listen and react to the events that are generated by this class.

Classes can supply an instance of an EventGeneratorActionIfc to provide the actions that take place when the event occurs. Alternatively, if no EventGeneratorActionIfc is supplied, by default the generator(JSLEvent event) method of this class will be called when the event occurs. Thus, subclasses can simply override this method to provide behavior for when the event occurs. If no EventGeneratorActionIfc is supplied and the method generate() method is not overridden, then the events will still occur; however, no meaningful actions will take place.

Of particular note is the use of initial parameters:

initial time of first event (default = Constant.ZERO) initial time between events (default = Constant.POSITIVE_INFINITY) initial maximum number of events (default = Long.MAX_VALUE) initial ending time (default = Double.POSITIVE_INFINITY)

These parameters control the initial state of the generator at the start of each replication. The generator is re-initialized to these values at the start of each replication. There are also parameters for each of these that can be changed during a replication. The effect of that change is only within the current replication.

Parameters

parent

the parent model element

generateAction

The action supplies the generation logic for reacting to the generated event.

timeUntilFirstRV

A RandomIfc object that supplies the time until the first event.

timeBtwEventsRV

A RandomIfc object that supplies the time between events. Must not be a RandomIfc that always returns 0.0, if the maximum number of generations is infinite (Long.MAX_VALUE)

maxNumberOfEvents

A long that supplies the maximum number of events to generate. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. The default is Long.MAX_VALUE. This parameter cannot be Long.MAX_VALUE when the time until next always returns a value of 0.0

timeOfTheLastEvent

A double that supplies a time to stop generating events. When the generator is created, this variable is used to set the ending time of the generator. Each time an event is to be scheduled the ending time is checked. If the time of the next event is past this time, then the generator is turned off and the event won't be scheduled. The default is Double.POSITIVE_INFINITY.

name

the name of the generator

Constructors

Link copied to clipboard
constructor(parent: ModelElement, generateAction: GeneratorActionIfc? = null, timeUntilFirstRV: RandomIfc = ConstantRV.ZERO, timeBtwEventsRV: RandomIfc = ConstantRV.POSITIVE_INFINITY, maxNumberOfEvents: Long = Long.MAX_VALUE, timeOfTheLastEvent: Double = Double.POSITIVE_INFINITY, name: String? = null)

Types

Link copied to clipboard
interface ActionStepIfc
Link copied to clipboard
interface BuildStepIfc
Link copied to clipboard
object Companion
Link copied to clipboard

Properties

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

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

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

Link copied to clipboard
open override var endingTime: Double

The time to stop generating for the current replication

Link copied to clipboard
open override var eventCount: Long

The number of events currently generated during the replication

Link copied to clipboard

Determines the priority of the event generator's events The default is DEFAULT_PRIORITY - 1 A lower number implies higher priority.

Link copied to clipboard
open override val id: Int
Link copied to clipboard
@set:KSLControl(controlType = ControlType.DOUBLE, name = "initialEndingTime", lowerBound = 0.0)
open override var initialEndingTime: Double

Used to set the ending time when the generator is initialized at the start of each replication.

Link copied to clipboard

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

Link copied to clipboard

Controls the maximum number of events to be used to initialize each replication. The time between events cannot evaluate to a constant value of 0.0 if the maximum number of events is infinite (Long.MAX_VALUE). Uses the current value for initial time between events

Link copied to clipboard
open override var initialTimeBtwEvents: RandomIfc

Sets the time between events and the maximum number of events to be used to initialize each replication. The time between events cannot evaluate to a constant value of 0.0. The maximum number of events is kept at its current value, which by default is Long.Max_Value

Link copied to clipboard

Controls the random variable representing the time until the first event that is used at the beginning of each replication to generate the time until the first event. This change becomes effective at the beginning of the next replication to execute

Link copied to clipboard
open override var isDone: Boolean

Whether the generator is done generating

Link copied to clipboard
open override val isEventPending: Boolean

true if an event is scheduled to occur for the generator

Link copied to clipboard
open override var isStarted: Boolean

indicates whether the generator has been started (turned on)

Link copied to clipboard
open override var isSuspended: Boolean

Whether the generator has been suspended

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 maximumNumberOfEvents: Long

The number of events to generate for the current replication

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

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

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

Link copied to clipboard

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

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
@set:KSLControl(controlType = ControlType.BOOLEAN, name = "startOnInitializeOption")
open override var startOnInitializeOption: Boolean

This flag controls whether the generator starts automatically when initialized at the beginning of a replication By default this option is true. If it is changed then it remains at the set value until changed again.

Link copied to clipboard

The current simulation time

Link copied to clipboard
open override var timeBetweenEvents: RandomIfc

The time between events for the current replication

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

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

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

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 day(): Double

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

Link copied to clipboard

Can be used to supply logic to invoke when the generator's ending time is finite and the generator is turned off.

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

Can be used to supply logic to invoke when the generator's is supposed to generate

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
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

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 resume()

Resume the generation of events according to the time between event distribution.

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.

open override fun setInitialTimeBetweenEventsAndMaxNumEvents(initialTimeBtwEvents: RandomIfc, initialMaxNumEvents: Long)

Sets the time between events and the maximum number of events to be used to initialize each replication. These parameters are dependent. The time between events cannot evaluate to a constant value of 0.0 if the maximum number of events is infinite (Long.MAX_VALUE)

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
open override fun setTimeBetweenEvents(timeBtwEvents: RandomIfc, maxNumEvents: Long)

Sets the time between events and the maximum number of events for the generator. These two parameters are dependent. The time between events cannot always evaluate to 0.0 if the maximum number of events is infinite (Long.MAX_VALUE). This method only changes these parameters for the current replication. The changes take effect when the next event is generated. If current number of events that have been generated is greater than or equal to the supplied maximum number of events, the generator will be turned off.

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
open override fun suspend()

Suspends the generation of events and cancels the next scheduled event from the generator

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

Link copied to clipboard
open override fun turnOffGenerator()

This method turns the generator off, the next scheduled generation event will NOT occur, i.e. this method will also cancel a previously scheduled generation event if one exists. No future events will be scheduled after turning off the generator

Link copied to clipboard
open override fun turnOnGenerator(t: Double)
open override fun turnOnGenerator(r: RandomIfc)

If the generator was not started upon initialization at the beginning of a replication, then this method can be used to start the generator

Link copied to clipboard
fun week(): Double

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