Trying to improve buffet lines using simulations
erikbern.com
erikbern.com
Dijkstra's algorithm is the completely wrong approach for this problem. First of all, the cost to enter any grid square is the same, so Dijkstra's priority queue is needless overhead. When all edges have the same weight Dijkstra's behaves identically to breadth-first search.
BFS is obviously a poor approach for a mostly open grid like you have here. It will explore every single open vertex whose distance is less than the distance to the goal. Imagine the person standing in the center of a circular room with the food at the edge. With DFS, the pathfinder will look at every single vertex in that room.
What you want is A-star, which is no harder to implement than Dijkstra's. Even better would be something like jump-point search that handles open spaces better. But just A-star alone will yield a massive improvement for problems like this.
1. Diagonal moves have a slightly higher weight. 2. I have an edge weight of 100 to go through another person. This makes it possible to go _towards_ the right direction even though there is no path 3. For the perpendicular lines method, the distance is modified to 1e-3 4. A* doesn't work because the heuristic becomes pretty useless when you have moves that are very "cheap": you need a lower bound that's pretty much zero
So for all those reasons, I just went with plain old Dijkstra!
I don't see where you have cheap moves. If your move costs are unit for straight lines, slightly longer for diagonal (i.e. probably close to sqrt(2)), and much longer for obstacle, then A* will work fine. The lower bound is just the usual Cartesian or Manhattan (depending on your diagonal cost) distance.
Assuming the crowd keeps moving, the problem will naturally resolve itself eventually (and the results are the same as if you'd done direct pathfinding -- a traffic jam is a traffic jam).
There's also the possibility an actor gets stuck holding the door: He's the last to move, so by the time he takes his turn, he's surrounded again; The gamey solution would be to cheat and let him phase through or temporarily merge with an actor.. alternatively increase his iteration priority if he doesn't get to move, so he gets the first move next turn.
But in the case of this simulation, such extreme crowding is an unnecessary edge-case to care about, since the goal really is to simulate to the point when crowding just starts to occur, so just "bump and undo" collision logic is probably more than sufficient.
If you want to go way too far, you end up with potential fields like [0] or [1] but I don't think a buffet line really necessitates that level of intelligent behavior
[0] http://grail.cs.washington.edu/projects/crowd-flows/continuu... [1] http://www2.cs.uregina.ca/~anima/408/Notes/Crowds/HybridVect...
While I agree that the 'default' buffet queue is inefficient, I don't agree with the proposed methodology of finding an improvement.
(also, I missed a literature study - there is so so so much research on this already)
Also, I think it is really unhelpful to quickly dismiss his analysis because you don't agree with his methods instead of showing why his proposed solutions fail when you add more realistic constraints to the simulation.
I'm not sure what you mean by this beyond what the author already implemented—people occupy space that can't overlap, several of the simulations break down because of blocking, and many of the simulations even display the routing paths that the agents are planning.
Point is, your comment on particle flows dug this reference up from somewhere deep in the back of my mind. It was a really interesting study, I'll try to find a link.
Years ago I entertained starting a business in this field - it was essentially exactly what you say, doing analysis for events as part of their risk assessment to see if event locations are safe under various patterns of (aggregate) visitor movement. At the time (15ish years ago?) that wasn't really done for anything but the largest events. The idea never really went anywhere but it's an interesting topic I still think about every now and then.
I sometimes have the same thought when traversing a particularly packed mall. Crowds appear to me to be a non-Newtonian fluid, because internal friction increases rapidly under pressure.
You don't need that much detail to model the simulation; really all you care about is that you have some distribution of arrival rates, and a distribution of processing time (to get a particular food), and some distribution of food preference, and it takes some x seconds to move to then next food. Perhaps with a food ordering as well.
The simulation could have been purely numerical with that (no need for pathing algorithms and whatnot, and avoid his day-long computations for such a simple simulation..), and the main variables to play with are:
1. Food preference
2. Food order
3. Number of instances of food stations
4. Processing time per food
But the author included pathing, and all his alternative-strategies then revolved around pathing, but really any path that isn't a simple line (or parallel lines) is probably non-viable, as they would quickly become a mess of people operating at random when they fail to understand whatever convoluted ruleset has been created unless its heavily enforced by the administration .
More likely than not, the best solutions probably would have been those that reduce processing time for high-preference food (a designated server), and increasing the number of food stations for those high-preference foods (eg split off deserts from the main food line to a new table, and add 4 locations to pick it up on that table)
It'd also address your concerns
>hence take into account that one person cannot occupy the same space as another
Modeled by the fact that its a queue, and there's only one person being processed at at time at any given station
>overhead of routing, blocking
Routing only really comes in two forms: Time to move from current station to the next one
1. and enter the queue
2. and skip the queue, and start moving to the next station
Blocking probably doesn't matter much; it's doubtful people will actually block each other off beyond the normal block of being processed, except when the buffet has overloaded and all the starving people swarm the tables, and all hell breaks loose; whatever physical blocking does occur will most likely have negligible impact on the system and if necessary, can be easily modeled in the time to switch stations
Queuing theory is very appropriate for this. It’s a queue.
Buffets are not like bank teller queues. Or maybe I should just visit different restaurants.
You're right if you wanted a really in-depth and granular model, but it's doubtful you'll find significantly improved insights versus treating it as a simple queue, and ignoring the fact that people are a little dynamic.
As far as I've seen, most buffets constitute a line with a little bit of people skipping around. But it's very close to well-ordered.
There was a long line. I asked a few people to see their tickets. All of them had entry times after mine. When my time was on the display, I asked the person in the front of the queue to see his ticket. He still had a few minutes to go. So I pointed at the time on my ticket and entered before him. He felt cheated, but as we together wondered through the museum, he agreed with my logic.
My point is that online booking systems can make many lines obsolete.
This article though touches on a more difficult problem, namely congestion.
IIRC park passes with this ability cost more, so Disney has already selected for people with expendable income.
They were chatting about the efficiency of buffet lines and one of them mentioned "It's well known that a buffet line with a server is 30% faster than a line with no server."
Made total sense at the time because in a self service line, people have to:
- stop
- pick up the utensil
- some people then take a while deciding which piece of food is the best
- grab the food
- put the utensil down and move on etc
With a food server, it goes so much quicker if only because the server isn't waiting around to pick the best piece for you.
the simplest solution is 1 entrance line and N parallel buffet rows.
My food only needs 30 seconds to microwave, but Slow Joe brought thanksgiving to work and needs to use the microwave for 4 minutes. We have 2 microwaves M1-2.
With your system this is what happens:
- Slow Joe blocks M1 with a 4 minute meal
- Several 30-60 second users cycle through M2
- Another Slow Joe blocks M2
- The queue grows until M1 is free
- The feedback loop gets worse the next iteration
Basically, you need a dedicated "express lane" for quick people to use. If there are no quick people in the queue, then a slow joe can use it. Otherwise you need to increase N such that there is always at least one unblocked lane, which might not be viable.
1. Ordering of the food does not matter in the classical method (you always have a bottleneck at the most popular option), whereas in practice some buffet options will be more popular than others, and spreading them out will help in the rogue and don't go backwards models. 2. In the classical model you have to wait for each food, so you might as well take everything (or at least more options), in the other options there is a market-based mechanism to discourage people to get the more popular option (because they would have to spend more time queueing), that could help spread people more evenly across the buffet.
Consider: Imagine every parallel queue, but with a "gap" every 3 people to allow others to pass by. In real life, humans wouldn't walk all the way around the queue, they'd find someone who would step momentarily aside to let them pass. Representing this by forcing the individual queues to not be fully solid would allow that behavior to be represented.
Anyway, this work doesn't even get to some of the more interesting aspects of buffet design, like handling multiple tables, popular items, correlated items, etc.
IIRC queueing theory suggests that a single line feeding into two sides of multiple buffet tables would work reasonably well.
In practice this also seems to work well, although head of line blocking can occur on each table side.
I'm often disappointed at computing or networking conferences or meetings of some sort where the buffet is strictly serialized with head-of-line blocking, resulting in massive, slow queues that waste most of the lunch break time.
It's especially bad on large cruise ships where the average age of the clientele is probably 90 years old.