Project: Multi-Server Single Queue Simulation



Project: Multi-Server Single Queue Simulation

Overview:

The goal of this project is use the knowledge we have studied to simulate single queue multiple server problems. Specifically, this project is to simulate scenario of Barber Shop where there are five barbers cutting hair for customers who come over time. After customers come, they will wait in one queue for their turns. If one barber is available, then the first customer in the queue will be served immediately. Make sure that all the customers are served in the rule of “first come, first service”.

Your Task

Your simulation structure should be event-driven simulation, which is the most common simulation model. At any given time, the simulation is in a single state. The simulation state can ONLY change at event times, where an event is defined as an occurrence that MAY change the state of the system. Events in this BarberShop simulation are the following: customer arrival, barber available(finished cutting hair) and the transition of a system state.

Each event occurs at a specified time. Since the simulation state only changes at an event, the clock can be advanced to the next most recently scheduled event. (Thus the term next event simulation model.)

Events are scheduled via an event queue. The event queue is a sorted queue which contains "future" events; the queue is sorted by the time of these "future" events. The event queue is initialized to contain the arrival of the customers and the first occurrence of finished cutting. The main loop of the simulation consists of processing the next event, perhaps adding more future events in the queue as a result, advancing the clock, and so on until all customers terminate.

In the end, you should print the details of the events in the system  

Input Format

The simulator input includes the number of customers that require hair cutting, and, for each customer, the arrival time and the time needed for hair cutting (Note: each customer’s hair cutting time is same for all the barbers, though different customers have different hair cutting time).

All these simulation parameters are integers. Your simulator obtains these parameters from the input file, which is in the following format.

   number_of_customers

   process_number arrival_time  hair-cutting-time

   process_number arrival_time  hair-cutting-time

   ....  

The following is an example input file to your simulation (time units = minutes):

10

1 0 30

2 15 60

3 5 25

4 30 100

5 32 20

6 25 90

7 50 40

8 12 35

9 4 150

10 31 50

You should create your own input file. Your program should generate at least 20 customers. You can assume no time is delayed when the barber switches from one customer to another customer. 

Output Format

There are two mode to display the output depending the user’s input:

-d: detail mode

-v: verbose mode

In detailed information mode (i.e., -d flag is given), the output of the simulation consists of the information about each customers including: arrival time, service time(hair-cutting-time), waiting time, finish time. See the following example.

$sim -d input_file

Customer 1:

arrival time: 0

service time: 30 minutes

waiting time: 0 minutes

finish time: 30 units

Customer 2:

arrival time: 15

service time: 60 units

waiting time: 0 units

finish time: 75 units

Customer 3:

arrival time: 5

service time: 25 units

waiting time: 0 units

finish time: 30 units

….

In verbose mode, the output of the simulation includes the scheduling decisions and the switching of the processes. Specifically, the output includes every event that occurs, the time of the event, and the state transition:

At time 0: Customer {1} moves from {arrival state} to {waiting state}

At time 0: Barber {1} is available and starts to cut hair for Customer {1}

….

At time X: Barber {1} finish the hair cutting for Customer {i}, Customer {i} leaves, then Barber {1} starts to cut hair for Customer {j}

….

Each state transition should be given as above on a separate line. (Be sure to include events that occur at the same time.)

Submit:

Write a 1-2 page paper describing your project, what problems you've faced and how you've overcome them. What are practical limitations on that algorithm?

What to submit:

1) Submit your test data.

2) Submit ALL source code with detailed instructions on how and where to compile it, and how to make it run. If possible, please submit a Makefile to build your code under C++, GCC, Java, or whatever language you use. You may use any language you wish, but you need to document what language you're using and how to compile code somewhere in your submission. Also comment your code! If I can't read it, it's wrong!

3) Submit your paper describing the project.

4) Submit a file named: description.txt that describes what and where all the information is stored. (which file does what, which file contains results of the algorithm, etc.). This is mostly needed so that I don't get lost in your project directory.

Note: All descriptions and text should be in TEXT format. Do NOT submit MS Word documents, etc. Everything has to be readable without any special programs. (If something "has" to be formated, use PDF).

When submitting, you're very likely to have many files. You can compress them into a .zip, .rar, or .tar.gz and submit that.

Tips: Organize and design the project and know what you're doing before you start coding. (and don't wait until the last weekend to do it).

Good Luck!

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download