1 Introduction

Since the outbreak of COVID-19 in 2020, scientists and managers of health care systems have been struggling to give a proper response to the challenges posed by the pandemic. First, it was the urge to treat the enormous amount of patients arriving at hospitals and health care centers contaminated by the SARS-Cov2 virus. Intense care units were suddenly overflowed with people in critical condition. Shortages of beds, ventilators, personal protective equipment and other supplies were reported all over the world (Sen-Crowe et al., 2021; Almeida et al., 2021; Ranney et al., 2020). Then, scientists were called to develop effective vaccines against the virus in a time span never seen before (Fang et al., 2022). Once it was achieved, it came the challenge of distributing and applying the available doses among the population in a rapid and safe way. The rush of thousands of people to the vaccination centers in the search for shots put those health care facilities under pressure and, in some cases, led to internal discoordination which, in turn, resulted in long waiting lines, people agglomeration and other undesirable events (abcnewsabcnews.go.com/WNT/video/thousands-waiting-hours-line-covid-19-vaccine-74997524).

Aiming to help softening the burden on health care structures, experts on science, technology, engineering and mathematics have been working to design models and systems intended to optimize the use of the resources available in many different health care institutions. From the very first moments after the classification of COVID-19 as a pandemic, mathematicians have presented models that have been used extensively by policy makers as support in their decision making process (Padmanabhan et al., 2021). In Gaubert et al. (2020), for example, the authors present a model capable of anticipating the evolution of the epidemic based on information from emergence calls. In van der Schaar et al. (2021) it is pointed out how artificial intelligence and machine learning could help in the management of limited healthcare resources, in the development of personalized treatment plans for different patients, in the improvement of collaboration among people working against COVID-19 and in enhancing the efficiency and effectiveness of clinical trials. In Garaix et al. (2022) the authors report four initiatives in which experts paired with front-line health care workers in order to design systems intended to improve the operation of the health care structures dealing with patients in need of urgent care. In one of those initiatives (Allamigeon et al., 2021), Petri net-based models were used to predict the necessary staff to handle a swift number of calls to the Medical Emergence Services of Paris. The system was later improved in order to deal with new routines implemented by healthcare workers.

Regarding the problems observed during the vaccination process, it is safe to say that many of those undesirable events could be avoided, or at least mitigated, through a better understanding of the vaccination center dynamics. Interestingly, searches made on scientific bases (Elsevier Science Direct and IEEE Xplore bases) did not return any work dealing specifically with this problem, which made it difficult to compare the results presented here with any other result.

Some interesting works related to health care structures and/or management strategies, that could be related to the subject of this paper were found, though. Most of them deal with modelling and simulating the results of different vaccination strategies under scenarios like the one saw during the COVID-19 pandemic. In Kuo et al. (2020), for example, the authors use graph theory to develop a probabilistic model in order simulate five different vaccination strategies (random, degree-based, acquaintance-based, first-neighbour-based and second-neighbour-based) applied to three different types of networks (small world network, scale free network and random network), which have different sensitivity to the initial conditions. The authors show that the degree-based strategy gives the best results in general, regardless of the network type. In Karabay et al. (2021), a particle-based simulation approach is applied to investigate how people’s hesitancy regarding vaccines impacts the success rate of two different vaccination strategies: age-based (in which elders get vaccinated first) and random (in which random particles are chosen to get vaccinated regardless of their ages). The authors show that, generally, the age-based strategy is more effective in generating herd immunity, but the difference between the two strategies get less significant as hesitancy among population increases.

Another very interesting work, more closely related to the one discussed here, is given in de Souza et al. (2021). The authors describe the development of a four-pronged tool capable of helping users and managers to make good choices in order to improve the services of the Brazilian public health system. The tool consists of a mobile app, which can route users in need of health care to appropriate public institutions, taking into account the institutions’ portfolio of specialties and the symptoms reported by the user. Instead of reporting the symptoms, the user can specify the type of specialist it is looking for. In a second stage, a data analysis routine was implemented in order to generate a heat map of users’ requests. The generated information is made available to the app users and help them to make informed decisions about which institution to go. The same information help managers to anticipate increasing demand in specific areas and reallocate resources, if necessary. All the information is stored in the cloud. Thus, a cloud computing application was also developed in order to enable the data analysis. Finally, a Stochastic Timed Petri Net was implemented in order to simulate hospital bed demands based on the available data, allowing managers to plan in advance actions to be taken under critical scenarios likely to happen.

This work is specially significant because, in some degree, it showcases features of what it is being proposed here. There, a Petri net model is used to simulate bed demands while here, it is used to simulate the dynamical response of a generic vaccination center. There, the model is associated to a data analysis tool in order to generate information to support managers decisions. Although we have not yet implemented such a solution, we point out that a similar system can be developed (perhaps making use of AI) to coordinate the routing of users to the vaccination centers of a city, based on a defined vaccination strategy, stored information and the model presented here.

In this paper, a tropical algebra-based model is developed for an elementary vaccination center. Then, a closed-loop control strategy is implemented in order minimize the time period of the vaccination cycle and the users’ waiting time, while maintaining a safe distance between them.

The paper is organized as follows: after this introduction, Sect. 2 presents a model for the vaccination center that we are interested in; In Sect. 3, the control strategy is developed; Sect. 4 presents the results from computer simulation tests comparing different control strategies; Conclusion is presented in Sect. 5.

2 Graphical and Mathematical Models of a Vaccination Center

This section presents a graphic model of a vaccination center using Time Event Graphs (TEG), which is a class of P-time Petri net (Baccelli et al., 1992). The model presented here should be seen as a cell that contains the essential elements of a vaccination center. However, if needed, it can be easily increased in order to represent more complex vaccination systems with no change required in the control strategy presented in the next sections. In the following subsections, a dynamical tropical model is developed for this system.

2.1 TEG Representation of the Vaccination Center

Figure 1 shows a TEG representation of the vaccination center to be modeled, which executes a four-step cycle every time a vaccine dose is given: admission, personal record review, wait and injection. The firing of transition \(x_1\), which is controlled by the input signal \(u_1\), is followed by the insertion of a token into place A and marks the admission of the user to the center’s facility. Transition \(x_2\), which is controlled by the input signal \(u_2\) and followed by the insertion of a token into place PRR, represents the ending of the admission phase and the beginning of the personal record review process, which takes \(t_P\) time units to be finished. The time needed for the user to get to the personal record review room (once they has been admitted) is included in \(t_P\). Also, it is assumed that a limited number of booths are available at the record review room, such that a maximum of m users can be simultaneously attended in that stage. The remaining places and transitions shown in Fig. 1 represent the remaining steps of the vaccination cycle and follow the same pattern described so far. Due to staff and equipment limitation, only n people can be receiving the vaccine injection at the same time. It should be noted that m and n come from physical/personnel limitations of the vaccination center and are assumed to be constant.

