โ† QueueSim home  ยท  All models

Order-Point Inventory (s,S) โ€” README

Order-Point Inventory

A continuous-review inventory model simulating an (s, S) reorder policy.

Problem

A single-item inventory is managed with a continuous-review policy. Demand arrives exponentially, with each demand pulling a random quantity of units. The "inventory position" is tracked as the sum of on-hand and on-order inventory minus backorders. Whenever the position drops below a reorder point s, an order is placed to bring the position back up to a target level S. Replenishment arrives after a random lead time.

The goal is to balance the cost of holding inventory against the cost of customer backorders.

This is based on the continuous-review formulation in Law-SMA and Example 9 of the Schriber-GPSS/H textbook.

Model in this directory

The model is centered around a Shop state and utilizes a "monitor" pattern:

Why this shape

The use of sim.Notify_Var and sim.wait_until (lines 112-116) is the architectural highlight. In traditional GPSS, this was achieved with SAVEVALUE and TEST. In the puck idiom, the monitor is an autonomous agent that only wakes up when the specific state it cares about changes. This decouples the demand process from the ordering process.

The model uses a custom flush_stats procedure (lines 48-58) to perform continuous integration of the on-hand and backorder levels. This provides an exact time-weighted average without needing to sample the system at arbitrary intervals.

Alternatives considered

What this example teaches

CLI

./order_point_inventory [options]

Add --json to emit the uniform envelope (metadata, execution_stats, metrics, details) instead of the default text output.

Flag Type Default Description
--days float 365 Simulation horizon in days.
--warmup float 30 Warmup cutoff in days; stats before this are ignored.
--s int 50 Reorder point (s).
--S int 150 Order-up-to level (S).
--seed int 42 RNG seed.
--sweep bool false Run an (s, S) grid sweep instead of a single policy.
--json bool false Emit uniform JSON envelope instead of text.

With --sweep, the model ignores --s and --S and walks a grid of (s, S) combinations to help locate the cost-optimal policy.

Example runs:

./order_point_inventory                                         # default text run
./order_point_inventory --json                                  # uniform envelope
./order_point_inventory --days=90 --s=20 --S=60 --json          # custom policy, JSON
./order_point_inventory --sweep --json                          # grid sweep as JSON

Running it

odin run examples/order_point_inventory

See also