|CSC 153||Grinnell College||Spring, 2005|
|Computer Science Fundamentals|
This program examines an object-oriented, Scheme-based solution to the following:
Consider a commercial environment where multiple clerks are available to serve customers. There are at least two models for such service:
Grocery Store Model: There is a queue for each clerk. When the customer is ready for service, the customer selects the shortest queue and stays in that queue until being served.
Airport Model: There is only one queue, which all customers enter. When a clerk becomes available, the customer at the head of the queue goes to that clerk for service.
Suppose also that we know the average number of customers that can be expected in a given time interval (e.g., customers per hour) and the average time required for a clerk to serve a customers (e.g., minutes per customer).
Run a simulation to compare the effectiveness of the two models -- specifically determining the relative waiting times of customers in each model.
The Grocery-Store and Airport Models for this problem are illustrated schematically in the following diagram.
Program /home/walker/oop/clerks/clerks-oo.ss provides an object-oriented solution to this problem in Scheme.
The basic idea of this program is to simulate the flow of customers through clerks over a specified length of time (in hours). The overall simulation time is divided into small intervals (in seconds). For each interval, a random number generator is used to determine whether or not a customer enters a queue, based on an overall arrival rate (given in customers per hour). Also, for each interval, if a clerk is working with a customer, the random number generator determines whether or not the clerk finishes for that customer, again based on an average service time (given in minutes per customer).
The first several lines of this program set the parameters for the simulation. In addition to the above measures (overall simulation length, interval length, customers arriving per hour, etc.), three variables allow the user to specify how much information is printed during a simulation.
Copy program /home/walker/oop/clerks/clerks-oo.ss to your account, open it within an editor, and load it within a Scheme environment.
Run the program several times, and note the output printed. How does the output seem to relate to the initial program constants?
Change a trace variable to true (#t), and explain the output obtained:
In each case, examine the output, and try to explain the output produced.
Setting the tracing variables back to false (#f), try running the simulation for several arrival levels (cust-per-hr) and several service times (min-per-cust) for the single-queue model (5 clerks, 1 queue).
Using the same arrival levels and service times from part 4, run the simulation for the multi-queue model (5 clerks, 5 queues).
Based on the data collected, is one model better than the other: for all cases? for some cases? Briefly explain your conclusions.
Examine the program clerks-oo.ss to answer the following questions related to object-oriented design and problem solving.
Describe the objects in this program.
Using tabular or outline form, indicate:
As the program executes, draw a diagram that indicates what messages are sent from one object to another during the simulation. That is, draw one or more flow diagrams for processing in this program, following the model of flow diagrams given in the solution for the Eliza program from the previous lab.
clarify how statistics are recorded for this simulation.
Explain the role of the main procedure simulate in this program; how does processing proceed for the simulation?
This document is available on the World Wide Web as
created April 8, 2000
last revised March 22, 2005
|For more information, please contact Henry M. Walker at email@example.com.|