The model presented in Fig. 1 looks quite simple. That, however, comes to show its strength. It should be noted that it can represent vaccination centers with immense physical structures, as long as they adopt the four-step vaccination cycle described in the last paragraph. The physical structure of the vaccination center is hidden behind the indexes m and n. A large vaccination center, with dozens of PRR booths and injection stations, maybe allocated in different rooms, and a small one with a single PRR booth and a single vaccination station will be represented by the same TEG, only with different values of m and n.

In order to keep users at a safe distance from each other, it is important to impose limit to the number of people in all the places where agglomeration can be created. For example, in the instance represented in Fig. 1 there is a maximum number of users that can be allowed in the waiting room (which will be denoted by \(N_W\)) without violating a given limit of people density. That is to be done through a proper closed-loop control strategy.

Another point of interest is the time the users are kept in the waiting room. The control strategy adopted to limit the number of people in each room of the vaccination center is also expected to keep this waiting time below a given maximum limit.

Obviously, it is also desirable to keep the system throughput, that is, its vaccination rate, as high as possible. The search for a good compromise between the operational restrictions and the system throughput is the core of the control problem.

The problem just presented is generally classified as a queueing problem. The typical queueing problem consists of customers arriving at a server requesting some kind of service, waiting if they cannot be immediately attended and leaving after being served (Shortle et al., 2018). An extensive theory has been developed, aiming to provide models capable of predicting the behavior of such systems, mostly of which deal with random demands (Bolch et al., 2006). Traffic control of cars, airplanes, phone calls, scheduling of customers attendance in a hospital, of machines operation in a manufacturing line, of operations executed by a computer processor are examples of problems successfully addressed in the context of that theory (Shortle et al., 2018).

Queueing theory is a methodology that leads to computational simplification of Markovian models with many (even infinite) states. According to (Cassandras & Lafortune, 2008), queueing theory has as its main goal the determination of a system’s performance under certain operating conditions, rather than the determination of the operating policies to be used in order to achieve the best possible performance. Its mission has been largely to develop “descriptive” tools for studying queueing systems, rather than “prescriptive” tools for controlling their behavior in an ever-changing dynamic and uncertain environment.

Fig. 1
figure 1

Model of a vaccination center with 4 stages: admission (A), personal record review (PRR), wait (W) and injection (I)

In the investigation of the vaccination center behavior, we have chosen an approach that leads to a formulation relatable to the classical system and control theories. The vaccination center is modelled as a Discrete Event System (DES), graphically represented by a Timed Event Graph (TEG). The point of using this formulation is that it provides a mathematical description which is analogous to the classical state-space description of continuous-time time systems. That not only leads to a simple and concise representation of the system under analysis, but also may cast light on nuanced aspects of the TEG behavior by comparison to the well known classical system and control theories (De Schutter et al., 2020). In fact, the use of tropical algebra in the study of dynamical DES is a lively branch of research with many open questions. That adds an important layer to the work presented here: besides the application itself, the result presented in Sect. 3.4 is a new contribution to this area of research.

2.2 Mathematical Description Based on Tropical Algebra

Tropical Algebra, also known as the tropical semi-ring, is an algebraic structure defined by the set \({\mathbb {R}}_{\text {max}} \equiv ({\mathbb {R}}\cup {-\infty }, \oplus , \otimes \)), in which \(\oplus \) and \(\otimes \) denote the basic operations of tropical sum and tropical multiplication, respectively, defined as follows (Maia et al., 2011):

$$\begin{aligned} \begin{aligned}&x \oplus y \equiv max(x,y)\\&x \otimes y \equiv x + y \end{aligned} \end{aligned}$$
(1)

The operation \(\oplus \) is associative, commutative and idempotent, meaning that \(a \oplus a = a, \forall a \in ({\mathbb {R}}\cup {-\infty })\), and has neutral element denoted by \({\bar{0}}=-\infty \). The operation \(\otimes \) is associative and distributive on the left and on the right with respect to \(\oplus \) and has neutral element denoted by \({\bar{1}}=0\). Also, \(a \otimes {\bar{0}} = {\bar{0}} \otimes a = {\bar{0}}, \forall a \in ({\mathbb {R}}\cup {-\infty })\), that is, \({\bar{0}}\) is absorbing with respect to \(\otimes \).

Generally, any GET can be represented by a set of matrix equation as the following:

$$\begin{aligned} \begin{aligned}&x(k) = A \otimes x(k - 1) \oplus B \otimes u(k)\\&y(k) = C \otimes x(k) \end{aligned} \end{aligned}$$
(2)

Here, \(u(k) \in {\mathbb {R}}_{\text {max}}^p\), \(y(k) \in {\mathbb {R}}_{max}^q\) and \(x(k) \in {\mathbb {R}}_{\text {max}}^r\) are vectors that represent the date of the \(k{\text {th}}\) fire of input transition, output transition and internal transitions, respectively. A, B and C are matrices of proper dimensions with elements in \({\mathbb {R}}_{max}\). The matrix operations indicated in (2) are carried out in the same way as in the regular algebra.

Another idea that tropical algebra inherits from the classical algebra is the concept of eigenvalue and eigenvector. For a given tropical matrix A, if \(A \otimes v=\lambda \otimes v\), then \(\lambda \) is said to be an eigenvalue of A and v a corresponding eigenvector.

There is a very important connection between eigenvalues and cycle means of a system. It has been shown (Baccelli et al., 1992) that, if a system can be represented by a strongly connected graph, then its A matrix has only one eigenvalue (but possibly several eigenvectors) and this eigenvalue is numerically equal to the maximum cycle mean of the system.

A slightly different state space formulation for GETs is given by the next set of equations, in which the vector x(k) is defined as a function of itself. For that reason, it is said to be an implicit equation.

$$\begin{aligned} \begin{aligned}&x(k) = A_0 \otimes x(k) \oplus A_1x(k - 1) \oplus B_0 \otimes u(k)\\&y(k) = C \otimes x(k) \end{aligned} \end{aligned}$$
(3)

If the eigenvalue of \(A_0\) is non-negative, then it can be shown (Baccelli et al., 1992) that

$$\begin{aligned} \begin{aligned}&x(k) = A_0^* \otimes A_1x(k - 1) \oplus A_0^* \otimes B_0 \otimes u(k) \end{aligned} \end{aligned}$$
(4)

where \(A_0^*\) is the Kleene star of \(A_0\). This is equivalent to the standard representation shown in (2), with \(A=A_0^* \otimes A_1\) and \(B=A_0^* \otimes B_0\).

The next set of max-plus equations describe the behavior of the system represented in Fig. 1.

