Problem 1: Write a Simulation program of a single queue system with a Poisson ar
ID: 3738613 • Letter: P
Question
Problem 1: Write a Simulation program of a single queue system with a Poisson arrival process at rate and a. The call holding (service) times are exponentially distributed with a mean of one unit time. b. The call holding (service times are Uniform [0, 2] service time with a mean of one unit time. c. The call holding (service) mes are constant service time with a mean of one unit time. Compare your systems (u n and queue length) for different Poisson arrival rate (e.g., 0.1, 0.2, 0.8), Graph the resultsProblem 2: Write a simulation program to compare the efficiency of two systems (A&B) at the check-in counter at an airport. The first system (A) has two separate queues with arrival at rate h/2 and service rates of u. The second system (B) has a single queue with combined arrival at rate and service rates of 2u. The service times are negative exponential distribution l and customers arrive as a Poisson process. Compare your systems (utilization and queue length) for different Poisson arrival rate h (e.g., 0.1, 0.2, 0.80. Graph the results. Problem 1: Write a Simulation program of a single queue system with a Poisson arrival process at rate and a. The call holding (service) times are exponentially distributed with a mean of one unit time. b. The call holding (service times are Uniform [0, 2] service time with a mean of one unit time. c. The call holding (service) mes are constant service time with a mean of one unit time. Compare your systems (u n and queue length) for different Poisson arrival rate (e.g., 0.1, 0.2, 0.8), Graph the results
Problem 2: Write a simulation program to compare the efficiency of two systems (A&B) at the check-in counter at an airport. The first system (A) has two separate queues with arrival at rate h/2 and service rates of u. The second system (B) has a single queue with combined arrival at rate and service rates of 2u. The service times are negative exponential distribution l and customers arrive as a Poisson process. Compare your systems (utilization and queue length) for different Poisson arrival rate h (e.g., 0.1, 0.2, 0.80. Graph the results. Problem 1: Write a Simulation program of a single queue system with a Poisson arrival process at rate and a. The call holding (service) times are exponentially distributed with a mean of one unit time. b. The call holding (service times are Uniform [0, 2] service time with a mean of one unit time. c. The call holding (service) mes are constant service time with a mean of one unit time. Compare your systems (u n and queue length) for different Poisson arrival rate (e.g., 0.1, 0.2, 0.8), Graph the results
Problem 2: Write a simulation program to compare the efficiency of two systems (A&B) at the check-in counter at an airport. The first system (A) has two separate queues with arrival at rate h/2 and service rates of u. The second system (B) has a single queue with combined arrival at rate and service rates of 2u. The service times are negative exponential distribution l and customers arrive as a Poisson process. Compare your systems (utilization and queue length) for different Poisson arrival rate h (e.g., 0.1, 0.2, 0.80. Graph the results.
Explanation / Answer
here is the code for the given problem in c
#include<iostream>
#include <cmath>
#include "lcgrand.h"
using namespace std;
const int Queu_Limit=100;
const int BUSY=1;
const int IDLE=0;
int
choice,
Num_Completed_Customers,
Number_of_Events,
Number_in_Queue,
Server_Status;
double
End_Time,
Type_Next_Event,
Mean_interArrival_Time,
Mean_service_Time,
Clock,
Time_Arrival[Queu_Limit + 1],
Service_Time[Queu_Limit + 1],
Next_Arrival_Time,
Next_Completion_Time,
Next_Service_Time,
Total_Flow_Time,
Progres_Arrival_Time,
Progres_Completion_Time,
Waiting_Time;
void initialize();
void Timing();
void Arrival();
void Completition();
float expon(float mean);
void Search_Min(double[],double[]);
int main()
{
initialize(); // Intialization of the System
cout<<" * Single-server queueing system with fixed run * ";
cout<<" _________________________________________________"<<endl;
cout<<" 1.First In First Out"<<endl;
cout<<" 2.Minimum Processing Time"<<endl<<endl;
do
{
cout<<" Enter your Policy: ";
cin>>choice;
}while(choice>2||choice<1);
cout<<" Mean Inter arrival Time: "<<Mean_interArrival_Time;
cout<<" Mean Service Time: "<<Mean_service_Time<<endl;
cout<<"The End of Simulation Time: "<<End_Time<<endl<<endl;
while(true)
{
Timing();
if(Clock>End_Time)
break;
switch (int(Type_Next_Event))
{
case 1:
Arrival();
break;
case 2:
Completition();
break;
}
}
cout<<" Total Flow Time: "<<Total_Flow_Time;
cout<<" Total Waiting Time in Queue: "<<Waiting_Time;
cout<<" Average Waiting Time in Queue: "<<Waiting_Time / Num_Completed_Customers;
cout<<" Average Flow Time: "<<Total_Flow_Time / Num_Completed_Customers;
cout<<" Number of Completed Customers: "<<Num_Completed_Customers;
cout<<" Average Number of Customers In System / Unit Time: "<<Num_Completed_Customers / Clock<<endl<<endl;
return 0;
}
void initialize()
{
Number_of_Events = 2; // Arrival , Completion
Mean_interArrival_Time=1.0;
Mean_service_Time=0.5;
End_Time=100.0;
Clock = 0.0;
Server_Status = IDLE;
Number_in_Queue = 0;
Num_Completed_Customers = 0;
Total_Flow_Time = 0.0;
Waiting_Time = 0.0;
Next_Arrival_Time = Clock + expon(Mean_interArrival_Time);//Arriving
Next_Service_Time = expon(Mean_service_Time);
Next_Completion_Time = 1.0e+10; // Completing Guarantening that the first event is arriving
Progres_Arrival_Time=0.0;
Progres_Completion_Time = 0.0;
}
void Timing()
{
Type_Next_Event = 0;
if(Next_Arrival_Time < Next_Completion_Time)
{
Type_Next_Event = 1;
Clock=Next_Arrival_Time;
}
else
{
Type_Next_Event = 2;
Clock = Next_Completion_Time;
}
if (Type_Next_Event == 0)
{
cout<<" Event List Empty at Time: "<<Clock;
exit(1);
}
}
void Arrival()
{
if (Server_Status == BUSY)
{
++Number_in_Queue;
if (Number_in_Queue > Queu_Limit)
{
cout<<" Overflow of the array time_arrival at";
cout<<"time: "<<Clock;
exit(2);
}
Time_Arrival[Number_in_Queue] = Clock;
Service_Time[Number_in_Queue] = Next_Service_Time;
}
else
{
Server_Status = BUSY;
Next_Completion_Time = Clock + Next_Service_Time;
Progres_Arrival_Time = Next_Arrival_Time;
Progres_Completion_Time = Next_Completion_Time;
}
Next_Arrival_Time = Clock + expon(Mean_interArrival_Time);
Next_Service_Time = expon(Mean_service_Time);
}
void Completition()
{
double Delay;
++Num_Completed_Customers;
Total_Flow_Time+= ( Progres_Completion_Time - Progres_Arrival_Time );
if (Number_in_Queue == 0)
{
Server_Status= IDLE;
Next_Completion_Time = 1.0e+10; // High Value
}
else
{
if(choice==2)
Search_Min(Time_Arrival,Service_Time); // Minimum Processing Time
Delay= Clock - Time_Arrival[1];
Waiting_Time+= Delay;
Next_Completion_Time = Clock + Service_Time[1];
Progres_Arrival_Time = Time_Arrival[1];
Progres_Completion_Time = Next_Completion_Time;
--Number_in_Queue;
for (int i=1;i<=Number_in_Queue;i++)
{
Time_Arrival[i] = Time_Arrival[i + 1];
Service_Time[i] = Service_Time[i + 1];
}
}
}
void Search_Min(double A_time[],double S_time[])
{
int Min=1;
double tem;
for(int i=1;i<Number_in_Queue;i++)
if(S_time[Min]>S_time[i+1])
Min=i+1;
tem=S_time[1];
S_time[1]=S_time[Min];
S_time[Min]=tem;
tem=A_time[1];
A_time[1]=A_time[Min];
A_time[Min]=tem;
}
float expon(float mean)
{
return (-mean * log(lcgrand(1)));
}