Assignment Document

Write a computer program that simulates an M/M/1 queue

Pages:

Preview:


  • "Part (A)(a) Write a computer program that simulates an M/M/1 queue.clc; clear all;close all;disp('Enter lambda value');lambda=input('>> Enter value= ');disp('Enter mu value');mu=input('>> Enter value= ');f..

Preview Container:


  • "Part (A)(a) Write a computer program that simulates an M/M/1 queue.clc; clear all;close all;disp('Enter lambda value');lambda=input('>> Enter value= ');disp('Enter mu value');mu=input('>> Enter value= ');fprintf('\\t\\tlambda = %d\\n',lambda);fprintf('\\t\\t `mu = %d\\n',mu);N= lambda/(mu-lambda);fprintf('\\t >> Expected (average) number in the system E[N]= %f\\n',N);T= 1/(mu-lambda);fprintf('\\t >> Average time spends in the system E[T]= %f\\n',T);W= lambda/(mu*(mu-lambda));fprintf('\\t >> Average waiting time queueE[W]= %f\\n',W);Nq=(lambda^2)/(mu*(mu-lambda));fprintf('\\t >> Expected (average) number queue E[Nq] = %f\\n',Nq);U= lambda/mu;fprintf('\\t >> Server utilizationE[U]= %f\\n',U); (b) From your program when ? =5 and µ=8, find the simulate results of E[N], E[T], E[w],E[N ] and E[U].q Simulated results:Enter lambda value>> Enter value= 5Enter mu value>> Enter value= 8lambda = 5 `mu = 8>> Expected (average) number in the system E[N]= 1.666667>> Average time spends in the system E[T]= 0.333333>> Average waiting time queue E[W]= 0.208333>> Expected (average) number queue E[Nq] = 1.041667>> Server utilization E[U]= 0.625000 (c) Using the same value of ? and µ in (b), find the theoretical results of the E[N], E[T],E[w], E[N ] and E[U].q ? E[N] == 1.66µ - ? 1 E[T] == 0.33µ - ? ? E[W] == 0.208µ(µ - ? ) 2 ? E[Nq] == 1.041µ(µ - ? ) ? E[U] == 0.625µ (d) Compare the theoretical and simulated results for each parameter.Parameters Theoretical SimulatedE[N] 1.66 1.666667E[T] 0.33 0.333333E[W] 0.208 0.2083331.041 1.041667E[Nq]0.625 0.625000E[U] ? ? ? ? ? (e) Based on this program, plot E[N] against the utilization (?), where ? =, , , , . Note? ? ? ? ? that ?<1 for a stable system.Program code:clc; clear all;close all;p=[3/8, 4/8, 5/8, 6/8, 7/8];for i=1:length(p)N(i)=p(i)/(1-p(i));enddisp(' p=[3/8, 4/8, 5/8, 6/8, 7/8];')fprintf(' E[N] = %f %f %f %f %f',N);plot(N,p);xlabel('Expected (average) number in the system E(N)');ylabel('Server utilization p');title('plot of E[N] against the utilization (p)');Simulation result:p=[3/8, 4/8, 5/8, 6/8, 7/8]; E[N] = 0.600000 1.000000 1.666667 3.000000 7.000000 Simulated Plot: Part (B)(a) Write a computer program that simulates an M/D/1 queue.clc; clear all;close all;disp('Enter lambda value');lambda=input('>> Enter value= ');disp('Enter mu value');mu=input('>> Enter value= ');fprintf('\\t\\tlambda = %d\\n',lambda);fprintf('\\t\\t `mu = %d\\n',mu);p= lambda/mu;N= (p/(1-p)) - ((p^2)/(2*(1-p)));fprintf('\\t >> Expected (average) number in the system E[N]= %f\\n',N);T= N/(lambda);fprintf('\\t >> Average time spends in the system E[T]= %f\\n',T);W= T-(1/mu);fprintf('\\t >> Average waiting time queueE[W]= %f\\n',W);Nq=lambda*W;fprintf('\\t >> Expected (average) number queue E[Nq] = %f\\n',Nq); ? (b) From your program when ? = , find the simulated results of E[N], E[T], E[w] and? E[N ].q Enter lambda value>> Enter value= 5Enter mu value>> Enter value= 8lambda = 5 `mu = 8>> Expected (average) number in the system E[N]= 1.145833>> Average time spends in the system E[T]= 0.229167>> Average waiting time queue E[W]= 0.104167>> Expected (average) number queueE[Nq] = 0.520833(c) Using the same value of ? in (b), find the theoretical results of E[N], E[T], E[w] andE[N ]. Then compare them with the results in (b).q 2 ? ? E[N] = - = 1.666 – 0.5208 =1.1451 - ? 2(1 - ? ) ? [ ? ] E[T] == 0.229? 1 E[W] = E[T] -= 0.229 – 0.125 = 0.104µ E[Nq] = ?E[W] = 5*0.104 = 0.52Parameters Theoretical SimulatedE[N] 1.14 1.145833E[T] 0.229 0.2291670.104 0.104167E[W]0.52 0.520833E[Nq] (d) Compare the results in (b)with the results for M/M/1 “Question 1(b)”. What do youobserve?Parameters M/M/1 M/D/11.666667 1.145833E[N]E[T] 0.333333 0.229167E[W] 0.208333 0.104167E[Nq] 1.041667 0.520833 From the above table we can observe that the M/D/1 based queuing system has lessaverage time spend in system, average waiting time than M/M/1 queuing system. "

Related Documents

Start searching more documents, lectures and notes - A complete study guide!
More than 25,19,89,788+ documents are uploaded!

Why US?

Because we aim to spread high-quality education or digital products, thus our services are used worldwide.
Few Reasons to Build Trust with Students.

128+

Countries

24x7

Hours of Working

89.2 %

Customer Retention

9521+

Experts Team

7+

Years of Business

9,67,789 +

Solved Problems

Search Solved Classroom Assignments & Textbook Solutions

A huge collection of quality study resources. More than 18,98,789 solved problems, classroom assignments, textbooks solutions.

Scroll to Top