A Method for Modeling and Simulation of Lossy Queuing System

 Abstract: Queuing is a common phenomenon in daily life. The theory of queuing provides theoretical basis and optimization scheme for queuing in real life. However, due to the limitation of time and space, the queuing problem in real life is not an ideal queuing model, and the field verification of the queuing model with losses consumes a lot of manpower, material resources and financial resources. In this paper, a queuing model with loss mechanism was established by using color Petri net. One-dimensional random walk model was improved and introduced into the queuing system to further reveal the principle of loss in queuing. CPN tools were used to simulate the model. By comparing the experimental results with the actual results, the correctness of the model is proved, which fully indicates that the model can well explain the loss of queuing system in real life.


Introduction
Queuing means that the served objects are linearly arranged at the request of the service organization. Queuing is a common phenomenon in the real life. Queuing theory provides theoretical basis and optimization scheme for queuing phenomenon in real life. Although queuing theory is a subdiscipline of mathematical operations research, it is often used in computer systems, routing performance analysis, national economy, management operations research and other fields [1][2]. The problem of queuing arises from the study of telephone communication. As early as 1909, Erlang, a Danish mathematician and electrical engineer, took the lead in putting forward the queuing problem and derived Erlang loss formula [3], which provided a theoretical basis for the study of queuing system. In 1917, Erlang studied the Poisson-type input and exponential call time telephone system [4]. In 1917, he proposed the Poisson-type input and fixed call time single-line telephone system [5]. On this basis, Pollaczek studied the queuing system of single-service mechanism and multi-service mechanism, and at the same time, Khinchim based on 1 College of Information and Electrical Engineering China Agricultural University, Beijing, 10083, China mathematical theory said that queuing theory was more systematic [6], which promoted the further development of queuing theory. In the 1950s, Kendal DG, a famous British mathematician, put forward the embedded Markov chain theory [7][8], which laid a theoretical foundation for the study of queuing theory. After World War II, queuing theory has been gradually applied to economic, military, transportation and other fields. In 1965, Scherr first realized the application of queuing model to computer system [9]. With the increasing complexity of practical problems, in order to study the need for scholars to subdivide the queuing system, a series of queuing models are proposed. L. Levy [10], O. Kella [11] and others studied the M/G/1 queuing model; Yechiali and Alman studied the M/M/C queuing system with loss mechanism [12]; H. C. White and L. S. Christie [13] first discussed the repairable queuing system of M/M/1. Queuing system has a variety of model systems. Generally, a queuing system consists of three important determinants [14]: arrival mode, service mechanism and queuing rules.
(1) Arrival mode: refers to the rule of job arrival, which is generally described by time interval characteristics; (2) Service mechanism: refers to how many service desks are serving at the same time, and what rules exist in the service time; (3) Queuing rule: refers to how to select the next job from the queue when the service mechanism completes the current job. As the demand of activity and service mechanism increases, we must consider more factors such as waiting time of activity, operating cost of service desk and working efficiency of service mechanism. So it is difficult to solve this problem by traditional mathematical and statistical methods, so we need to use computer imitation. Real software establishes a suitable model, and combines with the actual situation to analyze the model, so as to solve the actual needs and problems. In 2009, Hedayati simulated the LAN of network environment based on queuing theory [15]. Xuyao established a comparative model based on queuing theory to select the optimal resource allocation scheme by using Arena 7.0 software in 2012. In the same period, Wang G simulated the average number of faults and the average ·3· waiting time of the equipment by using MATLAB 7.1 programming based on queuing theory [17]. In 2014, Karim B M used Arena 12 and four scenarios to optimize the management of outpatient pharmacies studied [18]. Lossless queuing system has always been a hot topic in queuing system research. Because the loss is caused by many reasons, the loss rate and other parameters are usually given by the scheme of after-the-fact statistics. In this paper, the queuing system with loss is modeled and analyzed by color petri net. In the process of modeling, the random walk model is introduced, which further indicates the reason of queuing system loss. This paper studies the lossy queuing system, introduces the random walk theory into the queuing system, builds a lossy queuing system model, and describes the thinking mechanism of customer loss in queuing phenomenon and further explains the phenomenon of loss. On this basis, the monitor monitor is used to monitor the dynamic changes of the tracking network Data Collector collects time Data and token number to verify the correctness of the model. The main work of this paper is as follows: (1) Proposed an improved one-dimensional random walk model; (2) Introduced the random walk model into the queuing system； (3) simulated and analyzes the queuing system with loss. If your paper is intended for a conference, please contact your conference editor concerning acceptable word processor formats for your particular conference.