$$\begin{aligned} \begin{aligned}&x_1(k) = u_1(k)\\&x_2(k) = u_2(k) \oplus x_1(k) \oplus x_3(k-m)\\&x_3(k) = t_P \otimes x_2(k)\\&x_4(k) = u_3(k) \oplus x_3(k) \oplus y(k-n)\\&y(k) = t_I \otimes x_4(k) \end{aligned} \end{aligned}$$
(5)

It shows that in the open-loop system, transition \(x_1(k)\) is fired at the same time as \(u_1(k)\). It also shows that \(x_3(k)\) happens \(t_P\) time units after \(x_2(k)\), and so on. In order to get a standard representation for the system, like those shown in (2) and (3), (\(N_W + m - 1\)) auxiliary variables are necessary. These variables are defined as shown below.

$$\begin{aligned} \begin{aligned}&w_1(k) = x_3(k-1)\\&w_2(k) = w_1(k-1)\\&\vdots \\&w_{m-1}(k) = x_3(k-m+1)\\&z_1(k) = x_4(k-1)\\&z_2(k) = z_1(k-1)\\&\vdots \\&z_{n-1}(k) = x_4(k-n+1)\\&\vdots \\&z_{N_W}(k) = x_4(k-N_W) \end{aligned} \end{aligned}$$
(6)

The set of equations (5) can then be rewritten as:

$$\begin{aligned} \begin{aligned}&x_1(k) = u_1(k)\\&x_2(k) = x_1(k) \oplus w_{m-1}(k-1) \oplus u_2(k)\\&x_3(k) = t_P x_2(k)\\&x_4(k) = x_3(k) \oplus t_I z_{n-1}(k-1)\oplus u_3(k)\\&w_1(k) = x_3(k-1)\\&w_2(k) = w_1(k-1)\\&w_3(k) = w_2(k-1)\\&\vdots \\&w_{m-1}(k) = w_{m-2}(k-1)\\&z_1(k) = x_4(k-1)\\&z_2(k) = z_1(k-1)\\&z_3(k) = z_2(k-1)\\&\vdots \\&z_{n-1}(k) = z_{n-2}(k-1)\\&\vdots \\&z_{N_W}(k) = z_{N_W-1}(k-1)\\&y(k) = t_I x_4(k) \end{aligned} \end{aligned}$$
(7)

Here, the \(\otimes \) symbol was omitted, as is usually done with the \(\times \) symbol in regular algebraic expressions. Now, (7) can be written as:

$$\begin{aligned} \begin{aligned}&\begin{bmatrix} x(k)\\ w(k)\\ z(k)\\ \end{bmatrix} = \begin{bmatrix} A_{0xx} &{} A_{0xw} &{} A_{0xz} \\ A_{0wx} &{} A_{0ww} &{} A_{0wz} \\ A_{0zx} &{} A_{0zw} &{} A_{0zz} \\ \end{bmatrix} \begin{bmatrix} x(k)\\ w(k)\\ z(k)\\ \end{bmatrix} \oplus \\&\begin{bmatrix} A_{1xx} &{} A_{1xw} &{} A_{1xz} \\ A_{1wx} &{} A_{1ww} &{} A_{1wz} \\ A_{1zx} &{} A_{1zw} &{} A_{1zz} \\ \end{bmatrix} \begin{bmatrix} x(k-1)\\ w(k-1)\\ z(k-1)\\ \end{bmatrix} \oplus \begin{bmatrix} B_x\\ B_w\\ B_z\\ \end{bmatrix} u(k)\\&y(k)= \begin{bmatrix} C_x &{} C_w &{} C_z\\ \end{bmatrix} \begin{bmatrix} x(k)\\ w(k)\\ z(k)\\ \end{bmatrix} \end{aligned} \end{aligned}$$
(8)

For the system represented in Fig. 1, it is straightforward to verify that

$$\begin{aligned} \begin{array}{ll} A_{0xx} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{1}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} t_P &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} &{} {\bar{0}} \end{bmatrix} &{} A_{1xw} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{1}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}} \end{bmatrix} \\ \\ A_{1xz} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} t_I \end{bmatrix} &{} A_{1wx} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ \vdots &{} \vdots &{} \vdots &{} \vdots \\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{bmatrix} \\ \\ A_{1ww} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{}... &{} {\bar{0}}\\ {\bar{1}} &{} {\bar{0}} &{}... &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{1}} &{}... &{} {\bar{0}}\\ \vdots &{} \vdots &{} \ddots &{} \vdots \\ {\bar{0}} &{} {\bar{0}} &{}... &{} {\bar{0}}\\ \end{bmatrix} &{} A_{1zx}= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{1}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ \vdots &{} \vdots &{} \vdots &{} \vdots \\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{bmatrix} \\ \\ A_{1zz} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{}... &{} {\bar{0}}\\ {\bar{1}} &{} {\bar{0}} &{}... &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{1}} &{}... &{} {\bar{0}}\\ \vdots &{} \vdots &{} \ddots &{} \vdots \\ {\bar{0}} &{} {\bar{0}} &{}... &{} {\bar{0}}\\ \end{bmatrix} &{} A_{0xw} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times (m-1)} \\ \\ A_{0xz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times N_W} &{} A_{0wx} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{(m-1) \times 4} \\ \\ A_{0ww} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{(m-1) \times (m-1)} &{} A_{0wz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{(m-1) \times N_W} \\ \\ A_{0zx} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{N_W \times 4} &{} A_{0zw} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{N_W \times (m-1)} \\ \\ A_{0zz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{N_W \times N_W} &{} A_{1xx} = \begin{bmatrix} \varvec{{\bar{I}}}\\ \end{bmatrix}_{4 \times 4} \\ \\ A_{1wz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{(m-1) \times N_W} &{} A_{1zw} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{N_W \times (m-1)} \end{array}\end{aligned}$$
(9)
$$\begin{aligned} \begin{array}{ll} B_x= \begin{bmatrix} {\bar{1}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{1}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} \end{bmatrix} &{} B_w= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ \vdots &{} \vdots &{} \vdots \\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{bmatrix} \\ \\ B_z= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ \vdots &{} \vdots &{} \vdots \\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{bmatrix} &{} \begin{array}{c} C_x= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} t_I\\ \end{bmatrix} \\ \\ C_w= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ \end{bmatrix} \\ \\ C_z= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ \end{bmatrix} \end{array} \end{array} \end{aligned}$$

3 System Control

In this section, a controller for the vaccination center is developed. We start by coding mathematically the restrictions due to maximum patients allowed in the waiting room as well as the maximum waiting time.

3.1 Occupancy and Waiting Time Constraints

The model presented in the last section captures the most important features of the open-loop system behavior. Only physical restrictions were modeled. As a result, the system will violate the non-physical restrictions if inputs \(u_1\), \(u_2\) and \(u_3\) are not controlled. The two non-physical restrictions being considered here are the maximum number of people allowed in the waiting room (\(N_W\)) and the maximum waiting time (\(t_W\)). The number of people in the waiting room depends on the firing of transitions \(x_3\) and \(x_4\), which are controlled by inputs \(u_2\) and \(u_3\). Figure 2 shows the critical firing sequence of transitions \(x_3\) and \(x_4\) that still ensures no violation of the restriction related to \(N_W\).

Fig. 2
figure 2

Critical firing sequence of \(x_3\) and \(x_4\) that do not violate the restriction of the maximum number of people in the waiting room

It can be seen that, in order to restrict the number of people in the waiting room to \(N_W\), the firing date of \(x_4(k)\) must be less or equal to the firing date of \(x_3(k + N_W)\). Mathematically, this restriction can be expressed as:

$$\begin{aligned} \begin{aligned} x_4(k)&\preceq x_3(k+N_W)\\ x_4(k-N_W)&\preceq x_3(k) \Rightarrow z_{N_W}(k) \preceq x_3(k) \end{aligned} \end{aligned}$$
(10)

The restriction regarding the maximum waiting time can be easily expressed if one assumes that the system operates based on a first in, first out policy. Thus, the time the \(k{\text {th}}\) user spends in the waiting room is given by \(x_4(k)-x_3(k)\) and the related restriction be written as:

$$\begin{aligned} \begin{aligned}&x_4(k) \preceq t_W x_3(k)\\&x_4(k) \preceq (t_W+t_P)x_2(k)\\ -&(t_W+t_P)x_4(k) \preceq x_2(k) \end{aligned} \end{aligned}$$
(11)

The restrictions defined in equations (10) and (11) can be expressed in matrix form as \(\mathbf {Ex \preceq x}\), in which E is the system restriction matrix. For the system considered in this work

$$\begin{aligned} \begin{aligned} E=\begin{bmatrix} E_{xx} &{} E_{xw} &{} E_{xz} \\ E_{wx} &{} E_{ww} &{} E_{wz} \\ E_{zx} &{} E_{zw} &{} E_{zz} \\ \end{bmatrix} \end{aligned} \end{aligned}$$
(12)

for which

$$\begin{aligned} \begin{aligned} \begin{array}{ll} E_{xx} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} -(t_W+t_P)\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} &{} {\bar{0}} \end{bmatrix} \\ E_{xz} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{1}}\\ {\bar{0}} &{} {\bar{0}} &{} \ldots &{} {\bar{0}} \end{bmatrix} \end{array} \end{aligned} \end{aligned}$$
(13)

