Resource

open class Resource @JvmOverloads constructor(parent: ModelElement, name: String? = null, capacity: Int = 1) : ProcessModel, ResourceCIfc(source)

A Resource represents a number of common units that can be allocated to entities. A resource has an initial capacity that can be changed during a replication.

A resource is busy if at least 1 unit has been allocated. A resource becomes busy when it has allocations. If a seize-request occurs and the resource has capacity to fill it completely, then the request is allocated the requested amount. If insufficient capacity is available at the time of the request, then the request waits until the requested units can be allocated.

If b(t) is the number of units allocated at time t, and c(t) is the current capacity of the resource, then the number of available units, a(t), is defined as a(t) = c(t) - b(t). Thus, a resource is idle if a(t) = c(t). Since a resource is busy if b(t) 0, busy and idle are complements of each other. A resource is either busy b(t) 0 or idle b(t) = 0. If a(t) 0, then the resource has units that can be allocated.

The utilization of a resource is defined as the ratio of the average number of busy units to the average number of active units. Units are active if they are part of the current capacity of the resource.

Subclasses of Resource implement additional state behavior.

Parameters

parent

the parent holding this resource

name

the name of the resource

capacity

the initial capacity of the resource. Cannot be changed during a replication. The default capacity is 1.

Inheritors

Constructors

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

Types

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

Properties

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 via the useSchedule() function or when there is no schedule being used. The rule cannot be changed when there are pending capacity changes.

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 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 = 0.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

The initial request queue notification rule for controlling the order in which queues are notified for processing requests after a capacity change.

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

Changing this during a replication will only affect the current replication. The rule will be reset to the initial setting at the beginning of each replication.

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
open override var selectionCriteria: Double

A general attribute that can be used to assist with selecting resources

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

time average instantaneous utilization

Link copied to clipboard

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

Functions

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

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

Causes the resource to deallocate the amount associated with the allocation

Link copied to clipboard
Link copied to clipboard

Checks if the entity is using (has allocated units) of the resource.

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

Resources can be associated with a capacity change schedule. If a capacity change occurs, especially a decrease that makes the resource inactive or an increase that allows the resource to be available occurs, then queues that hold requests for the resource may want to be notified of the capacity change.

Link copied to clipboard

Removes the listener

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

This function permits a queue to be unregistered from a resource. If the queue was not registered, then nothing occurs.

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

Tells the resource to listen and react to capacity changes in the supplied Schedule. The model cannot be running when changing the schedule.