Data Structures · Queues · Peirce Lines

Peirce dining hall line simulator

Students arrive at random over the lunch hour and join one of the food lines. Each line is a std::queue: students join at the back, and the student at the front is served for a few seconds and then leaves. This page runs the same one-second loop as PeirceSimulation.cpp, plus the three activity extensions: named food lines, random service times, and line switching.

Scenario

Food type STEP 1Popularity Min service (s) STEP 2Max service (s)Load
Load is how busy a line's server is: arrivals per second × average service time. Above 1.00, students arrive faster than they can be served, so the queue keeps growing.
0:00

The lines right now

Waiting student (front of the queue is on the left) Student who switched lines Station box: the student being served and the seconds left. As in the C++, the next student starts one second after the last one leaves.

Students in each line over time

Program output


    

Statistics

LineArrivedServedAvg waitLongestStill in line

As in the C++ program, the average wait counts only students who were served, from joining the line to reaching the front. Students still in line at the end are not included, so a line that is falling behind looks better than it is.