0% found this document useful (0 votes)
57 views6 pages

Assignment-02: Shikha Gupta 11536019 M.Tech (IT)

The document describes C++ programs for simulating M/M/m/k and M/M/1/k queueing systems. It includes the code for the C++ programs that takes input for the arrival rate, service rate, number of servers, and queue limit. It then calculates metrics like average number in queue, average waiting time, and time in system. It also provides sample GPSS code and output for simulating the same queueing systems.

Uploaded by

divya_sachan22
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views6 pages

Assignment-02: Shikha Gupta 11536019 M.Tech (IT)

The document describes C++ programs for simulating M/M/m/k and M/M/1/k queueing systems. It includes the code for the C++ programs that takes input for the arrival rate, service rate, number of servers, and queue limit. It then calculates metrics like average number in queue, average waiting time, and time in system. It also provides sample GPSS code and output for simulating the same queueing systems.

Uploaded by

divya_sachan22
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment-02

Shikha Gupta 11536019 M.Tech(IT)

C++ Program for M/M/m/k system.

#include<iostream> #include<cmath> using namespace std; int facto(int x) {int result=1; for(int j=x;j>=1;j--) { result= result*j; }

return result; } int main() {

float lambda,mu,rho,p_knot,number_in_system,time_in_system,service_time,avg_w aiting_time,avg_num_in_queue,a,lambda_eff,x=0,y=0,p_k; int k,m; cout<<"enter arrival rate,service rate and queue limit and number of servers such that service rate should be greater than arrival rate\n"; cout<<"arrival rate(lembda):"; cin>>lambda; cout<<"\nservice rate(mu):"; cin>>mu; cout<<"\nqueue limit(k):"; cin>>k; cout<<"\n Number of servers(m):"; cin>>m; a=lambda/mu; rho=lambda/(m*mu);

for(int i=1;i<=m;i++) { x += pow(a,i)/facto(i); }

for(int i=m+1;i<=k;i++)

{ y += pow(rho,i-m); } p_knot=1/(1+x+(pow(a,m)/facto(m))*y); p_k= float((pow(a,float(k))*p_knot))/float((facto(m)*pow(m,float(k-m)))); lambda_eff=lambda*(1-p_k); cout<<"\nrho:"<<rho; cout<<"\np_knot:"<<p_knot; cout<<"\np_k:"<<p_k; cout<<"\nlambda effective:"<<lambda_eff; avg_num_in_queue=pow(a,m)*rho*p_knot*(1-pow(rho,k-m)-((km)*pow(rho,k-m)*(1-rho)))/(facto(m)*pow(1-rho,2)); avg_waiting_time=avg_num_in_queue/lambda_eff; time_in_system=avg_waiting_time+1/(mu); number_in_system=lambda_eff*time_in_system; cout<<"\n Average number in queue="<<avg_num_in_queue; cout<<"\n average waiting time="<<avg_waiting_time; cout<<"\n time in system="<<time_in_system; cout<<"\n num in system="<< number_in_system;

system("pause"); }

OUTPUT:

For M/M/1/k system

GPSS PROGRAM for M/M/m/k system:


server STORAGE 3 GENERATE (EXPONENTIAL(1,0,1/40)) test LE Q$queue1,3,term QUEUE queue1 gate SNF server Enter server Depart queue1 ADVANCE (EXPONENTIAL(1,0,1/80)) LEAVE server Terminate 1 term Terminate 1

OUTPUT:

GPSS World Simulation Report - mmck.9.1 Sunday, April 22, 2012 19:33:25 START TIME 0.000 NAME QUEUE1 SERVER TERM LABEL LOC 1 2 3 4 5 6 7 8 9 10 BLOCK TYPE GENERATE TEST QUEUE GATE ENTER DEPART ADVANCE LEAVE TERMINATE TERMINATE END TIME 2.546 BLOCKS 10 FACILITIES 0 STORAGES 1

VALUE 10001.000 10000.000 10.000 ENTRY COUNT CURRENT COUNT RETRY 101 0 0 101 0 0 101 0 0 101 0 0 101 0 0 101 0 0 101 1 0 100 0 0 100 0 0 0 0 0 AVE.(-0) 0.002

TERM QUEUE RETRY QUEUE1 0 STORAGE DELAY SERVER 0 FEC XN 101 102 PRI 0 0

MAX CONT. ENTRY ENTRY(0) AVE.CONT. AVE.TIME 2 0 101 98 0.003 0.000

CAP. REM. MIN. MAX. 3 2 0 3

ENTRIES AVL. 101 1

AVE.C. UTIL. RETRY 0.520 0.173 0

BDT 2.552 2.570

ASSEM 101 102

CURRENT 7 0

NEXT 8 1

PARAMETER

VALUE

GPSS program for M/M/1/k program


GENERATE (EXPONENTIAL(1,0,1/40)) test LE Q$que,100,term QUEUE que SEIZE server DEPART que ADVANCE (EXPONENTIAL(1,0,1/60)) RELEASE server term TERMINATE 1

OUTPUT: GPSS World Simulation Report - mm1k.8.1 Sunday, April 22, 2012 19:36:24 START TIME 0.000 NAME QUE SERVER TERM LABEL LOC 1 2 3 4 5 6 7 8 ENTRIES 101 BLOCK TYPE GENERATE TEST QUEUE SEIZE DEPART ADVANCE RELEASE TERMINATE UTIL. 0.682 END TIME 2.595 BLOCKS 8 FACILITIES 1 STORAGES 0

VALUE 10000.000 10001.000 8.000 ENTRY COUNT CURRENT COUNT RETRY 104 0 0 104 0 0 104 3 0 101 1 0 100 0 0 100 0 0 100 0 0 100 0 0

TERM FACILITY DELAY SERVER 3 QUEUE RETRY QUE 0 CEC XN 101 FEC XN 105 PRI 0 PRI 0

AVE. TIME AVAIL. OWNER PEND INTER RETRY 0.018 1 101 0 0 0

MAX CONT. ENTRY ENTRY(0) AVE.CONT. AVE.TIME 6 4 104 36 0.939 0.023

AVE.(-0) 0.036

M1 2.488 BDT 2.599

ASSEM 101 ASSEM 105

CURRENT 4 CURRENT 0

NEXT 5 NEXT 1

PARAMETER

VALUE

PARAMETER

VALUE

You might also like