desmod.pool

Pool class for modeling a container of resources.

A pool models a container of homogeneous resources, similar to simpy.resources.Container, but with additional events when the container is empty or full. Resources are Pool.put() or Pool.get() to/from the pool in specified amounts. The pool’s resources may be modeled as either discrete or continuous depending on whether the put/get amounts are int or float.

class desmod.pool.Pool(env: simpy.core.Environment, capacity: Union[int, float] = inf, init: Union[int, float] = 0, hard_cap: bool = False, name: Optional[str] = None)[source]

Simulation pool of discrete or continuous resources.

Pool is similar to simpy.resources.Container. It provides a simulation-aware container for managing a shared pool of resources. The resources can be either discrete objects (like apples) or continuous (like water).

Resources are added and removed using put() and get().

Parameters:
  • env – Simulation environment.
  • capacity – Capacity of the pool; infinite by default.
  • hard_cap – If specified, the pool overflows when the capacity is reached.
  • init_level – Initial level of the pool.
  • name – Optional name to associate with the queue.
capacity = None

Capacity of the pool (maximum level).

level = None

Current fill level of the pool.

remaining

Remaining pool capacity.

is_empty

Indicates whether the pool is empty.

is_full

Indicates whether the pool is full.

put[source]

alias of PoolPutEvent

get[source]

alias of PoolGetEvent

when_at_least[source]

alias of PoolWhenAtLeastEvent

when_at_most[source]

alias of PoolWhenAtMostEvent

when_any[source]

alias of PoolWhenAnyEvent

when_full[source]

alias of PoolWhenFullEvent

when_not_full[source]

alias of PoolWhenNotFullEvent

when_empty[source]

alias of PoolWhenEmptyEvent

class desmod.pool.PriorityPool(env: simpy.core.Environment, capacity: Union[int, float] = inf, init: Union[int, float] = 0, hard_cap: bool = False, name: Optional[str] = None)[source]

Pool with prioritizied put() and get() requests.

A priority is provided with put() and get() requests. This priority determines the strict order in which requests are fulfilled. Requests of the same priority are serviced in strict FIFO order.

is_empty

Indicates whether the pool is empty.

is_full

Indicates whether the pool is full.

remaining

Remaining pool capacity.

when_any

alias of PoolWhenAnyEvent

when_at_least

alias of PoolWhenAtLeastEvent

when_at_most

alias of PoolWhenAtMostEvent

when_empty

alias of PoolWhenEmptyEvent

when_full

alias of PoolWhenFullEvent

when_not_full

alias of PoolWhenNotFullEvent

put[source]

alias of PriorityPoolPutEvent

get[source]

alias of PriorityPoolGetEvent