Skip to content

How do I turn one order into several jobs?

One customer order is often several tasks, such as three dishes. DUPLICATE sends copies on from the same block. The script turns each order into three kitchen jobs.

from nagasim import build as nb

# One customer order is three dishes. DUPLICATE with number_of_duplicates=3 sends three entities on
# (the original and two copies), so the kitchen sees 3 jobs per order. Orders come every 6 minutes
# and a dish takes 1.5 minutes on average: 3 x 1.5 / 6 = 75% busy.
m = nb.Model(time_limit=2000, warmup=0)
m.add_resource(name="Kitchen")
orders = m.create(distribution=nb.Exponential(rate=1 / 6))
dishes = m.duplicate(number_of_duplicates=3)
orders >> dishes >> m.process(resource_name="Kitchen", distribution=nb.Exponential(rate=1 / 1.5)) >> m.dispose()

results = m.run(replications=5, seed=1)
print(f"kitchen busy {results.kpi('resource/Kitchen/Usage % (snapshot)'):.0f}%")
print(f"jobs per order: {results.kpi('system/Total Entities Completed') / (2000 / 6):.1f}")

Save it as recipe-order-copies.py and run it with python. The script seeds itself, so the numbers below are the same on your machine.

kitchen busy 76%
jobs per order: 3.0

How it works

  1. m.duplicate(number_of_duplicates=3) sends three entities on, the original and two copies, all along the same link.
  2. Three 1.5-minute jobs per order every 6 minutes load the kitchen to 75%, and the run shows about 76%.
  3. Each copy is a full entity, so it is counted, queued and timed on its own.

Elements used

Back to all recipes.