Otmane El Rhazi

发布时间:2026年11月4日

Introduction

Introduction

In many life situations, there exist queues with different behaviors. The purpose of this paper is to model those queues. These queues are prevalent in several areas. Not only, in the daily life in the administrative branches, or in the banks, but also in computer science and in telephone networks. The sharing of resources via a server, and the stream of commands to the level of the microprocessor or the management of telephone calls are all models for the queue. The present paper is divided into three parts: a basic theory part, an implementation part and a development of the code which will enable us to get some results.

The simulation are based on the following model:

  • The durations between two successive arrivals are independent random variables of the same law: exponential of parameter λ(ε) that will be designated by M (for Markov).
  • The time of service at the counters are independent variables and of same law: This law is taken exponential in the first place and bimodal in second place noted G. The bimodal case allows to model the possibility of lengthy queries and short ones.
  • A single server will be taken.
  • Different strategies of service of customers in the queue will be addressed:
  • First in first out (FIFO) the more natural one!
  • LIFO (last in, first out).
  • SIRO (service in random order) or the next customer is taken randomly in the queue,
  • PS (Processor sharing)
  • LIFOpreemp (LIFO pre-emptive strike) or the current service is interrupted to immediately take in the new customer arrived.

 

This work has been published in Academia. If you use data sets provided or refer to the model, please cite:

