Skip to content

BUFFER

Finite storage of waiting places between two machines or stations; when all places are taken the upstream machine stays blocked, holding its finished part.

Family: move. Python builder: m.buffer(...).

Typical uses

Use BUFFER to put a limit on the space between two stations. Without it, a queue in front of a machine is unlimited. With a BUFFER, a full buffer holds back the machine upstream, which is how a line with limited work in process behaves. To limit one station's own queue only, use that station's queue_capacity.

Behaviour and rules

A part takes one of the capacity places on the way in and keeps it until the next station accepts the part. If every place is taken, the upstream machine keeps its finished part, and its resource, until a place is free. This is called blocking after service.

A capacity of 0 is allowed. It means no place at all: the part never leaves the machine before the next station can start it. This is the classic zero-buffer line. There is no unlimited buffer. If you want an unlimited queue, do not draw a buffer.

The optional level mirrors the buffer's content into a declared level, so an asset can draw a fill indicator. It cannot be a conveyor level. The buffer_summary frame reports the average and maximum content and the share of time the buffer was full. It also reports the shares of time the upstream machine was blocked and the downstream one starved.

Ports

  • Inputs: any number of incoming links.
  • Outputs: one outgoing link.

Parameters

Parameter Type Default Required Quantity Unit key Description
capacity int 1 yes count Places in the buffer, 0 or more. A part takes one on the way in and holds it until the next station accepts it, so an upstream machine blocks while the buffer is full. 0 means no place at all (blocking after service with no buffer); for an unlimited queue, do not draw a buffer.
level str '' Optional level whose value mirrors the buffer's content, so an asset can draw it as a fill indicator. Empty = no level.

Statistics

Every run fills system and entity_summary (see the KPI reference). The example below also fills:

Frame Columns
resource_summary Run, Resource, Total Seizes, Usage % (snapshot), Idle %, Scheduled Capacity Avg, Down %, Busy Cost, Idle Cost, Usage Cost, Total Cost, Queue Length Avg, Queue Length Max, Queue Length at End, Queue Length Mode, Queue Length Mode %, Queue Len P95, Queue Len P99, Queue Len Std, Time in Queue Avg, Time in Queue Avg (incl. waiting), Time in Queue Max, Time in Queue Mode, Time in Queue Mode %, Wait P95, Wait P99, Wait Std, Bottleneck Score, Bottleneck %
buffer_summary Run, Block, Resource, Capacity, Avg Content, Max Content, Time Full %, Entered, Blocked %, Starved %
material_flow_summary Run, From, To, Entities

Problem codes

A check of the model reports these about this block:

Code Meaning
E_BUFFER_CAPACITY A BUFFER's capacity, or a SEIZE/PROCESS queue_capacity, is negative.
E_BUFFER_LEVEL A BUFFER's "level" names a level the model does not declare.
E_CONVEYOR_DIVERT A CONVEYOR divert is not {at, condition, time?, when_full?}, its at is off the belt or on another point, its condition is empty, its time is not a number >= 0 or an expression, its when_full is not wait/pass, the belt has fewer links than 1 + diverts, a "pass" divert's link does not go straight to a CONVEYOR, BUFFER or queue_capacity station, or an intercept divert has a push time or when_full, a bad on_late, or a link that is not the robot picking from it, a divert's side is not left or right, or a link out of the belt names an exit that is not out or d, or a routing rule is not usable, is not on the first divert of its rule_group along the belt, has an exit count other than its group's diverts, or sits beside a condition, a robot pick or when_full "pass", or a rule exit names a target piece that is not a CONVEYOR its loads reach; or a CONVEYOR_TRANSFER's links do not match its exits one to one (a port that is not one of its exits, or named twice), or its routing rule is not usable.
E_CONVEYOR_WRITE Something would write a conveyor stock directly (a TRANSFER block or agent transfer action, a BUFFER's mirror level, initial_state.levels, or a subscripted conveyor), bypassing its slat model.
E_HOLD_SPACE_TARGET hold_until_space is set but the block it reserves in (space_of, or the first link's target) is not a BUFFER with capacity > 0 or a SEIZE/PROCESS with queue_capacity > 0.
E_INITIAL_QUEUE_CAPACITY More entities wait at a block, or sit in a BUFFER, than it has places.

Example

The snippet seeds itself; its output is from a run made when this page was generated.

from nagasim import build as nb

m = nb.Model(time_limit=480, warmup=60)
m.add_resource(name="Slow")
arrive = m.create(distribution=nb.Exponential(rate=0.5))
slow = m.process(resource_name="Slow", distribution=nb.Exponential(rate=0.6))
arrive >> m.buffer(capacity=3) >> slow >> m.dispose()

results = m.run(seed=1)
print(round(results.kpi("system/Avg WIP"), 2), "entities in the model on average")
print(round(results.kpi("resource/Slow/Usage % (snapshot)"), 1), "% busy")
5.32 entities in the model on average
83.3 % busy

Used in

Bundled models: Container terminal: electrification, Container terminal: quay to yard, Line with finite buffers.

Guides: Finite buffers and blocking after service, Mobile cobots: machine tending, How do I limit the work waiting between two machines?, Digital twin, A plant as a timeline.

See also