sim_restaurant/
lib.rs

1// Copyright (c) 2026 Graphcore Ltd. All rights reserved.
2
3//! Simulate a fast food restaurant.
4//!
5//! This is an example of how GWR can be used to simulate time-based,
6//! event-driven systems. In this case, we choose to simulate a fast-
7//! food restaurant with some tills and a kitchen in order understand
8//! what might produce the most profitable staffing balance.
9//!
10//! This example simulates customers that arrive throughout the day. They decide
11//! whether to join the queue, place orders and then wait, collect their food
12//! and leave. It tracks costs vs income in order to understand the impact of
13//! the staffing decisions on profitability.
14//!
15//! # Overview
16//!
17//! The code is structured into a library that models a restaurant and two
18//! applications that use the library.
19//!
20//! The main files in the restaurant model are:
21//!
22//! - `src/lib/customer.rs` generates demand and tracks customer lifecycles.
23//! - `src/lib/staff.rs` models till and kitchen workers as concurrent async
24//!   processes.
25//! - `src/lib/menu.rs` defines order templates, preparation time, and
26//!   economics.
27//!
28//! The two applications using the library are:
29//!
30//! 1. The `sim-restaurant` is a command-line application that runs a sweep of
31//!    staffing configurations in order to determine the most profitable.
32//! 2. The `sim-restaurant-tui` allows the user to explore a single staffing
33//!    configuration in more detail.
34//!
35//! # sim-restaurant
36//!
37//! The following command runs the restaurant simulation in order to sweep for
38//! the most profitable staffing configuration. Running with the
39//! `--help` argument will give full list of available configuration parameters.
40//!
41//! ```text
42//! cargo run --bin sim-restaurant --release -- --max-till-staff 4 --max-kitchen-staff 5
43//! ```
44//!
45//! # sim-restaurant-tui
46//!
47//! `sim-restaurant-tui` is useful when you want to explore a single staffing
48//! configuration. For example:
49//!
50//! ```text
51//! cargo run --bin sim-restaurant-tui --release -- --till-staff 2 --kitchen-staff 3
52//! ```
53//!
54//! This replays one scenario letting you plot and dynamically explore:
55//!
56//! - Till and kitchen queue lengths.
57//! - Busy till and kitchen workers.
58//! - Profit vs costs.
59//!
60//! The controls are all detailed in the TUI window itself.
61
62pub mod config;
63mod customer;
64mod menu;
65pub mod recording;
66pub mod sim;
67mod staff;
68pub mod time_of_day;
69pub mod tui;
70
71pub use staff::Staffing;