simpy.resources.container — Container type resources

This module contains all Container like resources.

Containers model the production and consumption of a homogeneous, undifferentiated bulk. It may either be continuous (like water) or discrete (like apples).

For example, a gasoline station stores gas (petrol) in large tanks. Tankers increase, and refuelled cars decrease, the amount of gas in the station’s storage tanks.

class simpy.resources.container.Container(env, capacity, init=0)

Models the production and consumption of a homogeneous, undifferentiated bulk. It may either be continuous (like water) or discrete (like apples).

The env parameter is the Environment instance the container is bound to.

The capacity defines the size of the container and must be a positive number (> 0). By default, a container is of unlimited size. You can specify the initial level of the container via init. It must be >= 0 and is 0 by default.

Raise a ValueError if capacity <= 0, init < 0 or init > capacity.

capacity

The maximum capacity of the container.

level

The current level of the container (a number between 0 and capacity).

put

Creates a new ContainerPut event.

alias of ContainerPut

get

Creates a new ContainerGet event.

alias of ContainerGet

class simpy.resources.container.ContainerPut(container, amount)

An event that puts amount into the container. The event is triggered as soon as there’s enough space in the container.

Raise a ValueError if amount <= 0.

amount = None

The amount to be put into the container.

class simpy.resources.container.ContainerGet(resource, amount)

An event that gets amount from the container. The event is triggered as soon as there’s enough content available in the container.

Raise a ValueError if amount <= 0.

amount = None

The amount to be taken out of the container.