The queuing model with customer churn
The master-slave control is widely employed in the robot manipulation. In most cases, the joystick or the keyboard is the routine input device for the robot master-slave control system. The system presented in this paper is shown in Figure 1.
In an ideal situation, the waiting time and system capacity of queuing theory are infinite and there is no problem of job loss, however, space and time are limited in real life, therefore, a queuing model with losing customers has been proposed. In the case of a finite waiting space (a high-load model), literature [31][32] study the main indexes of queuing theory by using vector Markov process. For a limited wait time situation (with a customer leaving the queuing system because of a long wait time, this customer is called an "impatient" customer), literature [33][34] study customers whose term ends at the beginning of service. Palm [36] introduces impatient customers into the queuing system, Barrer [37] analyzed the model of M/M/1+D, for the M/M/1+D, Brodi [38][39] proposed ntegro-differential equation. This paper will analyze from two aspects: time limitation and space limitation.
(1) Time limitation: When there is only one waiting queue, the waiting space is infinite and the waiting time is limited, the arrival of customers is independent of each other, and it obeys the poisson distribution, service time follows exponential distribution, the whole system obeys the service rule of first come first serve. The model structure of the queuing system is shown in figure 1.

Figure 1 A single desk churn queuing model with "impatient" customers
For impatient customers, generally, there are two kinds of situations: "conscious" customers and "unconscious" customers, the article only discusses unconscious customers. "Unconscious" customers are divided into two models: at the beginning of service and at the end of service. This paper analyzes the latter, that is, if the customer fails to receive the service within the waiting period, he/she will choose to leave the queuing system and not return, and if he/she receives the service within the waiting period, he/she will leave the system until the end of the service.
(2) Space limitation ： When there is only one waiting queue, the waiting time is infinite and the waiting space is limited, the arrival of customers is independent of each other, and it obeys the poisson distribution, service time follows exponential distribute-on, the whole system obeys the service rule of first come first serve. The model structure of the queuing system is shown in figure 2.

Figure 2
A queuing model for high load single order service desk churn In this case, assume that the maximum capacity of the system is K, that is, there are at most K people queuing at the same time, so there are three kinds of customer arrival situations: I The service desk is in an idle state and the system is empty, so customers can serve directly. II The service desk is in a busy state, the system is not empty, customers wait in line; Queue Arrive Server Loss Leave Arrive Loss Queue Server Leave III The number of people waiting in line has reached the maximum capacity K, and customers are blocked due to limited waiting space, resulting in customer loss.

The model of single service station losing queuing with impatient customers
The model of single service station losing queuing with impatient customers increases the expected waiting time of customers based on the ideal model. When the customer's waiting time is less than or equal to the expected time, the customer will accept the service after waiting successfully. When the customer's waiting time is greater than the expected time, the customer will leave the queuing system without returning. When the customer's waiting time obeys the fixed length distribution, the customer loss rate is Where ρ is the service intensity of the system, T is the waiting time of the ideal queuing system when the time is unlimited, t is the impatience of the customer to wait for a long time. Set the waiting time period of customers as η, proability distribution: Where Fη(0)=0,the expectations of customers waiting and service time and arrival time are mutually independent random distribution, the probability of customer waiting time more than η is Where Pn is the customer`s loss rate, Mn (t, Φ) represents the situation where there are n customers in the system at time t.

The basic theory of Petri nets
Petri net is a formal model to describe concurrent system [19], which was first proposed by Carl Adam Petri, a German scientist, in 1962 [20]. In honor of his contributions to asynchronous concurrent systems, the model was named after him. Petri net can intuitively analyze the static characteristics of the concurrent system by means of reachability graph or reachable matrix and dynamic behavior properties [21]. Its boundedness, activity, safety and other characteristics can better analyze the system and improve the accuracy of the system. A generalized Petri net structure [22] is written by a triple Σ = (P, T, F), A simple Petri net structure is shown in figure 3, where P∩T= ∅ and PT≠∅;P is called place ofΣ,T is called transition of Σ, P is a finite set of places, T is a finite set of transitions.
(2) F⊆ (P×T) ∪ (T×P)；F represents the flow relationship of the network, represented by arc, the arrow points to the transition from the places or from the transition to the places. Figure 1 shows a simple Petri net structure diagram. P1, P2 and P3 are places nodes,T1 and T2 are transitions, and the black dots in P1 are tokens. A Petri net system [22] is defined as: PΣ=(P,T,F,K,W,M0),where：P={P1,P2,P3, …Pm} It is a finite set of places ； T={T1,T2,T3, …Tm} It is a finite set of transitions；F⊆(P×T)∪(T×P)It is a set of directed arcs.； K:P → Σ ∪ {ω} It is the places capacity function ； W:F → {1,2,3…} It is the weight function； M0: It is the initial marking.

