simpy.resources.store — Store type resources

This module contains all Store like resources.

Stores model the production and consumption of concrete objects. The object type is, by default, not restricted. A single Store can even contain multiple types of objects.

Beside Store, there is a FilterStore that lets you use a custom function to filter the objects you get out of the store.

class simpy.resources.store.Store(env, capacity=inf)

Models the production and consumption of concrete Python objects.

Items put into the store can be of any type. By default, they are put and retrieved from the store in a first-in first-out order.

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

The capacity defines the size of the Store and must be a positive number (> 0). By default, a Store is of unlimited size. A ValueError is raised if the value is negative.

items = None

List of the items within the store.

capacity

The maximum capacity of the store.

put

Create a new StorePut event.

alias of StorePut

get

Create a new StoreGet event.

alias of StoreGet

class simpy.resources.store.FilterStore(env, capacity=inf)

The FilterStore subclasses Store and allows you to only get items that match a user-defined criteria.

This criteria is defined via a filter function that is passed to get(). get() only considers items for which this function returns True.

Note

In contrast to Store, processes trying to get an item from FilterStore won’t necessarily be processed in the same order that they made the request.

Example: The store is empty. Process 1 tries to get an item of type a, Process 2 an item of type b. Another process puts one item of type b into the store. Though Process 2 made his request after Process 1, it will receive that new item because Process 1 doesn’t want it.

GetQueue

The type to be used for the get_queue.

alias of FilterQueue

get

Create a new FilterStoreGet event.

alias of FilterStoreGet

class simpy.resources.store.StorePut(resource, item)

Put item into the store if possible or wait until it is.

item = None

The item to put into the store.

class simpy.resources.store.StoreGet(resource)

Get an item from the store or wait until one is available.

class simpy.resources.store.FilterStoreGet(resource, filter=lambda item: True)

Get an item from the store for which filter returns True. This event is triggered once such an event is available.

The default filter function returns True for all items, and thus this event exactly behaves like StoreGet.

filter = None

The filter function to use.

class simpy.resources.store.FilterQueue

A queue that only lists those events for which there is an item in the corresponding store.