All the remaining sub-matrices shown in (12) are max-plus zero matrices with proper dimensions. If all the circuit weights of E are non-positive, it can be shown (Baccelli et al., 1992) that

$$\begin{aligned} \begin{aligned} Ex(k)&\preceq x(k) \iff E^*x=x\\ E^*x&=x \iff x \in ImE^* \end{aligned} \end{aligned}$$
(14)

From equation (4), it can be seen that

$$\begin{aligned} \begin{aligned} A_0x(k) \preceq x(k) \end{aligned} \end{aligned}$$
(15)

It follows that the matrix which express all the system restrictions is given by

$$\begin{aligned} \begin{aligned} {\hat{E}} = E \oplus A_0 \end{aligned} \end{aligned}$$
(16)

3.2 Controller Design

From a TEG perspective, the closed-loop control of the system is implemented through the addition of timed places (one for each input signal) connected and initialized in such a way that all the restrictions are met by the controlled system. One interesting change introduced by these control places is that they make the closed-loop system strongly connected. Thus, according to the results given in Baccelli et al. (1992), the closed-loop system has only one eigenvalue, which is numerically equal to its maximum cycle mean.

The \(k_{th}\) firing dates of the input signals in the closed-loop system are related to the \((k-1)_{th}\) firing dates of the system transitions according to the following:

$$\begin{aligned} \begin{aligned} u(k) = Fx(k-1) \end{aligned} \end{aligned}$$
(17)

Once F has been determined, the state space description of the closed-loop system is given as:

$$\begin{aligned} {\left\{ \begin{array}{ll} x(k) = (A \oplus BF) \otimes x(k - 1)\\ {\hat{E}}^*x(k) = x(k) \end{array}\right. } \end{aligned}$$
(18)

The method introduced by Maia et al. (2011) is used here for determining a matrix F that ensures the equation (18) holds true. In a first stage, the method uses the so-called alternating algorithm, introduced in Cuninghame-Green and Butkovic (2003), to find an initial solution that may or may not be a causal matrix. A matrix \(M \in {\mathbb {R}}_{max}\) is causal if all of its entries \(M_{ij}\) are such that \(M_{ij} = {\bar{0}}\) or \(M_{ij} \succeq {\bar{1}}\). Non-causal matrices cannot be physically implemented by systems like the one considered in this work. Thus, if the initial control matrix is non-causal, a method for finding an equivalent causal matrix must be employed.

3.3 Equivalent Causal Control Matrix

Finding an equivalent causal control matrix is a critical step for the work presented here. Given a non-causal matrix \(F_{nc}\), the goal is to find a causal matrix \(F_c\) such that \(Im\;F_c \subseteq Im\;F_{nc}\) and still ensures the closed-loop system meets all the non-physical restrictions imposed. The simplest way to find such an equivalent matrix is to use the concept of parallelism relation given in Katz (2007)

$$\begin{aligned} F_c = -\,min \left\{ [F_{nc}]_{ij}\right\} \otimes F_{nc} \end{aligned}$$
(19)

in which \(min \left\{ [F_{nc}]_{ij}\right\} \) is the smallest entry in the non-causal matrix \(F_{nc}\). However, this approach has a major disadvantage for the control problem considered here: it increases the eigenvalue of the corresponding closed-loop system when compared to the non-causal matrix. Since the system eigenvalue is numerically identical to its maximum cycle mean, to increase the system eigenvalue means to decrease the system throughput. In order to avoid such an undesirable change, an alternative approach, introduced in Maia et al. (2013) is further developed mathematically in this paper, resulting in proposition 1.

3.4 Equivalent Dynamic Feedback that Preserves the Same Dynamic Behavior as \(F_{nc}\)

Let \(F_{nc}\) be a non-causal control matrix that leads to a closed-loop system with characteristic:

$$\begin{aligned} {\left\{ \begin{array}{ll} u(k) = F_{nc}x(k-1)\\ x(k) = (A \oplus BF_{nc}) \otimes x(k - 1)\\ {\hat{E}}^*x(k) = x(k) \end{array}\right. } \end{aligned}$$
(20)

Equation (20) can be recursively applied to show that

$$\begin{aligned} {\left\{ \begin{array}{ll} x(k-1) = (A \oplus BF_{nc}) \otimes x(k - 2)\\ u(k) = F_{nc}(A \oplus BF_{nc}) \otimes x(k - 2)\\ \vdots \\ u(k) = F_{nc}(A \oplus BF_{nc})^{\otimes L} x(k-L-1) \end{array}\right. } \end{aligned}$$
(21)

Provided that \((A \oplus BF_{nc})\) is irreducible, it can be shown (Maia et al., 2013) that

$$\begin{aligned} \lim _{L\rightarrow \infty } [F_{nc}(A \oplus BF_{nc})^{\otimes L}]_{ij} = \infty , \forall \;i,j \end{aligned}$$
(22)

Thus, there is a minimum value of L that makes \(F_{nc}(A \oplus BF_{nc})^{\otimes L}\) causal. Let \(F_{\text {opt}} = F_{nc}(A \oplus BF_{nc})^{\otimes L_{\text {min}}}\). For the purpose of this work, the recursive routine shown in  Algorithm 1 can be used to find \(L_{\text {min}}\) and \(F_{\text {opt}}\). The closed-loop state matrix is then given as:

$$\begin{aligned} x(k) = Ax(k - 1) \oplus BF_{\text {opt}} x(k - L - 1) \end{aligned}$$
(23)

It should be mentioned that x(k) in equation (20) is actually representing the whole array of state variables defined previously, including the auxiliary variables defined in equation (6).

figure a

In order to write the closed-loop state matrix (23) in the standard form, a set of \(L_{\textit{min}}\) auxiliary variables are defined as:

$$\begin{aligned} \begin{aligned}&r_1(k) = x_1(k-1)\\&r_2(k) = r_1(k-1)\\&\vdots \\&r_{L_{\text {min}}}(k) = r_{L_{\text {min}}-1}(k-1)=x(k-L_{min}) \end{aligned} \end{aligned}$$
(24)

Substituting (24) into (23), the closed-loop state matrix can then be written as:

$$\begin{aligned} \underbrace{ \begin{bmatrix} &{}x(k)\\ &{}r_1(k)\\ &{}r_2(k)\\ &{}\vdots \\ &{}r_{L_{\text {min}}}(k) \end{bmatrix} }_{x_{ext}(k)} = \underbrace{ \begin{bmatrix} A &{} [{\bar{0}}] &{} [{\bar{0}}] &{} \ldots &{} B F_{\text {opt}}\\ [{\bar{I}}] &{} [{\bar{0}}] &{} [{\bar{0}}] &{} \ldots &{} [{\bar{0}}]\\ [{\bar{0}}] &{} [{\bar{I}}] &{} [{\bar{0}}] &{} \ldots &{} [{\bar{0}}]\\ \vdots &{} \vdots &{} \vdots &{} \ddots &{} \vdots \\ [{\bar{0}}] &{} [{\bar{0}}] &{} [{\bar{0}}] &{} \ldots &{} [{\bar{0}}] \end{bmatrix} }_{A_{ext}} \underbrace{ \begin{bmatrix} &{}x(k-1)\\ &{}r_1(k-1)\\ &{}r_2(k-1)\\ &{}\vdots \\ &{}r_{L_{\text {min}}}(k-1) \end{bmatrix} }_{x_{ext}(k-1)} \end{aligned}$$
(25)

Here, \(x_{ext}\) and \(A_{ext}\) are the extended versions of the closed-loop system state variables array and the state matrix, respectively. \([{\bar{I}}]\) represents an identity matrix and \([{\bar{0}}]\) a matrix of zeroes, both with dimensions \((N_W+m-1)\times (N_W+m-1)\).

Proposition 1

\(A_{ext}\) has the same eigenvalue as \((A \oplus BF_{nc})\).

Proof

Let \(\lambda \) be the eigenvalue of \((A \oplus BF_{nc})\) and v a corresponding eigenvector. Then, by definition,

$$\begin{aligned} \lambda v = (A \oplus BF_{nc})v \end{aligned}$$
(26)

But

$$\begin{aligned} \lambda v = (A \oplus BF_{nc})v \Rightarrow \lambda ^p v = (A \oplus BF_{nc})^pv \end{aligned}$$
(27)

Now, let \(\lambda _{ext}\) be the eigenvalue of \(A_{ext}\) and \(v_{ext}\) a corresponding eigenvector. Then,

$$\begin{aligned} \lambda _{ext} v_{ext} = A_{ext}v_{ext} \end{aligned}$$
(28)

But \(v_{ext}=[v_{x}^{T}\;v_{r_{1}}^{T}\;v_{r_{2}}^{T}...\;v_{r_{L_{\text {min}}}}^{T}\;]^T\). Thus, from (25) and (28), it follows that

$$\begin{aligned} \begin{aligned}&\lambda _{ext} v_x = Av_x \oplus BF_{\text {opt}}v_{r_{L_{\text {min}}}}\\&\lambda _{ext} v_{r_1} = v_x\\&\lambda _{ext} v_{r_2} = v_{r_1}\\&\lambda _{ext} v_{r_3} = v_{r_2}\\&\vdots \\&\lambda _{ext} v_{r_{L_{\text {min}}}} = v_{r_{(L_{\text {min}}-1)}}\\ \end{aligned} \end{aligned}$$
(29)

From (29), it follows that

$$\begin{aligned} \begin{aligned}&\lambda _{ext}^2v_{r_{L_{\text {min}}}} = v_{r_{(L_{\text {min}}-2)}}\\&\lambda _{ext}^3v_{r_{L_{\text {min}}}} = v_{r_{(L_{\text {min}}-3)}}\\&\vdots \\&\lambda _{ext}^{L_{\text {min}}} v_{r_{L_{\text {min}}}}=v_x \end{aligned} \end{aligned}$$
(30)

Replacing the last equality in (30) into the first one in (29) results in

$$\begin{aligned} \begin{aligned}&\lambda _{ext}^{L_{\text {min}}+1} v_{r_{L_{\text {min}}}} = (\lambda _{ext}^{L_{\text {min}}}A \oplus BF_{\text {opt}})v_{r_{L_{min}}}\\ \end{aligned} \end{aligned}$$
(31)

Now, assume that proposition 1 is true and that \(\lambda _{ext}=\lambda \) and \(v_{ext}=v\). Then, from (27) it follows that \((A \oplus BF_{nc})^{L_{\text {min}}}v_{r_{L_{\text {min}}}}=\lambda _{ext}^{L_{min}}v_{r_{L_{\text {min}}}}\). Thus, \(F_{\text {opt}} = F_{nc}(A \oplus BF_{nc})^{L_{\text {min}}}=F_{nc}\lambda _{ext}^{L_{\text {min}}}\) and (31) can be rewritten as shown below

$$\begin{aligned} \begin{aligned}&\lambda _{ext}^{L_{\text {min}}+1} v_{r_{L_{\text {min}}}} = \lambda _{ext}^{L_{\text {min}}}(A \oplus BF_{nc})v_{r_{L_{\text {min}}}}\\ \end{aligned} \end{aligned}$$
(32)

From (26), it follows that \((A \oplus BF_{nc})v_{r_{L_{\text {min}}}}=\lambda _{ext} v_{r_{L_{\text {min}}}}\). Finally, from (32), it follows that \(\lambda _{ext}^{L_{\text {min}}+1} v_{r_{L_{\text {min}}}} = \lambda _{ext}^{L_{\text {min}}+1} v_{r_{L_{\text {min}}}}\), which shows that proposition 1 is true. \(\square \)

4 Simulated Tests

In order to verify the theoretical predictions presented in the last sections, simulations were carried out and the results are presented here. All the simulations were done using the software Scicoslab©, which has a max-plus toolbox that simplify the simulation of discrete event systems like the one considered in this paper.

Figure 3 shows an instance of the generalized vaccination center model represented in Fig. 1, for which there are three PRR booths (\(m=3\)) and two injection stations (\(n=2\)). The PRR process takes 1.5 min on average while the whole procedure involving the vaccine injection takes 2.5. It will be assumed that a maximum of four people (\(N_W=4\)) can be allowed into the waiting room without violating the social distancing protocol previously established. Also, it will be assumed that the maximum waiting time tolerable is five minutes (\(t_W=5 min\)). The state space matrices for this particular instance are shown in (33).

It is worth noting that the cycle means for the instance shown in Fig. 3 are equal to 0.75 min and 1.25 min. The system maximum cycle mean is then 1.25 min.

$$\begin{aligned} \begin{array}{ll} A_{0xx} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{1}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} 1.5 &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} &{} {\bar{0}} \end{bmatrix} &{} A_{1xw} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{1}}\\ {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} \end{bmatrix} \\ \\ A_{1xz} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} 2.5 \end{bmatrix} &{} A_{1wx} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{bmatrix} \\ \\ A_{1ww} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}}\\ {\bar{1}} &{} {\bar{0}} \end{bmatrix} &{} A_{1zx}= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{1}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{bmatrix} \\ \\ A_{1zz} = \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{1}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{1}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} &{} {\bar{0}}\\ \end{bmatrix} &{} A_{0xw} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times 2} \\ \\ A_{0xz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times 4} &{} A_{0wx} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{2 \times 4} \\ \\ A_{0ww} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{2 \times 2} &{} A_{0wz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{2 \times 4} \\ \\ A_{0zx} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times 4} &{} A_{0zw} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times 2} \\ \\ A_{0zz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times 4} &{} A_{1xx} = \begin{bmatrix} \varvec{{\bar{I}}}\\ \end{bmatrix}_{4 \times 4} \\ \\ A_{1wz} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{2 \times 4} &{} A_{1zw} = \begin{bmatrix} \varvec{{\bar{0}}}\\ \end{bmatrix}_{4 \times 2} \\ \\ B_x= \begin{bmatrix} {\bar{1}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{1}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{1}} \end{bmatrix} &{} B_w= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ \end{bmatrix} \end{array} \nonumber \\ \begin{array}{ll} B_z= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{bmatrix} &{} \begin{array}{c} C_x= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} 2.5\\ \end{bmatrix} \\ \\ C_w= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} \\ \end{bmatrix} \\ \\ C_z= \begin{bmatrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ \end{bmatrix} \end{array} \end{array} \end{aligned}$$
(33)
Fig. 3
figure 3

Instance of the vaccination center represented in Fig. (1) with \(t_P=1.5\;min\), \(t_I=2.5\;min\), \(m=3\) and \(n=2\). It is also assumed that \(N_W=4\) and \(t_W=5\;min\)

4.1 The Open-Loop System

Table 1 shows the first firing dates of the system transitions when it is operating without a controller. Since only physical restrictions are observed by the model, there is no limit of any kind regarding the admission of users into the vaccination center facility. Consequently, an infinite number of admissions happen at t = 0. Obviously, this is not physically possible. Yet, it provides valuable insights about the system dynamic behavior. The modeled system behavior under this circumstance corresponds to its impulse response. For example, looking at y(k), it can be seen that two users leave the injection room every 2.5 min, which corresponds to an average of 1.25 min/vaccine. This gives the minimum time per vaccine possible for the instance considered, which, not by coincidence, is equal to its maximum cycle mean.

If on one hand the open-loop system works with optimum throughput, on the other it violates the non-physical restrictions previously defined. Figures 4 and 5 show how the number of people in the waiting room (\(N_W\)) and the waiting time (\(t_W\)) for each user increases well above the limits established.

Table 1 First firing dates of the open-loop system transitions
Fig. 4
figure 4

Number of people in the waiting room for the open-loop system. The \(N_W\) restriction is violated

Fig. 5
figure 5

Waiting time for the \(k{\text {th}}\) user in the open-loop system. The \(t_W\) restriction is violated

4.2 The Closed-Loop System with \(F_c\) Determined through Parallelism

As explained in Sect. 3.3, the first step to design the controller that will enforce the restrictions on the system behavior is to find a control matrix F. Here, that was done using the method introduced in Maia et al. (2011). The result was the following non-causal matrix:

$$\begin{aligned} F_{nc} = \left[ {\begin{matrix} -3 &{} -5 &{} -4 &{} -10 &{} -4 &{} -4 &{} -2 &{} -8 &{} -4 &{} -2 \\ -5 &{} -4 &{} -4 &{} -10 &{} -8 &{} -8 &{} -10 &{} -7 &{} -7 &{} -2 \\ -7 &{} -8 &{} -7 &{} -7 &{} -4 &{} -6 &{} -4 &{} -3 &{} -1 &{} -7 \end{matrix}}\right] \end{aligned}$$
(34)

A remarkable feature of this \(F_{nc}\) is that, if it was possible to implement such a control strategy, the closed-loop system matrix \((A \oplus BF_{nc})\) would have only one eigenvalue (a clear sign that the closed-loop system is strongly connected), which would be equal to the system maximum mean cycle, that is, \(\lambda _{nc}=1.25\). That means the closed-loop system generated by the non-causal control matrix would meet all non-physical restrictions and, in addition, guarantee the maximum system throughput possible. However, as already mentioned in Sect. 3.2, non-causal control strategies cannot be implemented by systems like the one under analysis here.

In order to generate a causal control matrix equivalent to the \(F_{nc}\) shown in (34), the parallelism relation described in Sect. 3.3 was used. From equation (19), \(F_c=10 \otimes F_{nc}\). The resulting \(F_c\) is

$$\begin{aligned} F_c = \begin{bmatrix} 7 &{} 5 &{} 6 &{} 0 &{} 6 &{} 6 &{} 8 &{} 2 &{} 6 &{} 8 \\ 5 &{} 6 &{} 6 &{} 0 &{} 2 &{} 2 &{} 0 &{} 3 &{} 3 &{} 8 \\ 3 &{} 2 &{} 3 &{} 3 &{} 6 &{} 4 &{} 6 &{} 7 &{} 9 &{} 3 \end{bmatrix} \end{aligned}$$
(35)

The matrix \(F_c\) shown in (35) has redundant information that can be eliminated in order to simplify the controller. To see this, observe that the expression for \(u_1(k)\) implied by (35) is

$$\begin{aligned}&u_1(k) = 7x_1(k-1) \oplus 5x_2(k-1) \oplus 6x_3(k-1)\\&\oplus x_4(k-1) \oplus 6w_1(k-1) \oplus 6w_2(k-1) \oplus 8z_1(k-1)\\ {}&\oplus 2z_2(k-1) \oplus 6z_3(k-1) \oplus 8z_4(k-1) \end{aligned}$$

If the auxiliary variables are now eliminated using the expressions given in (6), the expression for \(u_1(k)\) becomes

$$\begin{aligned}&u_1(k) = 7x_1(k-1) \oplus 5x_2(k-1) \oplus 6x_3(k-1)\\&\oplus x_4(k-1) \oplus 6x_3(k-2) \oplus 6x_3(k-3) \oplus 8x_4(k-2)\\ {}&\oplus 2x_4(k-3) \oplus 6x_4(k-4) \oplus 8x_4(k-5) \end{aligned}$$

Clearly, \(6x_3(k-3) \prec 6x_3(k-2) \prec 6x_3(k-1)\). Thus, the entries \([F_c]_{1,5}=6x_3(k-2)\) and \([F_c]_{1,6}=6x_3(k-3)\) are unnecessary. After elimination of redundant entries, F\(_{\text {c}}\) becomes

$$\begin{aligned} F_c = \begin{bmatrix} 7 &{} {\bar{0}} &{} 6 &{} 0 &{} {\bar{0}} &{} {\bar{0}} &{} 8 &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \\ {\bar{0}} &{} {\bar{0}} &{} 6 &{} 0 &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} 3 &{} {\bar{0}} &{} 8 \\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} 3 &{} 6 &{} {\bar{0}} &{} 6 &{} 7 &{} 9 &{} {\bar{0}} \end{bmatrix} \end{aligned}$$
(36)

