Poisson ratio function
Q.12 Customers calls arrive at a software support center with exponentially distributed inter arrival times with an average time between arrivals of 15 minutes What is the
4. Graphic Simulation Language GSL
6.6 Case Study
A multi-channel queuing system-Active Customer approach
Figure 2 shows the system being simulated. It is an abstraction of for example a bank where the customers wait in one queue for any of the tellers. The interval between arrivals is random, uniformly distributed between 1 to 3 minutes. All servers have the
same random service time that is normally distributed with the mean value 8 minutes and the standard deviation 2 minutes. The simulation should find the average time a customer spends in the system. Simulation of similar systems in Simula (exactly in the system class Simulation of Simula) always starts by identification of processes. One process is obviously the generator of customers - it will repeatedly generate a customer, record its arrival time, and wait a random delay. To express the dynamics of the system, there are two logical approaches. First (used in this example) is based on active customers and passive servers. The opposite approach - active servers, passive customers is shown in the next example. An active customer has life rules represented by the following steps:
If there is a free server, proceed. Wait in the queue otherwise. Seize a server; generate random delay that represents the service time. Release the server.
If there is a waiting customer (if the queue is not empty), remove it from the queue and activate it. (The activated customer will start its step 2.)
Update statistics. G e n e ra to r O f c u s to m e rs S e rv e rs Q u e u e
Figure 2: Queuing system made of one queue and more servers.
The following program is a simulation model of the above system. Note, that the primary objective was to show the logic of the model in a program as simple as possible. Real simulation models of course prompt for all variable parameters and provide more results (like for example average and maximum queue length, etc). In the following program there are two processes that exist during the whole experiment: the generator and the main program (block prefixed by Simulation), that just waits until the experiment is over and then displays the result. Then there are a varying number of customer processes that exist temporarily. After updating statistics the customers terminate. Note the use of standard functions to generate random delays. There are standard functions in Simula for most commonly used distributions. All are given an integer variable as a seed to be used by the random generator. So all random values may use separate streams of random numbers or share a common one.
! Active customer approach; Simulation Begin
Real TrialDuration; ! Experiment length [min]; Ref(Head) Queue; ! The queue;
Integer Servers; ! Total number of servers; Integer BusyServers; ! Numbers of working servers;
Integer TrialSeedG, TrialSeedS; ! Seeds of random generators; Long Real TotalTime, TimeSpent; ! Variables for statistics; Integer CustomersOut; ! Number of served customers;
Real MinInt, MaxInt; ! Uniform interval between arrivals; Real SMean, SStd; ! Normal service duration;
Begin
While true do begin
Activate New Customer(Time); ! Time is the current (arrival) time; ! Interval between arrivals: ;
Hold(Uniform(MinInt, MaxInt, TrialSeedG)); End While;
End of Generator;
Process Class Customer(Arrival); Real Arrival; Begin
Ref(Customer) Next;
If not Queue.Empty or (BusyServers >= Servers) then
Wait(Queue); ! Customer has to wait in the Queue;
! Service can start: ;
BusyServers := BusyServers + 1; ! Seize a server; ! This is the teller service: ;
Hold(Normal(SMean, SStd, TrialSeedS));
BusyServers := BusyServers - 1; ! Release the server; If not Queue.Empty then begin
Next :- Queue.First;
Next.Out; ! First from Queue served; Activate Next after Current;
End If;
CustomersOut := CustomersOut + 1; ! Statistics; TotalTime := TotalTime + (Time - Arrival);
End of Customer; ! MAIN program body: ;
TrialSeedG := 7; TrialSeedS := 23; ! Seeds for random variables; MinInt := 1; MaxInt := 3; ! Min and Max intervals; SMean := 8; SStd := 2; ! Random normal servers; OutText("Enter the number of Servers : "); OutImage;
Servers := InInt; ! Initial numbers;
TrialDuration := 600; ! Other variables initialized to 0; Queue :- New Head; ! Create an empty queue;
Activate New Generator; ! This starts the experiment; Hold(TrialDuration); ! Experiment duration; TimeSpent := TotalTime/CustomersOut;
OutText("Average time spent in the system: "); OutFix(TimeSpent, 3, 10); OutImage;
InImage End of program;
6.7 Case Study II
The system being simulated is the same, as in the previous example (refer Figure 2). The difference is the active server that repeatedly serves customers from the queue until the queue is empty. Then the server passivate . Customers at first activate all idle servers (if any) and then go into the queue. This is of course not very efficient, but simple. Servers activate customers after completing the service. In the rest of their lives the customers just update statistics. The main program creates and activates all servers, but they immediately passivate, because the queue is empty. Then the main program activates the generator and waits until the experiment is over.
! Active server approach; Simulation Begin
Real TrialDuration; ! Experiment length [min]; Ref(Head) Queue; ! The queue;
Integer Servers; ! Total number of servers; Integer TrialSeedG, TrialSeedS; ! Seeds of random generators; Long Real TotalTime, TimeSpent; ! Variables for statistics; Integer CustomersOut; ! Number of served customers; Real MinInt, MaxInt; ! Uniform interval between arrivals; Real SMean, SStd; ! Normal service duration;
Ref(Server) Array ServBank(1:10); ! Max. Number of servers is 10; Integer i;
Process Class Generator; Begin
While true do begin
Activate New Customer(Time); ! Interval between arrivals: ;
Hold(Uniform(MinInt, MaxInt, TrialSeedG)); End While;
End of Generator; Process Class Server; Begin
Ref(Customer) ServedOne; While true do
If not Queue.Empty then begin ServedOne :- Queue.First;
ServedOne.Out; ! First from Queue served; Hold(Normal(SMean, SStd, TrialSeedS));
Activate ServedOne after Current end
Else Passivate; End of Server;
Process Class Customer(Arrival); Real Arrival; Begin
For i:=1 step 1 until Servers do If ServBank(i).Idle then
Wait(Queue);
! Service finished: ;
CustomersOut := CustomersOut + 1; ! Statistics; TotalTime := TotalTime + Time - Arrival; End of Customer;
! MAIN program body: ;
TrialSeedG := 7; TrialSeedS := 23; ! Seeds for random variables; MinInt := 1; MaxInt := 3; ! Min and Max intervals; SMean := 8; SStd := 2; ! Random normal servers; OutText("Enter the number of Servers : "); OutImage;
Servers := InInt; ! Initial numbers; TrialDuration := 600;
Queue :- New Head;
For i:=1 step 1 until Servers do begin ServBank(i) :- New Server;
Activate ServBank(i) ! Create and activate all servers; End For;
Activate New Generator; ! This starts the experiment; Hold(TrialDuration); ! Experiment duration; TimeSpent := TotalTime / CustomersOut;
OutText("Average time spent in the system: "); OutFix(TimeSpent, 3, 10); OutImage;
InImage End of program;