Consider N = 5 servers, where each server completes a job with probability µ = 0
ID: 3588247 • Letter: C
Question
Consider N = 5 servers, where each server completes a job with probability µ = 0:5 in each
time slot. Assume that the number of jobs that arrive in each time slot is a Binomial random
variable with parameters N and . When each job arrives, let the job join the queue with
the fewest number of waiting jobs, i.e., join the shortest queue. If multiple jobs arrive in a
time slot, do this for one job at a time, update the queue lengths, and then do this again for
the next job.
Plot the mean delay as a function of . You should keep track of each job to obtain
the delay of the job. Choose = [0.2; 0.3; 0.4; 0.45; 0.49; 0.495]. You should run the
simulations for 10^6 time slots.
Plot a histogram of the delays for = 0.45, i.e., the x-axis would be the possible delays,
1 time slot, 2 time slots, etc. The y-axis would be the fraction of jobs that experience a
delay of 1 time slot, 2 time slots, 3 time slots, etc.
Note:
Choose one programming language to do the simulation from C/C++, Matlab, Python,
Java, and R.
Report should include the plot, and simulation code and annotations.
Explanation / Answer
i use the DDA line approach to plot the graph with x and y axes taking input from user
#include <graphics.h>
#include <iostream.h>
#include <math.h>
#include <dos.h>
void main( )
{
float x,y,x1,y1,x2,y2,dx,dy,step;
int i,gd=DETECT,gm;
initgraph(&gd,&gm,"c:\turboc3\bgi");
cout<<"Enter the value of x1 and y1 : ";
cin>>x1>>y1;
cout<<"Enter the value of x2 and y2: ";
cin>>x2>>y2;
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx>=dy)
step=dx;
else
step=dy;
dx=dx/step;
dy=dy/step;
x=x1;
y=y1;
i=1;
while(i<=step)
{
putpixel(x,y,5);
x=x+dx;
y=y+dy;
i=i+1;
delay(100);
}
closegraph();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.