Good Friday dear readers Habr.
In this post, I suggest you briefly familiarize yourself with the possibility of creating a simulation model of processes in the GPSS-WORLD program. This post cannot be considered a full-fledged tutorial, but I will share with you those bits that I know and it is quite possible that within half an hour after reading the article, you will show imagination and create your own simulation model. As they say: "It is difficult to learn easily in battle."
And even in some places, this "tutorial" adheres to the principle: "a broken one is not lucky," but I still bring to you the knowledge that I have, well, and you are free to decide whether to trust me or check it. In any case, I will be happy to audit the code from GPSS-WORLD experts. All the articles are posted on
GItHub.We will study the very basics at once on living examples - available, understandable and close to the heart of many employees who spend their legal 8 hours in offices.
From specifics, let's move on to the lyrics, Friday traditionally has to ask crazy questions, and this time my colleague
DrZugrik and I asked ourselves the question: “How many support staff employees are needed to tell how to turn the light bulb on?”
For details of this mental experiment, I ask for cat.
Writing this mini tutorial along with model development took 6 hours of pure time.
I would appreciate if the article gets to potentially interested readers.In order to avoid negative emotions, the original picture was replaced with a cat with a pipe and hidden under the spoiler.

')
First we need the
GPSS-World itself .
We will use the free version for students.
Also, when learning the language of simulation modeling, a textbook will be useful.
You can take this
one .
In my opinion, not very accessible, but better than nothing.
So we stocked the necessary tools, now it remains to connect the imagination and come up with the first model.
I can’t be called the guru of simulation modeling in general and GPSS-World in particular, the basis for the examples given here were the materials from this
book . But I think that compiled models have the right to life.
Let's first consider this case.
Given:
The office in which 10 employees work, Cooler at the end of the corridor to which “squash 4 minutes”, employees who wish to drink tea and make a trip to the cooler once an hour. The time of filling the bowl with a sachet of life-giving moisture is approximately 2 minutes. The working day is 480 minutes (8 hours without a lunch break, so to speak)
Define:
The utilization rate of the cooler office staff.
Create a simulation model
GENERATE ,,,10 ; 1 Amount office staff ADVANCE 4,0.8 ; 2 Time to reach the cooler DRINK QUEUE STAND ; 3 Queue to the cooler. input SEIZE COOLER ; 4 Verification of employment cooler DEPART STAND ; 5 Queue to the cooler. output ADVANCE 2,0.8 ; 6 Filling the cup with boiling water RELEASE COOLER ; 7 leave the cooler ADVANCE 60,10 ; 8 Time for tea, time to work, time to get back to the cooler TRANSFER ,DRINK ; 9 Go back to the cooler GENERATE 480 ; 10 Working day (minutes) TERMINATE 1 ; 11 Minus one minute START 1 ; 12 Start from the first minute
Since I left comments in my broken English, I certainly see the point in detailing the functioning of the model.
Line 1 - GENERATE ,,, 10 - the GENERATE block itself sets the number of incoming requirements (in this case, office staff), the record of the type ,,, 10 operators tells us that the first three parameters are missing, and the fourth parameter indicates the maximum the number of incoming requirements. GENERATE block. You can also set it with other parameters, but I will tell about this a little later.
As you guessed ";" - separates the comment field. A little more about the design of the code design, the code is read from left to right, there are several blocks that it is desirable to separate by tabulation. The leftmost block is a label (similar to the label in other programming languages), then the block itself goes (for example, generate), then its parameters usually go, then comments. Once upon a time we were taught to divide these blocks by tabulation, but this is more a matter of aesthetics. 1 space seems too enough so that everything starts. By the way, where it is written in all BIG letters, it is better to write this, otherwise an error may occur during execution.
Line 2 - ADVANCE 4,0.8; Responsible for the temporal characteristics of the process, so that it is clearer in this case, this means that the worker goes to the cooler 4 minutes ± 0.4 minutes.
Thus, the first digit means the time units spent (iterations), the second digit means half the deviation up or down, the books say that the deviation value is generated randomly, maybe it is, but every restart the system gives the same values ​​(I don’t know there is an analogue of randomize from good old pascal, but I did not find it). The ADVANCE block can also be set with different values, but more on that later.
Line 3 - DRINK QUEUE STAND; - here we meet our first DRINK tag, followed by the QUEUE block, which creates a queue in this queue, we will have everyone who goes to the cooler wet the throat ,. STAND is the queue id.
Line 4 - SEIZE COOLER - the SEIZE block determines whether our device is free, in this case, the device identifier COOLER (well, or just a cooler).
Line 5 DEPART STAND - if the last block gave us a positive result (the cooler is free), then the next block DEPART, which ensures that the person leaves the STAND queue, is triggered.
Line 6 - ADVANCE 2,0.8 people who left the queue will pour about 2 minutes of boiling water into a mug (well, plus they will have time to chat with people in the queue to the cooler)
Line 7 - RELEASE COOLER, having done his “wet” business, the person will release the COOLER device, for the next sufferer.
Line 8 - ADVANCE 60,10 - this block takes into account time. Which person who drank water will spend on gathering his strength and come to the cooler again (at least, I hope that this is what is being modeled).
Line 9 - TRANSFER, DRINK - “And everything will repeat as before,” A. Block would have said if he had been familiar with programming. This operator provides a transition to the DRINK label.
Line 10 - GENERATE 480 would seem to be from the point of view of programming after switching to the label in the last block, everything that lies below does not make sense, but this is not so (and why so, I honestly didn’t understand much, but judging by experience and dropdowns errors, this piece is perceived a little outside the context of the previous 8 blocks). The main thing is that this block gives us the execution time of the entire model, namely 480 minutes (8 hours)
Line 11 - TERMINATE 1 - This side subtracts one from each iteration counter. Without this block, you can go into an infinite loop.
Line 12 - START 1 - Tells the program from which point in the cycle to start, we start from the first minute.
Uh, well, here we are with the description of the first model.
Who are interested in the results, I ask for a spoiler. If you like to check everything yourself then I will remind again all the models posted on
GItHubResults Model 1 - utilization rate of the cooler
analyze the results
So, we see that, on average, our cooler is loaded by 33%, that is, our team of 10 employees turns out as if Administrator Peter constantly applied to it, Maria Vasilyevna from accounting and Project Manager Vasily Chufyrkin, well, another 0.33 people , or for example - a cat. In fact, this block of text does not carry a meaning, I just really wanted to draw a cat and a cooler and Marya Vasilyevna from the accounting department (all but the cat of a person are purely made-up)