A timed Colored Petri Net
In time Petri Net, timing information is added with colorful Petri Net, which made it possible to build and verify real time system [23]. Moreover, queue length and waiting time and other performances could be calculated by using A timed Petri Net. A timed Colored Petri Net is a nine-tuple CPNT = (P, T, A, Σ, V, C, G, E, I) where: P is a finite set of places. T is a finite set of transitions such that P∩T = ∅. A⊆P×T∪T×P is a set of directed arcs. Σ is a finite set of non-empty color sets. Each color set is either untimed or timed. V is a finite set of typed variables such that Type[v]∈ Σ for all variables v∈V.C: P→ Σ is a color set function that assigns a color set to each place. A place p is timed if C(p) is timed, otherwise p is untimed. G: T →EXPRV is a guard function that assigns a guard to each transition such that Type[G(t)]=Bool. E: A→EXPRV is an arc expression function that assigns an arc expression to each arc a such that Type[

Cpn Tools
Petri nets have a variety of editing and analysis tools [24][25], Cpn Tools [26][27][28][29][30] is a tool for editing, simulating and analyzing colored Petri nets, This tool can analyze the complete and partial state space and facilitate automatic simulation of Petri nets. Cpn Tools is a widely used Petri Net simulation tool, which supports not only the modeling based on Colored Petri Net, but also the temporal and hierarchical Colored Petri Net.

P1
T1 P2 P3 T1 Cpn Tools uses Cpn ML as the programming language, Simple and complex color sets make modeling easier, the use of monitor, state space analysis and so on can effectively solve the problem of combinatorial explosion, substitution changes and fusion library make the model more hierarchical, the interrupt monitor, data collection monitor, write file monitor, and custom monitor effectively track the dynamic changes in the model, The state space is used to verify the model and analyze a series of properties such as boundedness, activity and reachability.

One Dimensional Random Walk Model
The random walk theory was first proposed by Karl Pearson, A walker starts from a vertex s in the connected graph and walks along an edge of point s to the point e with a certain probability. This process is called random walk, and the walking formula can be expressed as Where, V represents the set of fixed points of the connected graph, E represents the set of edges of the connected graph, {V, E} represents an edge of the connected graph, E represents the vertex to be reached, and PE represents the probability of reaching point E.
The classic one-dimensional random walk model is shown in figure 4. The initial position of the walker is s, and the position of point 0. The probability of each step to choose left or right is 0.5, and the probability transfer matrix is shown in figure 5.

Figure 4
One dimensional random walk model

Queuing System Simulation Framework
The queuing system is mainly composed of three parts: arrival, queuing and service. Its schematic diagram is shown in figure  6.

Figure 6
A schematic of the queuing system In the figures, arrivals meant arrival of customers, and Queue meant queuing mechanism, the server represents the service mechanism，The queuing system with loss is also composed of three parts, but the loss of customers is caused by the presence of impatient customers. The schematic diagram is shown in figure 7.

Figure 7 schematic of a queuing system with losses
Loss is the loss of a customer in the line, The percentage of customers who lose money is called the loss rate. However, it is random whether customers lose or not, and it is also random whether customers are impatient or not. In this paper, the relationship between the three is shown in figure 8.

Figure 8 Inclusion relation
1 is for arriving customers, 2 is for impatient customers, 3 is for losing customers, According to field investigation and analysis, the probability of impatient customers is about 10%. And the probability of losing impatient customers cannot be estimated. In this paper, stochastic theory is introduced into queuing to estimate the loss rate of the system. The state transition diagram based on the one-dimensional random walk theory in section IV is shown in figure 9. {-4,-3,-2,-1, 1,2,3,4} represent 9 different states. The probability of transition between each two states is 0.5, and {0} is the initial state. When the customer is in the state of {0}, the probability of the next state being 1 is 0.5, and the probability of the next state being -1 is 0.5. And the probability of impatient customer state change in the queuing system will change with the change of state, In this paper, the probability of state transition is set as 1/n. N represents the number of transitions needed from the initial state 0 to the current state. The initial state of impatient customers is {0}, and the positive and negative states indicate that impatient customers mentally choose to queue or leave. In this paper, positive Numbers represent impatient customers' choice of queuing in mind, while negative Numbers represent impatient customers' choice of leaving in mind. The value of a state represents the number of transitions from the initial state to that state. In the first thinking, the probability of impatient customers changing from state {0} to state {1} is 0.5, and the probability of impatient customers changing from state {0} to state {-1} is 0.5. In the second thinking, the probability of impatient customers changing from state {-1} to state {-2} is 0.75, and the probability of impatient customers changing from state {-1} to state {0} is 0.25. Impatient customers choose to leave in the first thinking will increase the probability of leaving in the second thinking. In the third thinking, the probability of impatient customers changing from state {-2} to state {-3} is 0.875, and the probability of impatient customers changing from state {-2} to state {-1} is 0.128. In the fourth thinking, the probability of impatient customers changing from state {-4} to state {-4} is 0.9375>0.9, at this time, impatient customers are considered to be losing customers. The Petri net model is shown in figure 10. When impatient customers choose to leave four times, it is called the loss of customers in the system. When impatient customers choose to stay in the queue, they will not consider it any more.

Figure 10
Queuing system model with loss

Experiment And Test Analysis
The simulation of CPN tools is mainly implemented through Monitor, with which we can easily extract data from the model without complex function writing. Monitor refers to arrive during the simulation run from mark and enable the binding of data collection, the size of the tag Monitor collection libraries on the number of tokens, data collect Monitor data collected from the binding. A Monitor consists of two parts, the predicate functions and observation. The predicate function determines under what circumstances should Start collecting data, the Start of the observation function depends on the predicate function, when the predicate function value is true, observe what function decided to collect data. The Start function is used to collect data from initial tag, the stop function is used to gather data from the simulation at the end of the reach of editing, Several monitors in the figure enable dynamic monitoring of queue system performance metrics such as queue latency, queue length, and service mechanism utilization. In this paper, P1 represents the probability of impatient customers, P2 represents the probability of losing impatient customers, N represents the number of lost customers, and L represents the loss rate of the system. The relation between N and P1 when P2=0.5 is obtained through simulation, as shown in figure 11. The horizontal coordinate represents different values of P1, while the vertical coordinate represents changes of N when P1 is different. When P1=0.9, the relationship between N and P2 is shown in figure 12. The horizontal coordinate represents different values of P2, while the vertical coordinate represents changes of N when P2 is different. When the improved random theory is introduced into the queuing system, the changes of N in different consideration states are shown in figure 13. The horizontal coordinate represents different thinking states, the vertical coordinate represents the changes of N in different thinking states, and different colors represent different number of customers.

Figure 11
The relationship between the number of customers lost and the probability of impatient customers

Figure 12
The number of customers lost in different states Under different conditions, the comparison between simulation results and calculated results is as shown in 14,15 and 16. Figure 14 shows the change of L with P1 when P2=0.5. The abscissa represents different P1, the ordinate represents L, "caculate" represents computational results, and "simulate "represents simulation results. Figure 15 shows P1=0.5, and L changes with P2. The abscissa represents different P2, the ordinate represents L, "caculate" represents computational results, and "simulate" represents simulation results. Figure16 shows the changes of L considering different states when the improved stochastic theory is introduced to the queuing system. The abscess coordinate represents different states, the ordinate coordinate represents L, "caculate" represents computational results, and "simulate" represents simulation results.

Figure 13
The number of customers lost in different states

Figure 14
Loss rate based on different probability of impatient customers

Figure 15
Loss rate based on different probability of impatient customers As shown in figure 14, 15 and 16, the loss rate of the model proposed in this paper is close to the calculated result, which can be used to simulate the queuing loss in real life, proving the correctness of the system and its practical significance.

Conclusion
In this paper, A Petri Net model with displaced customers is proposed by using an expanded Petri Net and the onedimensional random walk theory is introduced into queuing theory. The accuracy of the model is verified by experiments, and the phenomenon of customer loss in the exhaust roller system is better explained. The advantages of Cpn Tools in simulation by using the timed Petri Net are as follows: All kinds of queuing models can be improved on the basis of rational model without changing the abstract model of the system. For different jobs and different data types, only the color set of the model needs to be changed to facilitate different fields of application. The classical calculation method can only study the queuing system under the steady state, but there are various unstable situations in life. Based on the above-mentioned advantages, the timed Petri Net model and Cpn Tools can more conveniently and accurately abstract and simulate the facts, and can be used to build the more complete queuing system in the future.