Discrete Event Modeling: Express Lanes
The Situation
Suppose you're the manager of a small grocery store. You have four
checkout clerks. The question is whether to institute an express lane (10
items or fewer).
The pros:
- People with just a few items will be able to check out quicker, making
them happy.
The cons:
- You have to take a checker off the regular lanes, slowing those people
down.
- You may end up wasting the time of the express-lane checker, if there
aren't enough people using the express lane.
A reasonable way to make this decision is to use simulation to compare
the two scenarios, and use whichever one has the lower mean waiting time
(or should it be median?).
How do People Arrive and Leave?
A crucial question in building this model is the arrival rate of
customers. Note that we care about how they arrive at the checkout lanes;
we don't care at what rate they enter the store. You could look at
records in your store, possibly looking at register tapes,
How Many Items Do People Buy?
Another crucial question in building this model is how many items
people buy. What kind of source of random numbers shall we use?
Gaussian? Do we even use a single source?
How do we determine what distribution to use? We could:
- Look at register receipts for a week and count the number of items
each person bought. Then sample from that set of numbers.
- Look at the register receipts and see what theoretical distribution
looks most like it and sample from that.
- Guess.
For now, we'll guess that it's a Poisson with mean of 15, but this
is just a wild guess. It has no basis in reality at all.
Q: What assumptions would you make in determining this? What
distribution or set of distributions would you use? Why? There is no
right or wrong answer here; just issues worth considering and discussing.
Examining the Model
For now, we'll explore a model that I built. After this, we'll run it
and look at the data, and last, we'll see how it was built. Let's start
with what it means.
grocery.mox
Open the model and poke around a little. Consider the following
- Notice that we have an executive block in the upper left. We always
have to have one of those in every discrete-event simulation and it must
be to the left of every block.
- Look in the light yellow area. See how the entities (customers with
loaded carts) arrive. In this model we will call them "jobs." What is the
distribution of their interarrival times?
- Find the "Set A" block. Notice that each entity has an attribute
called "num items." How does this attribute get its value?
- Find where we compare the "num items" attribute to 10. How do we do
this? Why do we do this? What is the comparision used for?
- Notice the difference between double-lines, that entities flow along,
and single lines, which are just numbers. In Extend, entities have to be
created, move through the system, and properly exit. They can't just
disappear.
- Entities can be routed, though. What is the block that routes a job
to either the express lane or the regular lanes?
- Notice that the express lane (light green area) uses a queue block.
You have to use a queue any time the entity can't just flow smoothly
along. In this case, it's because the customer might have to wait before
getting checked out.
- Again we retrieve the number of items and feed it into an equation
block to compute the service time for this customer. What is that
equation? Does it seem plausible to you?
- The job then moves to a "delay" block, which is where the actual
checkout happens, and then to an exit block, where it leaves the store.
- Look at the regular lanes, modeled in the light blue area. How many
regular lanes does this model have?
- Notice that we only have one queue for the regular lanes. Is this how
most grocery stores work? What (other) kind store works this way? In an
upcoming class, we'll see how to choose the shortest queue.
- Check the simulation parameters. How long are we simulating for? Does
that seem like a reasonable length of time?
- There are three plotters. What do each of them show?
Running the Simulation
Run the simulation. None of the plotter blocks will automatically
open. Let's examine them one at a time:
- Open the histogram block. What is this telling us? Does it seem like
what you'd expect?
- Open the "Plotter, Discrete Event" block that is in the yellow area.
Notice that, since this is a discrete event simulation, we can't use
"Plotter I/O," we have to use "Plotter, Discrete Event" instead. But
they're essentially equivalent.
- There are two lines. The blue line looks like a cityscape and is plotted
against the left Y axis; the red line is just 0/1 and is plotted against
the right Y axis.
- The blue line shows the number of items someone has. The red line is
1 if the number is less than or equal to 10 and 0 otherwise. That's
because the red line is the output of the decision block, comparing the
number of items to 10 (the max for the express lane).
- Look at the graph, and see if you can confirm that the red line goes
to 1 just when the blue line is below 10. (This may be hard to see.)
- If the blue line stays above 10 for some time interval, even though it
bounces up and down, the red line stays at zero. Therefore, there are
fewer changes in the red line than the blue one.
- Now look at the table of data. The "Time" columns (there are four,
one for each input) gives the time at which a change in that input occurs.
The attribute column gives the exact value of the "num items" attribute,
which is the first input. The "Y" column gives the value of Y (either 1
or 0), which is the second input. (The existence of "Time" columns is one
of the differences between "Plotter I/O" and "Plotter, Discrete Event.")
- Scroll down and notice that there are fewer entries in the red
columns. This corresponds to our earlier observation about the fewer
changes in value.
- Match up one of the transitions in the Y value with the corresponding
attribute. Use the Time value to find the corresponding attribute. See
if you can confirm that Y=1 when Attribute ≤ 10. Note that you can't
just read across a line! You have to match up timestamps. (I make this
mistake all the time.)
- Open the "queue lengths" DE plotter block that lies between the two
sets of checkout lanes. This gets two inputs, the blue one is the queue
length of the express lane queue and the red one is the length of the
regular lanes. Does this plot make sense to you?
- Now open "total exits" DE plotter block that lies between the two sets
of checkout lanes. This plots the number of entities that exited each
exit block, so this is the number of customers finished by each kind of
lane. Clearly, the regular lanes serve more customers. Do they serve
three times as many? Is that what we want or expect?
- Open the queue blocks and click on the "Results" tab. One purpose of
the express lane is to reduce the waiting time for these kind of
customers. Do they wait less, on average? How about the worst case?
"Utilization" is the time that someone was waiting in the queue. Did the
express lane have lower utilization?
- Open the "Activity, delay" blocks and click on the "Results" tab. The
utilization here is the fraction of time that the server was busy. Are we
keeping the express lane person busy enough? How does it compare to the
utilizations of the other servers?
Adjusting the Model
There are a bunch of fairly arbitrary aspects of this model. The
arrival rate, the service time calculation and the number of items
distribution, just to name three. I've tried to make plausible choices,
but I don't pretend to have done any more than that.
You'll also notice that there's not a lot of randomness in here. The
number of items and the arrival rate are random, but not the service
time. Do you think it should be?
Another arbitrary decision is the maximum number of items for the
express lane. If we increase this maximum, say to 12 or 15, we'd get
higher utilization of the express lane, but longer waiting times there
(but shorter for the regular lanes).
To do: Choose some aspect of the model to adjust and do this.
Run the simulation under these new conditions and see how much of a
difference it makes.
Creating the Model
I think the best way to learn how to build a model like this is to do
it. You already know how to choose blocks, set their parameters and draw
connections, so it's just a matter of getting familiar with these new
blocks and their parameters.
To make this exercise worthwhile, notice that we have a model of the
store with an express lane, but we don't have a model of our
current store, which doesn't have an express lane. To do a proper
comparison, we need to have both.
To do: Build a simulation model of the grocery store without an
express lane. I suggest you do it mostly from scratch, so that you'll get
some practice finding these blocks as well as parameterizing them, but
feel free to crib things from this model.
Comparing the Models
To determine whether two variable things are (statistically
significantly) different, we should use a statistical test, such as the
z-test or the bootstrap, which we'll learn soon.
- First, we should choose what data we will collect. In this case, we
might use the waiting time, the queue length, the server utilization, or
even some combination of those.
- We then collect our data. Run each model a number of times, say 30 or
more, and collect data from each run. (This is a Monte Carlo experiment.)
- Look at the collected data. Compute some summary statistics or
construct a histogram. It's important to look at the data to see if
anything odd is going on (for example, it's bimodal).
- Suppose we want to compare the mean of each sample. If we are willing
to assume that the mean is drawn from a Gaussian distribution, we can use
the z test.
- We'll do that in an upcoming class.
This work is licensed under a Creative Commons
License |
|
|
|