Simulation algorithm, Programming Languages

Assignment Help:

 Please remember to read and follow all of the assignment guidelines.

This assignment will expand upon the simulation algorithm given in class to produce a program which may be used to predict the behaviour of a slightly more complex system. Instead of assuming there is only a single cashier available to handle our lineup for movie tickets, we will allow an arbitrary number of cashiers instead. This would allow - for example- a movie theatre owner to determine the optimal number of cashiers to have on staff to ensure a reasonable wait for tickets.

One way to allow our algorithm to solve the slightly more complicated problem is to keep track of an extra piece of information. In the method, we used in class, we stated that the entry at the front of the lineup queue represented the customer currently at the cashier. If we have more than one cashier, we cannot use this method, since we can only examine the first element in a queue. Instead, the lineup will only contain a queue of waiting customers, not those at cashiers; as soon as a customer gets a cashier, they are removed from the queue. The event queue will have to be modified - instead of holding only 0 or 1 departure events, it will have to hold at most as many departure events as there are cashiers. When one of those departures occurs, then another cashier is free; thus, the event queue will have to keep track of how many departure events are in it.

Since you will have to make the appropriate modifications to the algorithm, you may want to test your algorithm on paper before implementing it. If you can come up with a different way to modify the algorithm, feel free to use it!

Your complete program should open a data file containing a sequence of time and duration values sorted by increasing time, one pair on each line. In a loop, read in values for the number of cashiers; check your input (the number of cashiers has to be greater than or equal to 1). Ask the user of the program whether or not they want to observe your algorithm working. Apply your simulation algorithm to the data in the file with that number of cashiers. If the user wanted to see algorithm work, show the contents of your data structures at each time value (this should include the time, the list of events waiting to happen, the lineup, and the total wait so far). This data should be neatly printed in a table. After your algorithm is done, print out the total amount of time customers spent waiting in line, and the average wait (divide the total wait by the number of customers). Repeat, using the same data file, reading in a new number of cashiers.

Although data structures you choose will largely be determined by the algorithm, you may choose any method of implementation, with one restriction. If you use a fixed-size implementation (i. E, an array), you may not choose the size of the array based on solely on the amount of given input data. If you use an array for your queue, it may have a maximum of 10 entries in it (to simulate the fact that you should not know the size of the input data). If you use an array for the ordered list, it should have the ability to dynamically re-size itself based on the number of entries that will be in it.

Hand in your source code and the output of running your program on the following two data sets: a5test1.txt and a5test2.txt. For each, run the simulation with 1 cashier (your output should show the algorithm work in these cases), 2 cashiers (do not show the algorithm working), 4 cashiers and 5 cashiers (optional).

 


Related Discussions:- Simulation algorithm

Write the dual of the max flow problem, 1. Write the dual of the above max-...

1. Write the dual of the above max-?ow problem. 2. Solve both problems with AMPL, and for each print the values of the vari- ables and the values of the dual variables (if a p

Function to check whether a certain ingredient is on pizza, Carnivorous Car...

Carnivorous Carla only eats pizza if it has at least three of the following ingredients: ham, pepperoni, salami, italian sausage, bacon. You have the function contains() to check w

Shell script to change the permission of a file, Normal 0 false...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Find max and min no.from numbers passed through command line, Normal 0 ...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Write a prolog predicate has duplicates, Write a Prolog predicate has_dupli...

Write a Prolog predicate has_duplicates(L) that is true if list L contains duplicated elements (that is at least 2 copies of an element). For instance: ?- has_duplicates([a,e,b,

Computer design project , I''m studying electrical engineering, and this se...

I''m studying electrical engineering, and this semester im taking course that called Computer Design. in this course they need me to a final project about any thing we took during

Miranda, Hi, Can you do exercises: D2, D3, D4, and D5 on page 230 of the fo...

Hi, Can you do exercises: D2, D3, D4, and D5 on page 230 of the following book: http://www.daimi.au.dk/~bra8130/Wiley_book/wiley.html . The book can be downloaded for free from t

Multi-targeting .net structure, Support for Multi-Targeting The multi-targe...

Support for Multi-Targeting The multi-targeting function of Vision Facilities allows you specify the particular edition or account of the .NET Structure that is required for your p

What is hiding a method? explain, Question 1 Explain the three traits of O...

Question 1 Explain the three traits of Object Oriented Programming Question 2 Write a note on (a) Assignment Operators                             b) Bitwise Operators.

Information management system, Write a detailed description on how you woul...

Write a detailed description on how you would go about planning information system for an organisation

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd