To what extent can queueing theory and behavioral
simulations be used to reduce perceived crowding in
school cafeteria environments?
Alan Yu
April 28, 2025
Abstract
1. Introduction
In my own experience, I often had to
spend over fifteen minutes in line, only to wait
for food. This personal frustration led me to
question whether these delays were simply
due to high demand or rooted in deeper
systemic inefficiencies. Long queue times and
overcrowding in school cafeterias are known
to be serious problems facing students. This
issue has been well documented in previous
studies that have emphasized the impact of
poorly designed cafeterias on student
satisfaction, waiting times, and the overall
dining experience. Surveys conducted at our
school have shown that many students are
dissatisfied with the current cafeteria setup,
citing overcrowding and long wait times as
major annoyances. However, no one has fully
explored why these issues persist after years
of improvement or how specific factors - such
as cafeteria layout, queuing systems, and
crowding during peak hours - contribute to the
problem. If we can identify the root causes of
inefficient cafeteria operations, we can not
only improve the dining experience, but also
optimize space usage and human resources.
This study aims to investigate the root causes
of cafeteria crowding by analyzing queue
dynamics, conducting simulations, and
exploring potential improvements. By
identifying and addressing these issues, I hope
to reduce waiting times, increase student
satisfaction, and improve overall operational
efficiency. Even now, many students joke that
1eating lunch is a ’survival game’, reflecting
how ingrained this problem has become in
daily school life.
First, we break down the students’
’dissatisfaction’ into two main areas. Firstly,
the long waiting time consumes their patience,
which is totally unnecessary. Second, the
crowded cafeteria makes it difficult for them
to move around. In this paper, we will analyze
these two problems separately and look for
potential solutions. To understand the
mechanisms behind these inefficiencies, it is
essential to examine existing theoretical
frameworks and studies related to queueing
behavior and cafeteria management. One of
the most widely used approaches in this area is
queuing theory, which provides mathematical
tools to analyze waiting lines and service
dynamics.
2. Literature Review
Queuing theory, a subfield of
operations research, focuses on analyzing and
optimizing systems where entities wait in line
for service. The foundational models—such
as M/M/1, M/M/c, and M/D/1—have been
widely adopted to understand arrival patterns,
service rates, and queue dynamics under
probabilistic assumptions (Kambli et al. 64).
2
These models are defined by Kendall’s
notation, where ’M’ refers to Markovian
(Poisson) arrival and/or service times, and the
number indicates the quantity of parallel
servers (Ajiboye and Saminu 304). Little’s
Law, a fundamental result in queueing theory,
relates average wait time to arrival rate and
system capacity (Tang et al. 30).
In the context of campus cafeterias,
queueing theory has been extensively
employed to address issues of student
congestion during lunch hours, which are
particularly pronounced due to synchronized
class schedules (Zuo 183). The application of
models such as M/M/n/m has shown practical
potential in optimizing the number of open
windows and reducing average waiting time
by reallocating resources during peak demand
(Chen and Wang 42). Simulation studies
demonstrate that queue optimization can
reduce waiting times by nearly 45% (Ye 76).
Another study using a multi-stage queue
model reduced average customer dwell time
from over 500 minutes to under 15 minutes by
redesigning queue architecture and service
logic (Ajiboye and Saminu 309).
Despite these successes, classical
queueing models exhibit limitations when
applied to real-world cafeteria environments.Most models assume steady-state behavior,
homogenous service stations, and
exponentially distributed arrival and service
times, which rarely match the fluctuating and
clustered nature of student behavior (Lu et al.
202). Furthermore, traditional models fail to
account for human behavioral dynamics, such
as balking, reneging, or jockeying—where
students leave or switch queues due to
perceived delays (Chen and Wang 44).
Extensions to these models have attempted to
incorporate dynamic arrival rates and
customer patience thresholds (Li and Saminu
893). Moreover, complex queue networks
involving multiple food stations and checkout
counters require simulation or agent-based
modeling, as closed-form analytical solutions
are infeasible (Kambli et al. 65; Deng et al.
62).
Therefore, while queueing theory
provides a strong theoretical framework for
diagnosing and improving campus cafeteria
service systems, its practical application
necessitates integration with behavioral
insights, discrete-event simulation, and
data-driven modeling tools to adapt to modern
high school or university environments.
Future research should also focus on
combining real-time data collection
3
technologies with adaptive queue control
algorithms to ensure continuous optimization
and student satisfaction.
This methodology was selected
because it enables the formulation of a
structured, quantitative framework to address
crowding issues through measurable
parameters such as arrival rate, service rate,
and wait time. Unlike anecdotal or
observational methods, queueing theory
allows for reproducible simulation and
modeling, which can be validated and
iteratively refined. Additionally, it provides a
scalable structure to simulate various design
interventions—such as staggered schedules or
reallocation of service counters—without
disrupting actual cafeteria operations. Given
the dynamic and high-density nature of
student lunch periods, this approach offers a
pragmatic balance between analytical rigor
and real-world applicability.
2.1. Research Gap
经典的排队论模型是一个静态模型,
只能够模拟一些变量不随时间变化的情景。
而对于动态的变量,比如随着时间变化的
到达率,还没有一个合适的理论模型来描
述。本研究尝试将午餐时段分为无数个时
间段,分别对它们应用静态排队论模型,Figure 1: Layout of school cafeteria
以此来得到变化的输出。
3. Data Collection
3.1. Observation
The data for this study came from field
observations in our school’s cafeteria, and data
were collected from December 2 to December
5, 2024, and December 9 to December 12,
2024 (8 days in total). Data collection under
each schedule lasted for four days due to the
school’s schedule of one cycle every two days.
The data primarily covered the third and
fourth periods which are lunch periods, and
the peak hours. Specifically, it includes the
number of students entering/leaving the
cafeteria during each period, the service time
of each window, and the number of windows.
Data collection was performed through
4
the cafeteria’s monitoring system during the
daytime hours, which recorded the timestamp
of each student’s entry into the cafeteria. The
specific time period for data collection was
from 11:50 to 13:35 each day. During this
time period, the number of students entering
the cafeteria was recorded by manual count,
and the service time of each service window
was recorded by simple observations. The
mean value of the window service time is the
average value obtained by several manual
timings.
3.2. Data pre-processing
During the data cleaning process, all
the collected data met the preset criteria, so no
data was eliminated. During the data
preprocessing stage, timestamps were
converted to relative times with respect to
peak hours and grouped for counting at
2-minute intervals during peak hours. For
off-peak hours, group counts were performed
at 5-minute intervals.
Total Population
We get the average Entries and Exits
(Et and Lt) by simply adding them together
and divided by the number of days. Notice
that our school’s cafeteria has 2 entrances5
Figure 2: Average Enter vs Leave Counts
Figure 3: Average Net Population
(marked as A and B here).
So for each time interval t,
and then the numbers drop off over time.
EnterTotal =
8
i=1 Enter ADayi
8
8
i=1 Enter BDayi
Data Processing
8
It is the same way to calculate
LeaveTotal.
Once the data collection was complete
we next used the data to calculate the student
arrival rate, which is a variable that changes
over time during every lunch time.
3.3. Data characterization
Number of Service Seekers Arriving During
Interval t (St)
According to Figure 2, the results of
the data analysis showed that the arrival time
of students to the cafeteria showed obvious
peak characteristics, especially between 11:50
and 12:10 (0 min - 20 min), when an average
of about 20 people entered the cafeteria per
minute, while the number of arrivals
decreased significantly at other times.
We can also graph the net population
in the cafeteria. According to Figure 3,
similarly, there are particularly large numbers
Then we consider the following
factors. We know that not all of the students
who enter the cafeteria will have any food,
and that some may only stay for a short time
before leaving (e.g., using the cafeteria as a
hallway just to walk through it). In addition to
this, since our school has an outdoor dining
area. It has the same capacity as an indoor
cafeteria. Some people order their lunch and
go straightly to the outdoor dining area, while
of students at the starts of the 2 launch periods,
others stay indoors to eat their lunch. We will6
Symbol Description Unit
Et Total number of individuals entering the location dur-
ing interval t
Count
Lt Total number of individuals leaving the location dur-
ing interval t
Count
p(t) Probability that an entering individual seeks service Fraction
r Probability that a service seeker stays after service Fraction
St Number of individuals arriving for service during in-
terval t
Count
λ(t) Average arrival rate of customers during interval t People/s
Table 1: Definitions of variables used in the crowd flow model.
mainly focus on those students who stay
indoors.
Arrival rate estimation
在这里我们假设最简单的“理想人”
流转路径,根据Figure 4,故我们假设只有
两种情况:
According to Table 1, we have a
fraction p of entrants seek service, where the
others leave immediately. After services,
some service seekers leave immediately as
well, and some stay after service. The fraction
r of service seekers stay in the area. However,
r does not vary roughly with the time in a day
because people will always look for
uncrowded locations. In this case we suggests
that they prefer to stay indoors when it is
crowded outdoors, and they prefer to go
outside when it is crowded indoors. But it has
been observed that it increases significantly
during the cold season, when people are
reluctant to have lunch outdoors where it is
colder. So in winter it usually gets more
crowded indoors.
- 进门后,不买饭的部分(占比1− p(t))
立即离开(几乎忽略在场时间);
- 进门后,去买饭的部分(占比
p(t) × r),在食堂会停留一段时间再离
开;这段时间包含了服务时间T ,以
及在堂食区停留时间D 。若有比例r
会堂食,则总“滞留”时间写为
τnet ≈ T + rD. (1)7
Lt ≈ 1− p(t) × Et
当下进门马上离开
- r × p(t− τ1) × Et−τ1
先前时刻吃完饭的那批人, 现在离开
- (1− r) × St−τ2
先前时刻买饭的那批人, 现在离开
. (2)
可以把p(t− τ1) ≈ p(t)。这样就得到:
L(t) ≈ 1−p(t) Et + p(t) Et−τ1 + r St−τ2.
将这条式子整理一下, 并将St−τ2 替换为
p(t)Et−τ2 :
Lt = Et− p(t)Et + p(t)Et−τ1 + r p(t)Et−τ2
= Et + p(t) Et−τ1− Et + r Et−τ2.
因此,可以粗略地解出
Lt− Et
Figure 4: Enter Caption
p(t) ≈
. (3)
Et−τ1− Et + rEt−τ2
再次根据等式(1) 的近似,我们将τ1 和τ2
合并为τnet
由于我们只有外部数据(某时间段t
的进入速率Et 与离开速率Lt),无法获得
某个时间段想要服务的人数。因此我们设
立若干种情况——买饭且在食堂食用的那
部分人,约在τ1 秒后离开;买饭且准备离
开的那部分人,约在τ2 秒之后才出现在离
开队伍里;而不买饭的那部分人几乎瞬时
进、瞬时出。由此可以写出一个“带延迟
的简化守恒”关系式(2)。
但在实际情况下,p(t) 变化不那么
快。在先前的观测中,随着时间的推移,
穿过食堂的人数比例只会略微下降。于是
Lt− Et
p(t) ≈
. (4)
Et−τnet− Et
我们根据p(t) = St
Et 得到
St
Lt− Et
Et
≈
Et−τnet− Et
.
根据研究所示,高中生平均用餐时间为20
分钟,所以我们计算
τnet ≈ 20r + T.
对于r 我们直接使用室内外座椅数量估计。人们总是会前往座位空闲的地方,
r =
Nindoor
Noutdoor + Nindoor
≈
47
59 + 47
最后我们将S 除以t 得出顾客到达率
St
¯
λt =
≈ 0.443.
.
tperiod
Figure 5: Arrival rate (λ) Standard Deviation
(σ)
得出的数据如Figure 5 所示。我们
首先使用多天平均的数据E 和L 计算出平
均顾客到达率λaverage。在此之后我们分别
计算每一天的数据的λ ,并且将其与
λaverage 做差,得出标准差σ。
σt =
n− 1
n
i=1
λt,i−
¯
λt
2
对于这类数据我们将它近似为正态分布,
也就是
1
Xt ∼ N (λ(t), σ(t)), ∀t ∈ [0, 6300].
8
3.4. 平滑样条函数拟合(Smoothing Spline
Fitting)
为构建一个时间连续变化的平均到
达间隔时间函数µ(t) 以及其标准差函数
σ(t),本文采用了平滑样条拟合
(Smoothing Spline Fitting)方法。该方法基
于一组离散时间点{ti}n
i=1 与对应的观测值
{yi}n
i=1,通过在最小化数据残差的同时控
制函数弯曲程度,从而拟合出一个光滑连
续的函数f (t)。其数学表达为以下优化问
题:
min
f ∈C2
n
i=1
(yi− f (ti))2 + λ
b
a
(f′′(t))2 dt .
其中:
• yi 表示第i 个时间段中计算得到的目
标值;
• f (t) 是待拟合的连续函数;
• λ 是平滑因子(smoothing factor),控
制拟合精度与平滑程度之间的权衡,
当λ = 0 时,拟合函数严格通过所有
点(即插值);当λ → ∞ 时,拟合函
数趋于线性;
本研究中,我们使用python 中的
UnivariateSpline 方法对µ(t) 和σ(t) 进
行拟合。该函数基于三次样条(cubic
spline)构建,并自动进行节点选择与最优Table 2: Service Time Data
Variable Value
Sample size 100
mean 32.378
std 20.478926
λ 0.030885
D 0.3510
Pval 0.1045
拟合。
µ(t) ≈
n
i=0
ciBi(t).
最终得到的函数f (t) 可在任意时间点t 上
进行评估,生成连续的时间-间隔函数µ(t)
及标准差函数σ(t),用于描述G(t)/M /c 模
型中顾客的动态到达分布。将离散变量拟
合成连续变量可以更好地拟合随时间变化
的到达率,提高对于动态排队过程的预测
精度。
4. Service Time Data
对于服务率数据,我们调取服务窗
口旁的监控并且记录了100 条服务时常数
据,见Figure 6。
Figure 6: Service Time (1/λ)
9
我们使用K-S (Kolmogorov-Smirnov)
检验来检测此数据是否能够近似为某个分
布。我们首先检测指数分布。K-S 检验表
明,对100 个观测服务时间进行指数分布
拟合,平均服务率为λ ≈ 0.030885(即平均
每32.378 秒服务一人)。根据Table 2, K-S
检验得到p 值为0.1045,大于显著性水平
α,说明无法拒绝服务时间服从指数分布的
原假设,因此可以合理建模为G/M /c 排队
模型。
5. Model Establishment
基于前文对数据的检验,我们认为
到达率符合正态分布且服务率符合指数分
布(即服务过程是无记忆性的)。故选用
G(t)/M /c 进行描述.
5.1. 基本参数
根据Table 3, 其中系统稳定系数
ρ(t) = λ(t)
cµ
, ρ < 1 (系统稳定条件). (5)
到达时间分布的变异系数Ca(t)
Ca(t) = σa(t)
1/λ(t), (6)
其中σa 为前文计算的到达率的标准差。我
们使用Ca(到达时间的变异系数)来修正
M /M /c 公式,即可得到G/M /c 的结果。10
5.2. 模型计算
使用Pollaczek-Khinchin (P-K) 公式
的推广形式,可得队列平均等待时间
Wq =
C2
a + 1
2· Wq,M /M /c, (7)
系统空闲概率P0:
P0 =
c−1
k=0
(λ/µ)k
k! + (λ/µ)c
c!·
−1
1
1− ρ
.
(11)
最后得出系统平均等待时间W 、系统平均
人数L
λ
W= Wq +
. (12)
µ
1
, L= Lq +
µ
我们将这些输出变量绘制成图像
其中Wq,M /M /c 是M /M /c 模型下的平均等
待时间:
Wq,M /M /c =
Lq,M /M /c
λ . (8)
平均队列人数Lq :
Lq =
C2
a + 1
2· Lq,M /M /c. (9)
Figure 7: System Stability During Peak Hour
而Lq,M /M /c(平均排队人数)可以由
Erlang-C 公式给出:
5.3. 模型输出
P0·
(λ/µ)c
c!· cρ
Lq,M /M /c =
(1−ρ)2
c−1
(λ/µ)k
k=0
k! + (λ/µ)c
c!·
可以发现,在高峰时间段(前5 分
.
钟),学生到达率超过了服务率,也就导致
1
1−ρ
(10)
了服务永远不可能完成。这种情况下系统
Table 3: Variables in the model
Symbol Explanation Unit
λ(t) Average arrival rate of customers people/s
µ Average service rate of a single service window services/s
c Number of service windows Number
ρ(t) System utilization rate /
Ca(t) Coefficient of variation /
Wq (t) Mean waiting time s
Lq (t) Average number of people in the queue Number
P0(t) Probability that the system is empty /Figure 8: Model Result (W and L)
是混乱的,并且在这些瞬间的等待人数、
等待时间会无限增长,没有稳定状态。
从上文的公式中我们了解到系统稳
定的条件是
λ
< 1, 或 λ < cµ.
cµ
所以在本研究收集到的数据中,想要让系
统保持稳定,到达率需要控制在以下区间
内
λ < 3 × 0.030885 ⇒ λ < 0.09.
除此之外,由于食堂区域的布局限制,窗
口最多仅能开放四个。并且服务过程中的
交流也会显著延长服务时间,导致服务率
降低。我们在此假设一个理想的服务时间,
即控制平均服务时间在25s。那么我们依然
需要控制到达率
λ < 4 × 0.04 ⇒ λ < 0.16.
因此,给出的初步解决方案如下。由于冬
11
季r 会上升,我们需要允许更多学生滞留
在食堂。于是针对不同季节,冬天需要限
制人流到0.12,夏天需要限制到0.14。如
Figure 9 所示,如果我们将人流限制在0.12
以下,其最长平均等待时间大约在50s 左
右,已经处于一个非常良好的范围了。
Figure 9: Optimized Result (W and L)
6. 优化策略与动态仿真
为缓解当前的问题,我们基于
G(t)/M /c 模型分析结果,提出如下优化策
略:
• 在0–600 秒期间,系统负载率ρ 显著
上升,超过1,服务能力过饱和。建议
增加1 个窗口,并通过培训服务员将
平均装餐时间缩短至25s,以在高峰时
段减少排队长度。
• 进行限流措施,每2 分钟放行12–14
人,时间集中在前10 分钟。
为确定限流最有效的位置,本研究使用动
态仿真模拟中午就餐过程。Figure 10: 动态模拟示意图
我们根据食堂的平面图设定各个元
素。根据Figure 10,橙色部部分为墙壁,
即行人无法通过的部分。这里椅子中间的
间距很窄,我们假设行人无法通过桌椅中
间的位置。最顶上左侧的绿色线段和底部
最左侧的绿色线段为两个出入口位置。绿
色箭头则为排队方向,绿色圆点则为窗口
位置。左侧还有一块绿色阴影为通道。随
后我们在AnyLogic 中建模,将先前计算的
到达率函数和服务率函数输入进去,并根
据比例P (t) 和r 界定一个人的行为。当一
个人进入室内位置就餐后或离开食堂则判
定结束,即删除这个个体。
12
6.1. 热力图分析(KDE)
Figure 11: 第200 秒模拟的热力图
热力图基于核密度估计(KDE)得
到,其数值并不代表绝对人数,而是单位
面积附近的人流密度。若某些区域出现超
过4 的KDE 值,说明此区域人群极度集
中,需要进一步的空间或排队管理措施。
此值还会受带宽参数影响,带宽越小对局
部拥挤越敏感。
通过Figure 11 我们可以发现人流密
集区域基本集中在靠近窗口的一部分,而
走廊的密度相对较少。因此,我们可以在
所有窗口的最左侧,也就是学生们进入窗
口排队的必经之路处,派遣一名老师或者
学生志愿者来控制人流。具体操作可以是
每2 分钟放行12 - 14 人,持续10 分钟,也
就是放行5 次。13
7. Discussion
综上所述,优化策略验证表明,增
加一条服务窗口并将平均装餐时间压缩至
25 秒,可在高峰期显著降低等待时间;配
合窗口边的限流措施(每两分钟仅放行12–
14 人),能够有效控制高峰人流突然涌入,
从而将系统负载率ρ 控制在0.8–0.9 的安全
区间内,使平均等待时间大致维持在50 秒
以内。此外,AnyLogic 动态仿真与热力图
分析进一步揭示,排队区域比通道中最容
易出现高密度聚集,针对性布置限流控制,
可有效地降低拥挤感受。
在与已有研究的异同方面,本文的
动态排队建模思路在实际应用中较为少见;
大多数研究依赖稳态模型进行优化,而本
文尝试使用动态G(t)/M /c,并结合平滑样
条函数对服务率进行非参数估计,使模型
更贴近实际。
然而,在模型设计与数据处理过程
中,仍存在一定的误差来源与局限性,值
得进一步探讨。首先,观察数据样本仅覆
盖8 天,且忽略了节假日、特殊活动等情
形的影响;其次,对学生行为的刻画较为
简化,仅考虑了“买饭”“不买饭”及室内
外偏好,未纳入换队(jockeying)、离队
(reneging)等更复杂行为。此外,研究并未
对“感知拥挤”与“实际拥挤”之间的心理
学差异进行深入探讨,这对于提升学生用
餐体验至关重要。
另外需要注意的是,基于时间变化
的排队模型容易忽视顾客在系统中的“累
积效应”,可能低估排队长度或高峰延迟。
除此之外还有其他误差来源,包括对到达
过程的近似、服务时间分布的简化,以及
人工观察记录中的偏差。特别的,即使本
研究中服务时间通过K-S 检验基本符合指
数分布,高峰时段出现的多任务或顾客犹
豫等行为可能导致实际服务过程的偏离。
未来工作或研究可在以下几方面展
开:一是扩大样本量,收集至少30 天的数
据来提升结果精度;二是结合问卷或生理
指标等方式,量化学生在不同布局与排队
策略下的“感知拥挤”水平;三是将模型
推广至多种学校类型(初中、高中、大学)
与不同规模的食堂环境,以评估其通用性。
8. Conclusion
本研究验证了排队论与行为仿真在
缓解食堂拥挤问题上的有效性,并提出一
种使用动态数据建立动态模型的思路描述
变化的场景。本研究基于多日实地数据与
G(t)/M /c 模型,定量揭示了午餐高峰期因
到达率超出服务能力而导致的系统失稳,
并通过增设窗口、缩短装餐时间及限流策
略,将平均等待时间有效降低至50 秒以
内。这为后续在实际校园环境中落地实施
提供了量化依据及技术路线。AnyLogic 动
态仿真与热力图分析进一步确定了最佳限14
流位置。尽管样本时段与行为模型尚有简
化,研究成果已为校园食堂管理者在调控
方面提供了明确的量化依据。未来可扩展
模型通用性并进一步提升人流管理水平。
同时在理论与应用层面,本研究也为其他
类似的学校食堂乃至公共服务场景提供了
一种较为可行的排队系统分析思路。