Question: Problem 4 Coding Assignment: In this problem you will develop code to simulate a single-server queue, where the time to process a request at the

 Problem 4 Coding Assignment: In this problem you will develop code

Problem 4 Coding Assignment: In this problem you will develop code to simulate a single-server queue, where the time to process a request at the server is modeled using an exponential distribution, while the arrival process of the requests follows a Poisson distribution (Hint: recall that if an arrival process is Poissonian, then the inter-arrival time between requests is exponentially distributed) a) Write a Java class that implements a discrete event simulator. The simulator should have a method with the following prototype: void simulate(double time), that simulates the arrival and execution of requests at a generic server for time milliseconds, where time is passed as a parameter to the method. The class should be implemented in its own java file, named simulator.java. The simulator class will internally use a exponentially-distributed random number generator. For this, you can re-use the function you wrote as part of the previous assignment Apart from implementing the simulate(...) method, the class should also include a main(...) function. The main(...) function should accept 3 parameters from the calling environment (in the following order) (a) length of simulation time in milliseconds. This should be passed directly as the time parameter to the simulate(...) function. (b) average arrival rate of requests; (c) average service time at the server; It is responsibility of the main(...) function to internally invoke the implemented simulate(...) function only once. In this first version, the simulate(. . . ) function will need to print in the console the simulated time at which each request arrives at the system (ARR), initiates service (START), and completes service (DONE). The output must look like this: RO ARR: RO START: R1 ARR: R2 ARR: RO DONE: R1 START: R1 DONE: R2 START: R2 DONE: where is the simulated time in milliseconds at which the event occurred printed in decimal format. This is also called the trace of the simulation b) Modify the code of the simulator written in the first part of this problem to measure utilization, average queue length, and average response time of requests. The simulator remains the same in terms of interface, accepted parameters, and simulation logic. However, in addition to printing out the simulation trace just like before, the simulator should add three lines at the end of its output, i.e. after the trace. This should be formatted as: UTIL: QLEN: avg. queue length:> TRESP: Problem 4 continued on next page. CS-350-Fundamentals of Computing Systems ::Homework Assignment #2 Problem 4 (continued) where is a decimal number between 0 and 1, is a decimal number, and is a decimal number expressed in milliseconds. Problem 4 Coding Assignment: In this problem you will develop code to simulate a single-server queue, where the time to process a request at the server is modeled using an exponential distribution, while the arrival process of the requests follows a Poisson distribution (Hint: recall that if an arrival process is Poissonian, then the inter-arrival time between requests is exponentially distributed) a) Write a Java class that implements a discrete event simulator. The simulator should have a method with the following prototype: void simulate(double time), that simulates the arrival and execution of requests at a generic server for time milliseconds, where time is passed as a parameter to the method. The class should be implemented in its own java file, named simulator.java. The simulator class will internally use a exponentially-distributed random number generator. For this, you can re-use the function you wrote as part of the previous assignment Apart from implementing the simulate(...) method, the class should also include a main(...) function. The main(...) function should accept 3 parameters from the calling environment (in the following order) (a) length of simulation time in milliseconds. This should be passed directly as the time parameter to the simulate(...) function. (b) average arrival rate of requests; (c) average service time at the server; It is responsibility of the main(...) function to internally invoke the implemented simulate(...) function only once. In this first version, the simulate(. . . ) function will need to print in the console the simulated time at which each request arrives at the system (ARR), initiates service (START), and completes service (DONE). The output must look like this: RO ARR: RO START: R1 ARR: R2 ARR: RO DONE: R1 START: R1 DONE: R2 START: R2 DONE: where is the simulated time in milliseconds at which the event occurred printed in decimal format. This is also called the trace of the simulation b) Modify the code of the simulator written in the first part of this problem to measure utilization, average queue length, and average response time of requests. The simulator remains the same in terms of interface, accepted parameters, and simulation logic. However, in addition to printing out the simulation trace just like before, the simulator should add three lines at the end of its output, i.e. after the trace. This should be formatted as: UTIL: QLEN: avg. queue length:> TRESP: Problem 4 continued on next page. CS-350-Fundamentals of Computing Systems ::Homework Assignment #2 Problem 4 (continued) where is a decimal number between 0 and 1, is a decimal number, and is a decimal number expressed in milliseconds

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!