Question: You should write a C++ program which uses discrete event simulation to model the queuing and service of a set of requests . Store all

You should write a C++ program which uses discrete event simulation to model the queuing and service of a set of requests. Store all the event times on a heap and have a secondary array telling which server is doing what. Make sure to add appropreate comments to make the code more readable.

Input consists of the following data (given in the sample file below):

- The number of primary servers in the system.

- The number of secondary servers in the system.

- A set of service requests each consisting of an arrival time and two service times in the order primary followed by secondary. This set is terminated by a dummy record with arrival time and service times all equal to 0.

(Note: the arrival times are sorted in ascending order).

Your program should read the name of the data file from standard input and then read the data in the named file into the simulation as needed.

The simulation is to be of a system with two sets of servers, primary and secondary, each set of servers associated with a queue. Customers arrive in the system and are served first by a primary server and, on completion of this service, by a secondary server. If all servers of a particular type are busy, the customer will enter either the primary or secondary queue as appropriate.

The simulation should be run until the last customer has left the system.

Important Notes: - Standard libraries of data structures and algorithms such as STL may not be used. - The simulation starts at time = 0, not when the first customer arrives. - You may assume that there are no more than 10 servers of each type, 20 total.

Output, to standard output will consist of the following data:

- Number of people served.

- Time last service request is completed.

- Average total service time.

- Average total time in queue(s). Both overall and separate.

- Average length of queue. For each queue and overall.

- Maximum Length of queue. For each queue and overall.

- Total idle time for each server.

The format of the output should look like this:

Number of people served: xxx

Time last service request completed: xxx.xxx

Avg total service time: x.xxx

Avg total time spent in primary servers: xx.xx

Avg total time spent in secondary servers: xx.xx

Avg total time spent in queues: xx.xx

Avg length of the primary servers: xx.xx

Avg length of the secondary servers: xx.xx

Avg length of the queues: xx.xx

Max length of primary servers: xx

Max length of secondary servers: xx

Max length of queues: xx

Idle times of servers:

Total idle time for each server in primary servers

0 1 2

xx.xx xx.xx xx.xx

Total idle time for each server in secondary servers

0 1

xx.xx xx.xx

Please use this sample file to test this program:

3 2 0.490986897 1.385112773 3.590034257

1.241028335 1.794862289 1.360290065

1.767694437 3.508872586 2.528623235

2.108350758 1.697700393 1.24499551

2.171760494 4.453241905 3.352559789

2.63033819 3.074279642 3.506584411

3.501143903 3.197945668 3.69322067

3.919179966 1.587555336 1.554331602

4.285220927 2.462347587 3.712313223

4.903813035 1.601535549 1.476412114

5.880221024 1.711730329 2.620081524

6.332875975 2.593645279 2.283626938

7.21734923 1.02771052 1.126456304

8.151866418 1.123773959 2.715130524

8.665921869 4.476768016 3.039874078

9.160499093 1.726910146 2.63001837

9.43795821 3.055150814 1.074536682

9.740793279 1.371899802 2.147988246

10.18671208 3.377224803 1.517646447

10.54220008 3.175974072 2.767316669

11.29937684 3.304307858 2.503408972

11.39185977 3.378386574 2.551986442

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!