@article{QTS2013,
  title = {Queuing theory and simulation - Otmane El Rhazi (2013)},
  author = {Otmane El Rhazi},
  year = {2013},
  doi = {http://www.academia.edu/10163145/Queuing_theory_and_simulation_-_Otmane_El_Rhazi_2013_},
  note = {Multitask Optimization},
  researchr = {http://researchr.org/publication/QTS2013},
}

The full paper can be viewed here [Otmane El Rhazi's Publication].

Simulation Model

Simulation Model

To simulate the chains M/M/1 and M/G/1, or the two notation that have been explained previously, we must simulate two laws:

��

1.1 The exponential law ��(��)

The exponential law of a parameter �� is simulated by the dual function va1 (double l).�� We used to this end the result of probability. U being a random variable of uniform law on [0, 1]


1.2 The bimodal law

A random variable following this law takes two kinds of values, to simulate periods of short and long past over the counter according to the client's request. The density of this law has been taken equal to:


where �� is a normalization constant, �� is the parameter of the exponential and s represents an order of magnitude of the lengthy queries (requete_longue).

The function that simulates this law is double va2 (double l). To simulate this law, the following theoretical result was used:

��

  • X random variable density equal to p
  • U random variable of uniform law on [0, 1]


The following figures represented the histograms generated by these two functions va1 and va2. Note the conformity of the histogram with the exponential laws of va1 and bimodal of va2.

Coding Approach

Coding Approach

We recall that the strategies involved to designate what client serve -and when(LIFO Preemp)- among the crowd of customers in the queue.


2.1 FIFO (First In First Out)

To implement the FIFO strategy a stack INTVECTOR st is taken into account. This stack contains (at each moment) all clients who are in the queue except the one who is at the counter. The number j is designated by the variable ds_guichet.


Each time a new client n arrives in the queue, its number -his rank in the queue, the customers being stowed in an ascending order of their time of arrival- is added to the end of the queue by the instruction st.push_back(n).  The empty variable is then set to 0 empty = 0 to indicate that the stack is not empty. Each time a client leaves the queue, the top customer in the queue can then be directed into the counter-strategy FIFO which expressed by the following statement:

  • j=st.front() ; the highest element in the stack
  • st.erase(begin()) ; the client leaves the stack
  • ds_guichet=j ; the variable ds_guichet is redefined

 

2.2 LIFO (Last In, First Out)

The same variables that previously were taken with the same definitions are also used here. Each time a new client n arrives in the queue, its number is added to the end of the queue by the instruction st.push_back(n). The empty variable is then set to 0 empty = 0 to indicate that the stack is not empty. Each time a client leaves the queue, the last customer in the queue can then be directed into the counter-strategy LIFO which expressed by the following statement:

  • j=st.back( ); the lowest element in the stack
  • st.erase(st.end( ))-1 ; the client leaves the stack, the last element is deleted
  • ds_guichet=j ; the variable ds_guichet is redefined

 

2.3 SIRO (Service In Random Order)

The same variables that previously are taken with the same definitions are also used here. This strategy involves a new function void shaker(INTVECTOR &s) whose role is to randomly swap the elements of the queue. The top item in the stack will be random. In each new arrival, the newcomer is added at the end of the queue by the instruction st.push_back(n).  Similarly, as previously, the empty variable is set to 0. In each departure of a customer, when his treatment is completed, a new customer will then randomly taken -strategy SIRO- in the queue to go to the ticket counter. This is expressed by these commands:

 

  • shaker(st) ; random permutation of the elements of the stack
  • j=st.front() ; the highest element of the stack is taken
  • st.erase(st.begin()) ; this element is removed from the stack
  • ds_guichet=j ; the variable ds_guichet is redefined

 

2.4 Ps (Processor Sharing)

This strategy is a bit unusual in the sense that all requests are processed at the same time. The explanation of this strategy encroaches on the algorithmic part of the next part which will therefore be more concise.


The variables used are:

  • A table int st[N] containing customers
  • Size variable to measure the number of customers in the queue
  • A table RESTE_A_TRAITER containing the wait times
  • Remaining for each clients ; the queries being processed at the same time.
  • Next to designate what client exit the queue.

In each arrival of a new client, its number is stored in st st[size] =n, the size of the queue increases, size=size 1, the time remaining to him is given by RESTE_A_TRAITER[n] =Va2 (mu). The empty variable is, as previously, upgrade to 0 empty = 0. The next customer who will leave the queue is the one whose box RESTE_A_TRAITER[n] is minimal. Moreover, the variable next is such that RESTE_A_TRAITER[next] is minimum. In each departure of a customer, the element RESTE_A_TRAITER[next] is crushed by RESTE_A_TRAITER[size] and the variable size is decremented size= size -1 ;. the variable next is then recalculated according to the same principle.


2.5 LIFOpremp (LIFO pre-emptive strike)

The principle of strategy is to serve immediately the newcomer by interrupting the processing of the current request.

The variables used are:

  • INTVECTOR st (the same defined previously for FIFO)
  • A table RESTE_A_TRAITER
  • A varibale ds_guichet (the same defined previously)

In each arrival of a new client, the one at the ticket counter is sent to the queue st.push_back(ds_guichet).  The remaining time to satisfy his request is logged RESTE_A_TRAITER[ds_guichet].  The variable ds_guichet is initialized to n the number of the last client arrival. Finally empty = 0 to indicate that the stack is not empty.

In each departure of a customer, the last client returned sees the treatment of its query resume which expressed by:

  • j=st.back( ); the lowest element in the stack, the last returned
  • st.erase(st.end( )-1); the client leaves the stack
  • ds_guichet=j ; the variable ds_guichet is redefined

 

C/C++ Algorithms

C/C++ Algorithms

The purpose of this algorithm is to return a history of events which take place between the moment 0 of departure and a time T corresponding to the passage of N client by the service. The events are, the arrivals and departures of the customers. The history must include the moment of arrival, departure, the waiting time in the queue before the beginning of the processing of the request and the duration of treatment for each client. These data will allow then to calculate averages and make comments on each type of queue characterized by its strategy and its laws.


In practice, the historical data are taken after a moment corresponding to the passage of 1000 clients since the initial moment and before the moment after which will 100 in the queue. This is to help to stabilize the system in a stationary speed. These two moments are expressed respectively by the variables heats and cools. The historical data are then stored in a file res.txt. The history is defined by four tables:

  • Arrival to store the moment of arrival of each client.
  • DUREE_TRAITEMENT to store the duration of the processing of the query.
  • OUTPUT to store the time of output of the customers at the counter.
  • TREATMENT to store the moment of the beginning of treatment, this variable is unused for the queues PS and LIFOpreemp.

The flow time is simulated by three variables:

  • time the current time since the first arrival of a customer.
  • t the time between the moment current (time) of the arrival of the next customer.
  • u the time between the moment the current departure next to a client.

The variable t follows, throughout the algorithm, an exponential law. On the other hand u follows, in the first case, an exponential law and, in the second case, a bimodal law. These two variables therefore indicate the closest event. In effect t ≤ u designates an arrival then that t ≥ u designates a departure. The time variable time is accordingly corrected for each event, it is in other words to a sum of several t and u scenarios.

If the nearest event is an arrival of a customer n then:

  • The time variable is corrected: time = time t ;.
  • By definition of u: u = u -t ;.
  • The moment of arrival is recorded in the table ARRIVAL: ARRIVAL[n] =time ;.
  • By definition of t: t= va1 (λ)

If the event the nearest is an output from a client n then:

  • The time variable is corrected: time = time u ;.
  • By definition of t: t = t - u ;.
  • The moment of departure is recorded in the table OUTPUT: OUTPUT[ds_guichet] =time ;

The next customer j -if the queue is not empty- is taken according to the logic and the algorithm explained in the previous section:

  • By definition of u: u= va2 (mu).
  • DUREE_TRAITEMENT[j]= u ;.
  • If the queue is empty empty = 1 ;.

If the queue is empty the choice step (previous section) is skipped. It goes directly to the next arrival and the customer is directly supported.

Author's Reference


Reference

  • Otmane El Rhazi. Multi-Task Optimisation: Queuing theory and Efficient simulation. [PDF]


Biography

Otmane El Rhazi is formerly a programmer and a theoretician with an uptrend in algebra. He has been using TeX since 1999, and managed to write his Ph.D. thesis using it. He works with analytic number theory, and always had the spot for real analysis, complex functions, and combinatory theorems. Schoolwork and use of dynamic sets, particularly involving notions of random excursion and fractal dimensions. Most of those skills lay in areas useful to finance such as econometrics, statistics, complex analysis, differential equations, and data analysis.

Former engineer and researcher, Otmane El Rhazi is always seeking to expand his math skills. While working, El Rhazi ensures that excellent results are produced, regardless of the task at hand. Beyond the simple production of results, El Rhazi questionings also his team-mates to check and see the process carried out. It is a way to find precise actions that could be improved in order to streamline the process and make it more effective strategy. He created seamless processes that were undeniably close to genius and continue to be used in many companies.

He has also written more than 100 technical papers and slides on both theoretical and experimental projects and topics. El Rhazi has been represented frequently in publications such as the SSRN (Social Science Research Network), CCSD (Centre pour la Communication Scientifique Directe). Where Otmane El Rhazi published his Thesis and most of his memoirs. While in school, he didn���?�?t just meet goals; he exceeded them year in and year out and now he shares what he can in his publications for others to shine too.

His interest in software building Stack Exchange stems from a profound interest in Java and assembler and his many years of role-playing in programs that he and his friends have individually or collaboratively built. Otmane has gone from scribbling demo hello program using Microsoft Visual Studio fifteen years ago and he is now implementing much difficult interactive AI software and real-time emulation of global scenarios.