The corresponding closed-loop system is shown in Fig. 6.

Fig. 6
figure 6

The closed-loop system with \(F_c\) determined through parallelism

It is clear that the added control places make the closed-loop system strongly connected.

It is worth stopping at this point to clarify the role played by the control places in the control strategy. Essentially, what the control places do is to ensure the correct synchronization between the firings of each transition. They do that by controlling the firing of the inputs. For example, the control places associated to the first input in Fig. 6 ensure that the next firing of \(u_1\) will not happen 7 time units before the last firing of \(x_1\), or 6 time units before the last firing of \(x_3\), or 8 time units before the last but one firing of \(x_4\), whichever happens last. It is not intuitive, though, why that control law, in conjunction with the control laws associated to \(u_2\) and \(u_3\) enforce the closed-loop system to behave in the expected way. It is the analytical methodology presented in Sects. 3.2, 3.3 and 3.4 that guarantees it will do so.

The closed-loop system behavior is then determined by the following set of equations:

$$\begin{aligned} {\left\{ \begin{array}{ll} x(k) = (A \oplus BF_c) \otimes x(k - 1)\\ y(k) = C \otimes x(k). \end{array}\right. } \end{aligned}$$
(37)

Table 2 shows the firing dates of each system transition. The first ten firings were simulated with an open-loop system. Before the 11th firing the loop was closed. Looking at transitions \(x_3\) and \(x_4\), it can be seen that, once the loop is closed, they are always fired at the same time. That means the non-physical restrictions are easily met by the closed-loop system, since \(N_W\) and \(t_W\) are driven to zero. On the other hand, from the values of y(k), it can be seen that the closed-loop system takes on average 7.5 min/vaccine, a value six times greater than the minimum value possible. That indicates that the closed-loop system throughput is six times lower than its optimum value. It can be easily verified that matrix \((A \oplus BF_c)\) has only one eigenvalue, which is equal to 7.5.

Figures 7 and 8 highlight the action of the controller showing how it brings \(N_w\) and \(t_W\) to values below those specified by the non-physical restrictions.

Fig. 7
figure 7

Number of people in the waiting room as the system goes from open-loop operation to closed-loop operation with \(F_c\)

Fig. 8
figure 8

Waiting time for the \(k{\text {th}}\) user as the system goes from open-loop operation to closed-loop operation with \(F_c\)

Table 2 Transitions firing dates when the loop is closed with \(F_c\) determined through parallelism

4.3 The Closed-Loop System with Optimum Throughput Implemented Through the Method Suggested in this Paper

Here, the method presented in Sect. 3.4 is applied in order to find a \(F_{\text {opt}}\) that generates the same closed-loop eigenvalue as the \(F_{nc}\) shown in (34) and ensures the closed-loop system observe the non-physical restrictions. The resulting matrix is

$$\begin{aligned} F_{\text {opt}} = \left[ {\begin{matrix} 7 &{} 7 &{} 5.5 &{} 8 &{} 7 &{} 7 &{} 8 &{} 4.5 &{} 5 &{} 5 \\ 4.5 &{} 4.5 &{} 3 &{} 3 &{} 2 &{} 4.5 &{} 5.5 &{} 0 &{} 2 &{} 2.5 \\ 6 &{} 6 &{} 4.5 &{} 6.5 &{} 5.5 &{} 6 &{} 7 &{} 3 &{} 3.5 &{} 4 \end{matrix}}\right] . \end{aligned}$$
(38)

As with \(F_c\), the \(F_{\text {opt}}\) in (38) has redundant entries, which can be eliminated resulting in the following matrix:

$$\begin{aligned} F_{\text {opt}} = \left[ {\begin{matrix} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} 8 &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \\ {\bar{0}} &{} 4.5 &{} {\bar{0}} &{} 3 &{} {\bar{0}} &{} 4.5 &{} 5.5 &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}}\\ {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} &{} 6.5 &{} {\bar{0}} &{} {\bar{0}} &{} 7 &{} {\bar{0}} &{} {\bar{0}} &{} {\bar{0}} \end{matrix}}\right] \end{aligned}$$
(39)