Although damn it after I read
it , I can safely say that the cooler could have drunk 12 cute cats =)

But back to the topic.
Let's consider the results of the issue.
Facility is a list of all our working devices, in this case only a cooler.
Entries 79 - means the number of approaches to service the device, in this case the number of people with empty cups was 79 - for the entire shift.
Util is the utilization factor of the equipment. It tells us that the cooler was idle (1-0.33) * 100% = 67% of the total time.
AVE. TIME - average time of use of a cooler by 1 person 2.002 minutes
Avail. - Availability of the cooler, I don’t know what it means, apparently, a unit says that it was available
DELAY = 0 - tells us that the number of people who just came to the cooler, got upset and left empty-handed (mug), is zero.
Now we will move to our queue (QUEUE)
As you can see here is the name of the queue we created earlier,
In which there were a maximum of 9 people, in which there were 79 inputs, and 48 zero inputs (apparently, inputs without waiting in a queue), the average time spent by a person in a queue is 1.5 minutes. Cont. = 0 tells us that at the end of the simulation there was no one in the queue.
Well, everything seems to be not bad, but what will happen if we return to the well-fed 2006
Year and hire another 30 employees in our office?
Results Model 1 - utilization rate of the cooler with 40 employees As can be seen from the model, our cooler will almost cease to stand idle, and the average time in the queue will be as much as 20 minutes, which suggests either that we need a second cooler or that it is time to deprive everyone of the premium for long tea drinking.
Maybe this model is rustic, but even with the manifestation of some fantasy it allows us to estimate the number of coolers that are needed on the floor.
But at the moment we are not yet able to develop multi-channel service models. So let's kill two birds with one stone, learn multi-channel service and at the same time answer questions that a colleague and I asked at the very beginning of the article. (who is attentive and remembers - well done, to that happiness of good and bezpakhmelny weekend :)
When creating a model, call center operators and subscribers, let us set such conditions
Given:
2 technical support operators service users who call twice every minute, if one operator is busy and another handset is on. The working day is 480 minutes (8 hours without a lunch break, so to speak)
Define:
The load factor of support staff.
HELPDESK STORAGE 2 ;1 Number of operators helpdesk ************************************************************************************************** GENERATE 6,3 ;2 The number of subscribers Ticket ADVANCE (Exponential(1,0,2)),, ;3 during dialing ENTER HELPDESK ;4 incoming call TRANSFER ALL,OPR1,OPR2,3 ;5 definition of operator availability OPR1 SEIZE OP1 ;6 Verification of employment operator number 1 ASSIGN 1,OP1 ;7 If the operator is free in this case, accept a call TRANSFER ,COME ;8 Jump to the process of service OPR2 SEIZE OP2 ;9 Verification of employment operator number 1. ASSIGN 1,OP2 ;10 If the operator is free in this case, accept a call COME LEAVE HELPDESK ;11 Beginning the process of providing technical support ADVANCE 10,8 ;12 Service time RELEASE P1 ;13 The release of the operator TERMINATE 0 ;14 Removes the Active Transaction from the simulation GENERATE 480 ;15 Working day (minutes) TERMINATE 1 ;16 Minus one minute START 1 ;17 Start from the first minute
Like last time I will describe line by line
Line 1 - HELPDESK STORAGE 2 - Create a storage unit Support service with a capacity of 2 employees
Line 2 - GENERATE 6.3; So we come to another method of generating the task, in this case, the number 6 means that about 1 call appears every 6 minutes, the number 3 means that deviations from six minutes is ± 1.5 minutes. Another GENERATE block could be set like this.
(Exponential (1,0,6)), generally what is true for ADVANCE, in many respects true for GENERATE.
Line 3 - ADVANCE (Exponential (1,0,2)), - tells us how long the caller takes to remember the phone of those support and dial the number, and it takes us an average of 2 minutes exponentially. number 1 - selects a random number generator (from 1-7 how to work with them, I did not figure it out), figure 0 - determines the offset (while for me is also a mystery), figure 2 is the actual minute. I want to add that there are other laws of distribution, according to which you can specify the time period, but it is better to read about them in the textbook. Which I indicated at the beginning of the article.
Line 4 - ENTER HELPDESK - drive input (incoming call)
Line 5 - TRANSFER ALL, OPR1, OPR2,3 - tells us that this event is processed for all incoming calls (ALL), that processing statements begin with the OPR1 label and move in 3 block steps until they reach the OPR2 label
Line 6 - OPR1 SEIZE OP1 - this is also our first label, on which the employment of the first support service operator (OP1) is checked
Line 7 - ASSIGN 1, OP1 - In case operator 1 is free. Then we pass the incoming call to him, if not, then after three lines (from the 6th) we go to line 9
Line 8 - TRANSFER, COME - there is no need to learn about the employment of the second operator, go to the label COME
Line 9 OPR2 SEIZE OP2 - if the first statement was busy, check the second
Line 10 - - ASSIGN 1, OP2 - and give him a call.
Line 11 - COME LEAVE HELPDESK - the call leaves the support services drive
Line 12 - ADVANCE 10.8 - the time that the operator spends on it to give a person advice on how to properly twist the light bulb.
Line 13 - RELEASE P1; - the operator helped the man and was released. P1 in this case is a link to a pointer (or parameter), I can not explain this moment, but it works.
Line 14 - TERMINATE - (zero can not be written by default, and so is zero), if you believe the information, in this case this block will tell the system that it is time to take this iteration from the active loop and move on to the next one. In any case, without it, the system will give us an error.
Lines 15-17 are similar to lines of the first model.
As a result, we obtain the following data
results Model 2 - operator utilization factor The output structure is similar to the output structure of the first model, except that instead of a queue - the drive, I suggest you deal with it yourself. By the way, the report generation parameters can be configured (I don’t have GPSS installed on this computer and I don’t want to install it, so take my word for it in the program’s settings, well, if I don’t forget to add on Monday how to do it)
So, we see that our operators are quite acceptable loaded at about 75% and 87%, respectively. We assume that the two operators is enough to advise people how to properly screw the light bulb. But we are with you - the people are curious, let's see what happens if we get another boarder with the phone on the guys.
To do this, consider a slightly modified model. I suggest you deal with it yourself.
HELPDESK STORAGE 3 ;1 Number of operators helpdesk ************************************************************************************************** GENERATE 6,3 ;2 The number of subscribers Ticket ADVANCE (Exponential(1,0,2)),, ;3 during dialing ENTER HELPDESK ;4 incoming call TRANSFER ALL,OPR1,OPR3,3 ;5 definition of operator availability OPR1 SEIZE OP1 ;6 Verification of employment operator number 1 ASSIGN 1,OP1 ;7 If the operator is free in this case, accept a call TRANSFER ,COME ;8 Jump to the process of service SEIZE OP2 ;9 Verification of employment operator number 1. ASSIGN 1,OP2 ;10 If the operator is free in this case, accept a call TRANSFER ,COME ;11 Jump to the process of service OPR3 SEIZE OP3 ;12 Verification of employment operator number 1. ASSIGN 1,OP3 ;13 If the operator is free in this case, accept a call COME LEAVE HELPDESK ;14 Beginning the process of providing technical support ADVANCE 10,8 ;15 Service time RELEASE P1 ;16 The release of the operator TERMINATE 0 ;17 Removes the Active Transaction from the simulation GENERATE 480 ;18 Working day (minutes) TERMINATE 1 ;19 Minus one minute START 1 ;20 Start from the first minute
Result under the spoiler
Results Model 2 - utilization rate of three operators As a result, we see that we clearly do not need the third operator and we can safely go and clean up the vacancy, and with it all the candidates.
Lastly, I would like to tell you that GPSS-WORLD represents more extensive possibilities for modeling than the ones I told you about. Just because of the limitations of my knowledge, I can not adequately demonstrate them to you. But, nevertheless, as a bonus, I will give an example of working with variables
INITIAL X$APPLES,3 ;1 Set Variable GENERATE 1 ;2 set count of cicles SAVEVALUE APPLES-,1 ;3 set APPLES=APPLES-1 TERMINATE 1 ;4 delete one iteration START 1 ;5 1 Start from the first cicle
Let's line up again
Line 1 - INITIAL X $ APPLES, 3; 1 set the value of the variable, X $ in this case, we somehow indicate the name of the variable, and the number three is the value that we write to the variable APPLES (by the way, I'm not a fan of APPLE products just At the moment, there were 3 apples on the common table, and I took one for myself, just like in the kindergarten tasks in mathematics)
Row - 2 GENERATE 1 - create 1 iteration
Line 3 - SAVEVALUE APPLES-, 1; - save the variable apples its value minus one.
Lines 4-5 help us finish the program.
Model 3 results - variables To be honest, in spite of the fact that this example works and the unit is actually subtracted from the variable, I don’t understand the complete mechanism of working with variables, so I will leave it to the professionals.
Well, now you know about one of the tools with the help of which you can create a simulation model of the process, the tool is not the most convenient and does not seem to be updated by the developers, but nevertheless, if you show imagination, then in one two days you can do some research models and for example publish it in a scientific journal or at a conference (I already
wrote about this
earlier )
In any case, now you have one more tool to create, develop and make the world better. The right word is more interesting than to burst the ball on a smartphone while sitting in public transport.
Have a great weekend, good luck and good luck :)