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

The queue inherits list and modifies __getitem__() and __bool__() to appears to only contain events for which the store‘s item queue contains proper item.

__getitem__(key)

Get the keyth event from all events that have an item available in the corresponding store’s item queue.

__bool__()

Return True if the queue contains an event for which an item is available in the corresponding store’s item queue.

__nonzero__()

Provided for backwards compatability: __bool__() is only used from Python 3 onwards.

Read the Docs v: 3.0.4
Versions
latest
stable
3.0.10
3.0.9
3.0.8
3.0.7
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0
Downloads
pdf
htmlzip
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.