ResourcePool

open class ResourcePool @JvmOverloads constructor(parent: ModelElement, poolResources: List<Resource>, name: String? = null) : AbstractResourcePool<Resource> , ResourcePoolCIfc(source)

A ResourcePool represents a list of Resources from which resources can be selected to fill requests made by Entities.

Resources are selected according to a ResourceSelectionRule. The assumption is that any of the resources within the pool may be used to fill the request.

If no selection rule is supplied the pool selects a list of resources that can fully satisfy the request and makes allocations to the resources based on the order in which they are listed in the pool.

Author

rossetti

Parameters

parent

the parent model element

poolResources

a list of resources to be included in the pool

name

the name of the pool

Inheritors

Constructors

Link copied to clipboard
constructor(parent: ModelElement, poolResources: List<Resource>, name: String? = null)
constructor(parent: ModelElement, numResources: Int = 1, name: String? = null)

Makes the specified number of single unit resources and includes them in the pool.

Functions

Link copied to clipboard
open override fun addResource(resource: Resource)

Adds a resource to the pool. The model must not be running when adding a resource.

Link copied to clipboard
fun allocate(entity: ProcessModel.Entity, amountNeeded: Int = 1, queue: RequestQ, resourceSelectionRule: ResourceSelectionRuleIfc = defaultResourceSelectionRule, resourceAllocationRule: ResourceAllocationRuleIfc = defaultResourceAllocationRule, allocationName: String? = null): ResourcePoolAllocation

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
fun canAllocate(resourceSelectionRule: ResourceSelectionRuleIfc, amountNeeded: Int): Boolean

For use, before calling allocate()

Link copied to clipboard
fun deallocate(poolAllocation: ResourcePoolAllocation)
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

Link copied to clipboard
protected open fun makeAllocations(resourceAllocationRule: ResourceAllocationRuleIfc, amountNeeded: Int, resourceList: MutableList<Resource>): Map<Resource, Int>
Link copied to clipboard
protected open fun selectResources(resourceSelectionRule: ResourceSelectionRuleIfc, amountNeeded: Int): MutableList<Resource>

Uses the pool's resource selection rule to select resources from those that are available that have enough units available to satisfy the request in full. If there are insufficient resources in the pool to satisfy the full amount, then the returned list will be empty. In general, the returned list may have more units available than the requested amount.