Buffer

Bases: Edge

Buffer class representing a FIFO queue. Inherits from the Edge class. This buffer can have a single input edge and a single output edge.

Attributes:
  • state (str) –

    The current state of the buffer.

  • store_capacity (int) –

    The capacity of the buffer's internal storage.

  • mode (str) –

    Mode of operation for the buffer, It can be - "FIFO" (First In First Out) - "LIFO" (Last In First Out).

  • delay ((int, float)) –

    Delay after which the item becomes available. It Can be

    • int or float: Used as a constant delay.

Behavior: The Buffer is a type of edge represents components that holds the items that are waiting to be accepted by the destination node. Items that are added in buffer becomes available for use after delay amount of time. It operates in two modes- 1. FIFO: It prioritizes items in the order they were added, with the oldest items being available for the destination node first. 2. LIFO: It prioritizes items in the reverse order of their arrival, items that newly added are available to use by the destination node first Incoming edges can use reserve_get and reserve_put calls on the store in the buffer to reserve an item or space and after yielding the requests, an item can be put and obtained by using put and get methods.

Raises:
  • AssertionError

    If the buffer does not have at least one source node or one destination node.

Output performance metrics

The key performance metrics of the buffer edge are captured in the stats attribute (dict) during a simulation run.

last_state_change_time                      : Time when the state was last changed.
time_averaged_num_of_items_in_buffer        : Time-averaged number of items available in the buffer.
total_time_spent_in_states                  : Dictionary with total time spent in each state.

can_put()

Check if the buffer can accept an item.

Returns

bool True if the buffer can accept an item, False otherwise.

can_get()

Check if the buffer can accept an item.

Returns

bool True if the buffer can give an item, False otherwise.