Lab on Bimodal Distributions, Hierarchical Models, Fast Food Operation
Today, we'll learn a new simulation model that I hope will be
interesting. Then, we'll spend some time doing some point estimates and
confidence intervals.
Bimodal Distributions
Suppose we want to have a service time that is the sum of two
Gaussians. This comes about when there are two kinds of service, one
longer than the other, but both are Gaussian. The PDF for this
distribution might look like a Bactrian camel, or one hump might be much
larger than the other, dominating the appearance. Consider the following:
bimodal.mox
- What are the two means of the distributions?
- What are the two standard deviations of the distributions?
- What is the mixture of the two?
- What does the combined distribution look like?
- What is the mean and standard deviation of the combined distribution?
- Experiment with some different values for the parameters above.
Now, let's see how this might work as a service time. Examine the
following:
bimodal-service.mox
Note that there's gotcha with the histogramming. The reasons for this
are:
- Efficiency: a number is only generated upon demand.
- Histograms don't generate demands, and even if they did, they'd get a
different number
We'll talk about this. I asked the Extend support folks, and they sent
the following, which works fine, and it explains why Winton's models
(which we'll look at soon) so often use timers.
bimodal-service-2.mox
The "Timer" block lives in (Discrete Event Lib / Information / Timer).
Essentially, you can determine how long an item (entity) takes to go from
one place in a model to another. The end is marked with the "sensor"
input.
Attributes
You noticed in the last model that there were three attributes of the
items used: Dist1, Dist2, and WhichDist. What attributes can you use?
Actually, you can use any you want; you can make them up. Let's do that.
- Open the Set Attribute block
- Go to an unused attribute and select "New Attribute"
- Enter something. I used "crankiness"
- Close the block
- Copy a random number generator and set the new attribute to some
suitable value. I used integers from numbers 1-10 for the crankiness.
That's all there is to it!
Hierarchical Models
(There may not be time for this today.)
Hierarchical models are nice when you have a fairly complex model that
breaks into coherent parts. (Our global heat simulation might be usfully
restructured this way.) The complex way of doing service times could be
done this way. Let's try:
- In the complex model (bimodal-service-2.mox), use the mouse to select
all the blocks involved with determining the service time and delaying the
item. Choosing how to group blocks to make a hierarchy is a judgement
call, so different people may make different decisions. Some ways to
modularize may make more sense than others, but there can certainly be
several good solutions and no single "right" answer.
- From the Extend menus, choose "Model / Make Selection Hierarchical."
- Name the hierarchical block. I called mine "bimodal service." Again,
this is a judgment; choose something that seems to describe the overall
effect of the hierarchical block (h-block).
- (When making a hierarchical model from scratch, you'd use "Model/New
Hierarchical Block" instead.)
- You'll probably make some mistakes with that. If so, delete the
erroneous parts and re-build.
- Double-click on the h-block to open it. You can restructure it there.
- Notice the red-outlined connectors in the h-block. Those are its
input and output connectors. You can add and delete them by opening the
h-block structure window: Either select the block and choose Model / Open
Hierarchical Block Structure or option-double-click the h-block. Do that.
- The h-block structure window has four panes. The lower right is the
sub-model. The upper left is the icon. The named connectors are the lower
left. The upper right is the help text.
- You can rename the connectors, to make their names more intuitive.
Here's what I came up with
bimodal-service-2-hier.mox
Notice how much nicer the main model is! We could use this block in a
much more complex model and the overall model would be much easier to see
and understand. Notice that the "help" button for the new block works,
too.
The ability to create hierarchical blocks is a really nice feature of
Extend.
Fast Food Operation
Extend has a built-in example model of a hamburger joint. We'll
explore this first. You needn't understand every aspect of this model, but
try to think about how this expands your repertoire of modeling
techniques.
- Open Extend 6/Examples/Operations Research/Fast Food Operations.mox.
- It's a hierarchical model. Open the various parts to explore.
- Notice the use of the Timer block in the "Ordering" h-block. Where
does the sensor input come from?
- There is an "unbatch" block in the "Ordering" h-block. Read the
documentation on this. Look at where the information is flowing. Can you
see what the block is doing?
- In the kitchen, there is a "Resource" block. Read its documentation.
Make some educated guesses about how it works.
- Similarly, read about the "Activity, Service" block and the "Activity,
Multiple" blocks in the kitchen.
- The "Get Attribute" block in the "WaitingArea" is somewhat
mysterious. What is being done with the attribute? Try adding a "Plotter
Discrete Event" and plotting the number of customers in the queue after
the "Get Attribute" block. Notice that the queue length doesn't increase
and decrease by just one customer each time. It increases by as much as
3, which is the maximum number of hamburgers.
- Look at the "Batch" block at the top level. What is this doing?
This is a pretty cool model, and pretty complicated. Some of you may
decide to build something this complex for your project, but it's not
required. I'm just looking for you to build something interesting and
challenging.
Running the Restaurant
When we run the Fast Food Operation model, we get several kinds of
data, including the wait time for each customer, the length of the line,
and the number of burgers. Let's suppose we're only interested in the
average wait time.
- Modify the model to compute the mean wait time.
- Set up the model to compute the mean of the mean wait times over
several runs, say 30.
- Compute a 95 percent confidence interval on the mean waiting time for
customers.
Now, here's some data you could take to your boss!
Suppose, though, that your boss knows some statistics and says, "Gee,
I'd really rather have an estimate of the median wait time."
Now what?
- Run the simulation once.
- Extract the wait-time data from the plotter, copy it to Excel, and
compute the median.
- Is the median the same as the mean? If so, this might be a
symmetrical distribution, in which case you can tell your boss to use the
original point estimate.
- Try this several times. Because this is so tedious, we won't collect
a lot of median data.
Think about how you would compute a confidence interval on a median.
There are a couple of issues:
- How do you combine a collection of medians into an overall point
estimate. Do you take their mean or their median?
- If you take their mean, you could use the same procedure for finding a
confidence interval as you do for any other mean.
- If you take their median, you have to use a bootstrap procedure.
- Try this for just one of the median runs, resampling from the median
data of one run.
Review
Today, we learned about the following:
- bimodal distributions and how to do them
- How to get histograms of values you're using for another purpose
- How to create new attributes
- hierarchical models, why they're useful and how to do them
- the Timer block, which can measure how long it takes an item (entity)
to get from the Timer block to someplace else in the model
- the Unbatch block, which can "clone" an entity to create two copies.
The model did this to divide the hamburgers from the customer.
- the Resource block, which allows us to pre-allocate a fixed number of
items. Here, they were hamburgers.
- The "Activity, Service" block, which passes an item (in this model,
they are hamburgers from the Resource block) only when one is demanded (in
this model, whenever an order arrives). So, this puts a burger on the
grill whenever an order arrives. (In this model, we don't run out of
burgers, so there is never unfilled demand. Thus, it would be equivalent
to just send the orders to the grill instead of the burgers.)
- The "Activity, Multiple" block, which serves multiple items at a
time. Here, we used it to cook 10 hamburgers at a time.
- A way to use the "Get Attribute" block to turn an attribute (# of
burgers) into a number of items. This lets us match up customers and
hamburgers to ensure that each customer gets enough.
- The "Batch" block, which matches up items. Here, we used it to match
up hamburger items with customer items, so that each customer gets their order.
This work is licensed under a Creative Commons
License |
|
|
|