ResourceWithQ

open class ResourceWithQ(parent: ModelElement, name: String? = null, capacity: Int = 1, queue: RequestQ? = null) : Resource, ResourceWithQCIfc

A resource is considered busy if at least 1 unit is allocated. A resource is considered idle if no units have been allocated. The capacity can be changed during a replication; however, the capacity of every replication starts at the same initial capacity.

A resource is considered inactive if all of its units of capacity are inactive. That is, a resource is inactive if its capacity is zero and there are no busy units. Capacity can only become 0 via the use of a CapacitySchedule or via the use of a CapacityChangeNotice. A resource that is inactive can be seized. If a request for units occurs when the resource is inactive, the request waits (as usual) until it can be fulfilled.

Define b(t) as the number of units allocated and c(t) as the current capacity of the resource at time t.

If (b(t) = 0 and c(t) = 0) then the resource is considered inactive If b(t) 0 and c(t) >= 0, then the resource is busy If b(t) = 0 and c(t) 0, then the resource is idle

Note that a resource may be busy when the capacity is 0 because of the timing of capacity changes.

Parameters

parent

the containing model element

capacity

the capacity for the resource at the beginning of each replication, must be at least 1

name

the name for the resource

queue

the queue for waiting entities. If a request for units cannot immediately be met, then this is where the request waits. If a queue is not supplied, a default queue will be created. Supplying a queue allows resources to share request queues.

Inheritors

Constructors

Link copied to clipboard
constructor(parent: ModelElement, name: String? = null, capacity: Int = 1, queue: RequestQ? = null)

Types

Link copied to clipboard
inner class CapacityChangeNotice(val capacity: Int = 0, val duration: Double = Double.POSITIVE_INFINITY, val priority: Int = KSLEvent.DEFAULT_PRIORITY)

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
open override val busyState: StateAccessorIfc

Access to the busy state. Busy means at least 1 unit of the resource is allocated.

Link copied to clipboard
open override var capacity: Int

The current capacity of the resource. In general, it can be 0 or greater

Link copied to clipboard

The default rule is IGNORE. This can be changed when a CapacitySchedule is used.

Link copied to clipboard

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

Link copied to clipboard
open override var defaultReportingOption: Boolean

Returns the default reporting option. True means that the response should appear on the default reports

Link copied to clipboard
open override val hasAvailableUnits: Boolean

If a(t) is greater than zero

Link copied to clipboard
open override val hasBusyUnits: Boolean

If b(t) is greater than zero

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

Access to the idle state. Idle means that no units of the resource are allocated.

Link copied to clipboard
open override val inactiveState: StateAccessorIfc

Access to the inactive state. Inactive means that the capacity of the resource is 0

Link copied to clipboard
@set:KSLControl(controlType = ControlType.INTEGER, lowerBound = 1.0)
open override var initialCapacity: Int

The initial capacity of the resource at the start of the replication. The initial capacity must be greater than 0.

Link copied to clipboard

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

Link copied to clipboard
open override val instantaneousUtil: Double

If b(t) is the number of busy units, and c(t) is the current capacity, then the instantaneous utilization iu(t) is

Link copied to clipboard
open override val isBusy: Boolean

Checks to see if the resource is busy, has some units allocated

Link copied to clipboard
open override val isIdle: Boolean

Checks if the resource is idle, has no units allocated

Link copied to clipboard
open override val isInactive: Boolean

Checks to see if the resource is inactive

Link copied to clipboard

Indicates whether capacity changes are pending. The resource cannot allocate units when capacity changes are pending because released busy units will be used to fill the capacity change.

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

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
Link copied to clipboard
open override val numAvailableUnits: Int

If c(t) is the current capacity and b(t) is the current number busy, then a(t) = c(t) - b(t) is the current number of available units. Under some capacity change situations, a(t) may be negative.

Link copied to clipboard

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

Link copied to clipboard
open override var numBusy: Int

The number of busy units at any time t, b(t)

Link copied to clipboard
open override val numBusyUnits: TWResponseCIfc