The corresponding closed-loop system is shown in Fig. 9.

Fig. 9
figure 9

The closed-loop system with \(F_{\text {opt}}\)

Again, the closed-loop system behavior is then determined by equation (37), with \(F_c\) being replaced by \(F_{\text {opt}}\).

The firing dates of the system transitions are shown in Table 3, in which the first ten rows show the system behavior working with no controller while the remaining rows represent the controlled system behavior when the feedback loop is closed according to \(F_{\text {opt}}\). Looking at the y(k) values one can immediately see that the closed-loop system is able to maintain the same throughput achieved by the open-loop system (1.25 min/vaccine). This shows that the closed-loop system matrix \((A \oplus BF_{\text {opt}})\) has the same eigenvalue as \((A \oplus BF_{nc})\), which is equal to the system maximum cycle mean.

Table 3 Transitions firing dates when the loop is closed with \(F_{opt}\) determined as shown in Sect. 3.4

Figures 10 and 11 show that the restrictions related to \(N_{W}\) and \(t_W\) are rapidly violated by the open-loop system. However, once the controller is turned on, it acts to bring \(N_{W}\) and \(t_W\) back under the defined limits.

Fig. 10
figure 10

Number of people in the waiting room as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\)

Fig. 11
figure 11

Waiting time for the \(k{\text {th}}\) user as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\)

