Skip to content

Teaching

9 of the bundled models. The numbers are from a run made when this page was generated: see how.

Chance-based branching (DECIDE)

A CREATE feeding a DECIDE that splits arrivals 30/70 between a fast and a slow DELAY path -- the minimal example of chance-based branching.

naga run decide_routing
flowchart LR
    b0["create_1 (CREATE)"]
    b1["decide_1 (DECIDE)"]
    b2["delay_fast (DELAY)"]
    b3["delay_slow (DELAY)"]
    b4["dispose_1 (DISPOSE)"]
    b0 --> b1
    b1 --> b2
    b1 --> b3
    b2 --> b4
    b3 --> b4

3 replications, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 505 40
system/Avg Throughput Time 2.16 0.051

HOLD on a store's contents

Trucks wait in a HOLD until two cases are staged at a packer. Cases arrive four at a time and are packed in threes, so the staged count rises and falls within one instant: the HOLD reads NS("pack") and is re-evaluated when the store changes, not on a timer.

naga run hold_on_store
flowchart LR
    b0["cases_in (CREATE)"]
    b1["pack (BATCH)"]
    b2["packs_out (DISPOSE)"]
    b3["trucks_in (CREATE)"]
    b4["wait_for_cases (HOLD)"]
    b5["trucks_out (DISPOSE)"]
    b0 --> b1
    b1 --> b2
    b3 --> b4
    b4 --> b5

2 replications, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 29 0
system/Avg Throughput Time 3.34 0

Delay, seize/release and signal HOLD

Three independent flows in one model: a plain delay chain, a SEIZE/RELEASE pair, and a HOLD gated by a SIGNAL -- demonstrates resource seizing and signal-based synchronization side by side.

naga run hold_signal_flow
flowchart LR
    b0["create_1 (CREATE)"]
    b1["delay_1 (DELAY)"]
    b2["dispose_1 (DISPOSE)"]
    b3["create_2 (CREATE)"]
    b4["seize_1 (SEIZE)"]
    b5["release_1 (RELEASE)"]
    b6["dispose_2 (DISPOSE)"]
    b7["decide_1 (DECIDE)"]
    b8["hold_2 (HOLD)"]
    b9["create_3 (CREATE)"]
    b10["signal_1 (SIGNAL)"]
    b11["dispose_3 (DISPOSE)"]
    b3 --> b4
    b4 --> b5
    b0 --> b1
    b5 --> b7
    b7 --> b2
    b7 --> b6
    b1 --> b8
    b8 --> b7
    b9 --> b10
    b10 --> b11

2 replications, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 30 0
system/Avg Throughput Time 1.72 0.6
system/Avg Queue Length 0.656 0.052
system/Avg Resource Usage % 51.2 69

Policy-routed parallel servers

Arrivals routed by a Policy-mode DECIDE ('routing') between a fast and a slow single server; observation is each server's queue length and in-service flag. With no controller attached it falls back to always routing to ServerA (fallback 'first'), so the model runs headless with no RL involved.

naga run parallel_routing_policy
flowchart LR
    b0["create_1 (CREATE)"]
    b1["decide_route (DECIDE)"]
    b2["process_a (PROCESS)"]
    b3["process_b (PROCESS)"]
    b4["dispose_1 (DISPOSE)"]
    b0 --> b1
    b1 --> b2
    b1 --> b3
    b2 --> b4
    b3 --> b4

1 replication, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 2,980
system/Avg Throughput Time 1.89
system/Avg Queue Length 2.09
system/Avg Resource Usage % 73.8

Single server (M/M/1)

The classic M/M/1 queue: a single Server processes arriving customers one at a time -- the baseline example for utilization and waiting-time KPIs.

naga run single_server --replications 3
flowchart LR
    b0["create_1 (CREATE)"]
    b1["process_1 (PROCESS)"]
    b2["dispose_1 (DISPOSE)"]
    b0 --> b1
    b1 --> b2

3 replications, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 882 31
system/Avg Throughput Time 3.2 1.2
system/Avg Queue Length 2.39 1.2
system/Avg Resource Usage % 76.5 6.3

Single server, general service times (M/G/1)

The single-server queue with Poisson arrivals (one a minute) and a service time that is not exponential: uniform between 0.2 and 1.4 minutes, mean 0.8. The server is as busy as in an M/M/1 queue of the same load (80%), but the queue is shorter, because the service time varies less. Read the Server's average queue length: the Pollaczek-Khinchine formula gives lambda^2 E[S^2] / (2 (1 - rho)) = 0.76 / 0.4 = 1.9.

naga run single_server_general --replications 3
flowchart LR
    b0["create_1 (CREATE)"]
    b1["process_1 (PROCESS)"]
    b2["dispose_1 (DISPOSE)"]
    b0 --> b1
    b1 --> b2

3 replications, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 5,010 170
system/Avg Throughput Time 2.77 0.11
system/Avg Queue Length 1.97 0.049
system/Avg Resource Usage % 80.6 2.8

Process time lookup table

Process time by product and station, read from a 2-D lookup table. Deterministic on purpose: one WIDGET and one GADGET (entity types are upper-cased by the engine, so the table's keys are too), far enough apart that neither ever queues, so every KPI is exact by hand.

naga run table_process_times
flowchart LR
    b0["widget_arrives (CREATE)"]
    b1["gadget_arrives (CREATE)"]
    b2["cut (PROCESS)"]
    b3["pack (PROCESS)"]
    b4["leave (DISPOSE)"]
    b0 --> b2
    b1 --> b2
    b2 --> b3
    b3 --> b4

1 replication, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 2
system/Avg Throughput Time 7.5
system/Avg Queue Length 0
system/Avg Resource Usage % 6.82

Tank: fill, overflow and run dry

A tank of 100 litres that starts with 20, a pump that delivers 6 litres a minute for 40 minutes and then stops, and a constant demand of 2 litres a minute. Nothing is random and no time step is involved: the level moves in straight lines and the engine computes the instants it reaches a bound. Read the Tank's row: it is full from minute 20 to 40 (80 litres spilled), empty from minute 90 (20 litres of demand unmet), and holds 57 litres on average over the 100 minutes.

naga run tank_fill_and_drain

1 replication, seed 0:

KPI Mean 95% half-width
level/Tank/Average 57

Two tellers (resource set)

Customers served by either of two named tellers (TellerA/TellerB) through one PROCESS block -- the minimal example of a resource set with a selection rule.

naga run two_teller_set --replications 3
flowchart LR
    b0["create_1 (CREATE)"]
    b1["process_1 (PROCESS)"]
    b2["dispose_1 (DISPOSE)"]
    b0 --> b1
    b1 --> b2

3 replications, seed 0:

KPI Mean 95% half-width
system/Total Entities Completed 2,660 69
system/Avg Throughput Time 2.16 0.38
system/Avg Queue Length 1.72 0.56
system/Avg Resource Usage % 73.5 2.4