Statistical response representing the number of busy units of the resource.

Link copied to clipboard
open override var numTimesReleased: Int

The number of times that the resource has been released (deallocated)

Link copied to clipboard
open override var numTimesSeized: Int

The number of times that the resource has been seized (allocated)

Link copied to clipboard
open override val previousState: StateAccessorIfc

The last (previous) state before the current state.

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
open override val scheduledUtil: ResponseCIfc

Statistical response representing the utilization of the resource. This is the time average number of busy units divided by the time average capacity.

Link copied to clipboard
open override val seizeCounter: CounterCIfc

The number of times the resource was seized

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

Time when state time accumulation started. May be greater than 0 because of warmup.

Link copied to clipboard
open override val state: StateAccessorIfc

The current state of the resource.

Link copied to clipboard

Indicates if proportion of time spent in states (idle, busy, inactive) is automatically reported

Link copied to clipboard

The current simulation time

Link copied to clipboard

time average instantaneous utilization

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

Total time that the resource has been idle, busy, or inactive

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 activate(process: KSLProcess, timeUntilActivation: Double = 0.0, priority: Int = KSLEvent.DEFAULT_PRIORITY): KSLEvent<KSLProcess>
fun activate(process: KSLProcess, timeUntilActivation: GetValueIfc, priority: Int = KSLEvent.DEFAULT_PRIORITY): KSLEvent<KSLProcess>

Cause the entity to start the process. The activation of the process is governed by an event that is scheduled to occur at the specified activation time.

Link copied to clipboard

Add an allocation listener. Allocation listeners are notified when (after) units are allocated to an entity and after units are deallocated.

Link copied to clipboard
fun allocate(entity: ProcessModel.Entity, amountNeeded: Int = 1, queue: RequestQ, allocationName: String? = null): Allocation

It is an error to attempt to allocate resource units to an entity if there are insufficient units available. Thus, the amount requested must be less than or equal to the number of units available at the time of this call.

Link copied to clipboard
Link copied to clipboard
fun canAllocate(amountNeeded: Int = 1): Boolean

A resource may fill a request in many ways. This function indicates if the request for the amount needed can be allocated immediately, without any wait based on the current state of the resource. Since the underlying state of the resource may be more complex than indicated by the state exposed in the API, it is important to use this method to determine if the requested amount can be allocated.

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

It is an error to try to change the capacity directly via this method if the resource is using a capacity change schedule.

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
open override fun deallocate(allocation: Allocation)

Causes the resource to deallocate the amount associated with the allocation

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

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
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 the entity is using (has allocated units) of the resource.

Link copied to clipboard
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

Computes the number of different allocations of the resource held by the entity. Recall that allocations can be for different amounts.

Link copied to clipboard

Removes the listener

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

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 <T : ProcessModel.Entity> startProcessSequence(entity: T, timeUntilActivation: Double = 0.0, priority: Int = KSLEvent.DEFAULT_PRIORITY): KSLEvent<KSLProcess>?

Cause the entity to start the process sequence in the order specified by the sequence. The activation of the first process is governed by an event that is scheduled to occur based on the time until activation parameter.

fun <T : ProcessModel.Entity> startProcessSequence(entity: T, timeUnitActivation: GetValueIfc, priority: Int = KSLEvent.DEFAULT_PRIORITY): KSLEvent<KSLProcess>?

Cause the entity to start the process sequence in the order specified by the sequence. The activation of the first process is governed by an event that is scheduled to occur at the specified activation time.

Link copied to clipboard

If the resource is using a schedule, the resource stops listening for capacity changes and is no longer using a schedule. The current capacity will be used for the remainder of the replication.

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

Computes the total number of units of the specified resource that are allocated to the entity.

Link copied to clipboard
fun useSchedule(schedule: CapacitySchedule, changeRule: CapacityChangeRule = CapacityChangeRule.IGNORE)

Tells the resource to listen and react to capacity changes in the supplied Schedule.

Link copied to clipboard
fun week(): Double

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