HOLD¶
Holds entities waiting in a queue until a named signal fires, a condition becomes true (a buffer has room, a machine is idle), or for good.
Infinite mode never releases: the entity stays held in the store for the rest of the run. That is the documented semantics, not a leak.
Family: control. Python builder: m.hold(...).
Typical uses¶
Use HOLD to keep entities waiting until something outside the flow happens: a shift starts, a gate opens, a buffer has room, a machine is idle. In Signal mode, a SIGNAL block releases them. In Condition mode, the entity waits until its own tests are true. Infinite mode parks entities for good.
Behaviour and rules¶
All waiting entities sit in the block's store, so the store_summary frame reports how many wait and for how long. In Signal mode, the entity waits for the next broadcast of that signal name. A signal that fires before the entity arrives is missed. The signal is not remembered.
A signal releases every entity waiting on that name at that instant. They then leave one by one in the same instant. In Condition mode, all conditions must be true. An entity whose conditions are already true passes without waiting.
The block re-checks the conditions whenever something they read changes, such as a variable, a queue length, a resource state, a store or a level threshold. If a condition reads the clock, a time series or a random draw, nothing announces a change. The block then also re-checks every scan_interval.
In Infinite mode, the entity never leaves. It stays in the work in progress until the run ends. This is intended and not a leak.
Ports¶
- Inputs: any number of incoming links.
- Outputs: one outgoing link.
Parameters¶
| Parameter | Type | Default | Required | Quantity | Unit key | Description |
|---|---|---|---|---|---|---|
mode |
str | 'Signal' |
"Signal": wait for a named signal. "Condition": wait until every condition is true, re-checked whenever something it reads changes. "Infinite": never release. | |||
signal_name |
str | '' |
Name of the signal to wait for, when mode is "Signal". | |||
conditions |
list | [] |
Boolean expressions that must all be true to release, when mode is "Condition". | |||
scan_interval |
float | 1.0 |
time | scan_interval_unit |
Fallback re-check interval, when mode is "Condition": used only when a condition reads something no event announces (TNOW, TS(), RAND(), a level between events). Variables, NQ/NR/MR/IDLE, NS and threshold writes wake it at once. | |
scan_interval_unit |
str | 'base' |
Unit of scan_interval: "base" (the model's) or one of its quantity's units. |
Statistics¶
Every run fills system and entity_summary (see the KPI reference). The example below also fills:
| Frame | Columns |
|---|---|
store_summary |
Run, Store, Capacity, Average Size, Max Size, Mode Size, Mode Size %, P95 Size, P99 Size, Std Size, Avg Time in Store, Mode Time in Store, Mode Time in Store %, P95 Time in Store, P99 Time in Store, Std Time in Store, Util % (time-weighted) |
material_flow_summary |
Run, From, To, Entities |
Problem codes¶
No check names this block type.
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=100)
m.create("Parts", distribution=nb.Constant(value=1), max_arrivals=10) >> m.hold(signal_name="Open") >> m.dispose()
m.create("Gate", distribution=nb.Constant(value=1), max_arrivals=1, start_time=30) >> m.signal(signal_name="Open") >> m.dispose()
results = m.run(seed=1)
print(int(results.kpi("system/Total Entities Completed")), "entities completed: the 10 held parts and the one that sent the signal")
print(round(results.kpi("store/hold_1_hold/Average Size"), 2), "parts held on average")
11 entities completed: the 10 held parts and the one that sent the signal
8.5 parts held on average
Used in¶
Bundled models: (s, S) inventory with backorders, Two-echelon supply chain (library assets), HOLD on a store's contents, Delay, seize/release and signal HOLD.
Guides: Digital twin, Coming from SimPy, Resources, sets and queue disciplines, Coming from AnyLogic, Coming from salabim, Continuous quantities: levels, flows and time-series inputs and 4 more.
See also¶
- All blocks, KPI reference, Model file keys, Model file format
- Same family (control): DECIDE, LOGIC, ROUTE, SEND, SIGNAL