Process simulation

Queue and process simulation

Queue and process simulation

A SIMULATION describes entity flow through sources, queues, services with shared resources and sinks. The definition is inert; an explicit, seeded, bounded RUN executes it on the native discrete-event engine.

checkout = SIMULATION(cashiers)
  RESOURCE cashier CAPACITY cashiers
  SOURCE arrivals EVERY EXPONENTIAL(3min)
  QUEUE waiting FIFO
  SERVICE payment USING cashier FOR EXPONENTIAL(2min)
  SINK completed
 
  arrivals -> waiting -> payment -> completed
END
 
definition = checkout.DEFINITION()
run = checkout.RUN({cashiers: 2, seed: 42, horizon: 8h})

SIMULATION checkout(cashiers) … END is the equivalent declaration spelling. Reading or importing the definition samples nothing, creates no job and publishes nothing. Two runs with the same definition, arguments and seed produce identical results.

Stations and chains

Clause Meaning
RESOURCE name CAPACITY expression A pool of identical units; the capacity may use definition parameters
SOURCE name EVERY timing Recurring arrivals; the next interarrival is drawn when it is scheduled
QUEUE name FIFO Waiting entities in arrival order
SERVICE name USING pool FOR timing Hold one unit of the pool for the service duration
SINK name Terminate the entity and count the departure
a -> b -> c Deterministic edges between stations

Every source, queue and service has exactly one outgoing edge; a queue feeds a service and every service follows a queue; a sink has no outgoing edge. Topology problems are compile diagnostics (GRID_SIMULATION_TOPOLOGY). When several queues share a resource, a release considers every waiting queue. Eligible heads compete by enqueue time and entity ID; another arrival is not required to wake a waiting queue. This slice requires positive resource capacity.

Timing slots take a duration literal (30s, 3min, 2h) or EXPONENTIAL(mean), UNIFORM(low, high) or TRIANGULAR(low, high, mode) of duration literals. A bare number has no time dimension and is refused (GRID_SIMULATION_DURATION). Deterministic durations consume no random stream, so adding one never changes another station's draws. Internally all times are seconds; results report timeUnit: "s".

Runs and results

RUN(arguments) takes one record with seed (exact nonnegative integer), horizon (positive duration), optional warmup (duration below the horizon) and one value per definition parameter. Missing, unknown or mistyped arguments are errors (SIMULATION_ARGUMENTS). The run is bounded by an event budget and a wall-clock budget. Event-budget exhaustion yields status :limited with the processed prefix. Wall-clock timeout currently returns SIMULATION_LIMIT; retaining its prefix remains unfinished.

The result has schema grid.simulation.run.v2:

  • status (:complete or :limited), complete, reason, seed, horizon, warmup, observedBoundary, events;
  • counters with admitted, departed and unfinished entities;
  • queues.<name> with meanLength, maxLength and a wait tally;
  • resources.<name>.utilization;
  • cycleTime tally for departed entities.

Tallies carry count plus Option-valued mean, max and p95; an empty tally has count zero rather than invented statistics. Waiting and in-service entities at the horizon are unfinished observations, not failures.

DEFINITION() returns grid.simulation.definition.v1: the definition identity, parameters, stations with their timings and the edges.

Current scope

This is the first DES slice: both header spellings, inert definitions, FIFO chains, shared pools, explicit seeded runs and summary statistics. Typed entities, recorded arrivals, UPDATE, routing, finite queue capacity, patience, priority queues, multi-pool grants, calendars, reusable FLOW components, traces and experiment replication remain later slices; their keywords are refused with explicit diagnostics. See the existing simulation operations.