4.3.1 Closed-Loop System Behavior Ender Parametric Variations

A relevant question about the closed-loop system behavior is how the controller reacts to system parametric variations. For example, how good will be the closed-loop system behavior if, for some reason, a PRR booth or an injection station suddenly goes out of service? This question is related to the concept of system robustness. We expect to carry out a rigorous and formal analytical investigation about this topic in the future. Here, we used simulations in order to check some results.

As discussed in the previous sessions, the system is modelled in terms of the parameters m, n, \(t_P\), \(t_I\). Thus, we focus here on checking how changes in one or more of these parameters impact the system performance. Before presenting the results, we observe that there is an equivalence between increasing \(t_T\) and decreasing m. Indeed, as the number of PRR booths decrease, less users, on average, will be attended in given time interval. Thus, on average, the time for a user to go through the PRR process will increase. The same thing can be said about \(t_I\) and n.

In the first simulation the system state matrices were changed in order to represent a similar system, but with \(m = 2\). That represents the situation in which a PRR booth goes out of service. Everything else, including the controller, was kept unaltered. The results are shown in Table 4 and Fig. 12 and 13. Comparing these results with the ones presented in Table 3 and Figs. 10 and 11, almost no change is observed. All the restrictions are met, both systems develop the same throughput, the firing dates of the closed-loop transitions are the same, etc. This means the controller was able to enforce the system desired behavior showing no sensitivity to the variation of m. The only difference that can be noted is that the open-loop system dynamics became slower. The system takes more time to change its states. That is coherent with the fact that now less users will be attended simultaneously in the PRR room.

Table 4 Transitions firing dates when the loop is closed with \(F_{\text {opt}}\) and \(m=2\)
Fig. 12
figure 12

\(N_W\) as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(m=2\)

Fig. 13
figure 13

\(t_W\) for the \(k{\text {th}}\) user as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(m=2\)

If m is decreased to \(m=1\), then the transitions firing dates become those shown in Table 5. It can be seen that transitions \(x_3\) and \(x_4\) are fired simultaneously. That means no person stays at the waiting room for any significant time and thus, the non-physical restrictions are observed all the time. From the values of y(k) one can see that now the system vaccination rate is a little slower than before: 1.5 min/vaccine. However, that is still the best rate possible. With only one PRR booth available, the PRR process becomes bottleneck of the vaccination cycle. From a graph theory perspective, the maximum mean cycle is now \(\lambda =1.5/1=1.5\) min. So, it can be said that the controller is still working properly, although it does not have much to control in this case.

Table 5 Transitions firing dates when the loop is closed with \(F_{\text {opt}}\) and \(m=1\)

The next test consisted of decreasing the parameter n to \(n=1\). Now the system as only one vaccination station. The results are shown in Table 6 and Figs. 14 and 15. It can be seen that, once the control loop is closed, the controller is able to stabilize the values of \(N_W\) and \(t_W\). However, it stabilizes them above the maximum values specified, that is, the restrictions are violate. This shows that the controlled system is highly sensitive to changes in n. In future works we expect to improve its robustness to n variations.

Table 6 Transitions firing dates when the loop is closed with \(F_{\text {opt}}\) and \(n=1\)
Fig. 14
figure 14

\(N_W\) as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(n=1\)

Fig. 15
figure 15

\(t_W\) for the \(k{\text {th}}\) user as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(n=1\)

The controller has low sensitivity to variations in \(t_P\) and \(t_I\). Figures 16, 17, 18, 19 show the values of \(N_W\) and \(t_W\) when \(t_P\) is increased up to \(t_P = 3.5\) min (Figs. 16 and 17) and when \(t_I\) is increased up to \(t_I = 4\) min (Figs. 18 and 19). In all situations the non-physical restrictions are met. Also, it was observed that the vaccination rate is kept at its highest in all scenarios.

Fig. 16
figure 16

\(N_W\) as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(t_P=3.5\) min

Fig. 17
figure 17

\(t_W\) for the \(k{\text {th}}\) user as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(t_P=3.5\) min

Fig. 18
figure 18

\(N_W\) as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(t_I=4\) min

Fig. 19
figure 19

\(t_W\) for the \(k{\text {th}}\) user as the system goes from open-loop operation to closed-loop operation with \(F_{\text {opt}}\) and \(t_I=4\) min

5 Conclusion

The goal of this paper was to present a model for a vaccination center based on discrete event modeling approach, and a controller design method that ensures the closed-loop system meets a series of operational restrictions while maintaining its throughput at a maximum. First, it was shown how a tropical dynamic model can be developed for the vaccination center. Then it was shown how a control matrix F can be found and, in case F turns out to be non-causal, how an equivalent causal matrix can be found. Following, it was shown that the equivalent causal matrix generated by parallelism relation leads to a closed-loop system with low throughput. A method for finding an equivalent control matrix that leads to a closed-loop system that meets the restrictions and works with optimum throughput was presented. Finally, simulations were carried out to confirm the theoretical predictions made in the previous sections and to investigate the system robustness to parametric variations. It was shown that the controlled system has low sensitivity to changes in the parameters m, \(t_P\) and \(t_I\), but high sensitivity to changes in n.

Simulation results has shown the effectiveness of the approach. This distinct application of tropical algebra, as literature review indicates, opens to us exciting threads of investigation related to the management of structures similar to the vaccination center studied in this work.