โ† QueueSim home  ยท  All models

Multi-Barber Shop โ€” README

Multi-Barber Shop

Simulates a barbershop with two barbers where customers prefer one barber over the other but will accept either.

Problem

Two barbers share a waiting room. Customers arrive with interarrival times uniform(18, 6) minutes. Each customer prefers Barber 1 but will take Barber 2 if Barber 1 is busy and Barber 2 is free. If both are busy, the customer waits in a common FIFO queue. Service time is uniform(16, 4) minutes per barber.

This is an extension of the single-barber shop, specifically designed to demonstrate "Transfer Both" semantics and shared queue management.

Model in this directory

The model implements a dual-resource system with a shared waiting area:

Why this shape

The "Transfer Both" logic is explicitly coded in the Customer.Arriving state (lines 55-65). By checking the .busy flag of each facility in a specific order before suspending, the model ensures that Barber 1 always gets priority for new arrivals.

The use of a separate sim.Set for the wait_list (instead of using the facilities' internal waiters) is critical. If customers waited in the facilities' internal queues, they would be locked to one barber. By using a shared set, any barber who becomes free can pull any customer from the head of the queue, maintaining a global FIFO discipline across the shop.

Alternatives considered

What this example teaches

Running it

odin run examples/multi_barber

CLI

./multi_barber [options]

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

Flag Type Default Description
--json bool false Emit uniform JSON envelope instead of text.

Example runs:

./multi_barber           # default text run
./multi_barber --json    # uniform envelope

See also