PITS: An Intelligent Transportation System in pandemic times

The control of the pandemic caused by SARS-CoV-2 is a challenge for governments all around the globe. To manage this situation, countries have adopted a bundle of measures, including restrictions to population mobility. As a consequence, drivers face with the problem of obtaining fast routes to reach their destinations. In this context, some recent works combine Intelligent Transportation Systems (ITS) with big data processing technologies taking the traffic information into account. However, there are no proposals able to gather the COVID-19 health information, assist in the decision-making process, and compute fast routes in an all-in-one solution. In this paper, we propose a Pandemic Intelligent Transportation System (PITS) based on Complex Event Processing (CEP), Fuzzy Logic (FL) and Colored Petri Nets (CPN). CEP is used to process the COVID-19 health indicators and FL to provide recommendations about city areas that should not be crossed. CPNs are then used to create map models of health areas with the mobility restriction information and obtain fast routes for drivers to reach their destinations. The application of PITS to Madrid region (Spain) demonstrates that this system provides support for authorities in the decision-making process about mobility restrictions and obtain fast routes for drivers. PITS is a versatile proposal which can easily be adapted to other scenarios in order to tackle different emergency situations.


Introduction
Every pandemic is unique and can cause different problems in the society and economy, so managing a pandemic is a challenge for authorities and governments around the world. Intelligent Transportation Systems (ITSs) can be helpful for mitigating the effects of a pandemic, since ITSs allow us to make decisions under dynamic changes, uncertainty and limited knowledge. Thus, managing ITSs in pandemic times requires rich information and decision support technologies (Trivedi and Zulkernine, 2020).
Scientific evidences have revealed that the transmission of COVID-19 is related to population mobility. For instance, Kraemer et al. (2020) and Chinazzi et al. (2020) discovered that the drastic measures taken by the Chinese's government substantially mitigated the spread of COVID-19. These measures were mainly based on prohibiting the population mobility, among others (Wu et al., 2021). Badr et al. (2020) found a correlation between COVID-19 and mobility patterns in a study performed in USA. In addition, mobility restrictions seriously affect economy as showed by Bonaccorsi et al. (2020). Therefore, a proper balance in the restrictions according to the advance of COVID-19 helps domain experts to make decisions about the restrictions to be applied in the health areas. Afterwards, fast routes are automatically computed based on these restrictions.
In this system, the CEP technology allows us to analyze and correlate real-time information on each area to automatically provide a set of indicators associated with the COVID-19 transmission level. Since this real-time information could be imprecise, we combine CEP with a Fuzzy approach. Therefore, a two-step process determines the mobility restrictions: (1) an expert system, designed as a Fuzzy Inference System (FIS) (Mamdani and Assilian, 1975), allows us to manage the linguistic variables representing the health risk levels based on such indicators, and (2) a domain expert determines the actions to be taken considering the health risk level obtained. These risk levels should be considered in a dynamic model able to capture the changing restrictions. We propose the use of a formal model to provide mathematical rigor. In this case, a CPN model is able to capture this dynamic behavior and this formalism is supported by several automatic tools that can be used to compute fast routes using real-time techniques, such as the simulation. In addition, the graphic nature of CPNs allows us to have a global and intuitive view of the system and the capability to study different scenarios automatically.
Therefore, the research objectives of this work are: • To develop an ITS based on the integration of CEP, CPN and fuzzy logic with the aim of addressing pandemic situations, which should be easily adaptable to other situations. • To provide a set of event patterns to automatically detect risk situations in real time. • To design a FIS to support domain experts in the decision-making process to adopt an alert level. • To create a CPN model to compute routes considering which areas are open and closed according to the current health circumstances.
The structure of the paper is as follows. Related works are discussed in Section 2. Section 3 presents a description of the COVID-19 situation in Madrid (Spain), which is the context of this ITS, considering health indicators and alert levels. A background on CEP, fuzzy logic and PNs is presented in Section 4. Section 5 describes the proposal, and Section 6 draws conclusions and future work.

Related work
Recurrent problems such as traffic accidents, air and noise pollution and long travel times are in the scope of the ITS (Picone et al., 2015), a cutting-edge area of study whose main aim is to optimize road traffic according to the associated problem. In this way, ITS plays a key role for both improving human life and modern economy (Bekiaris and Nakanishi, 2004). For instance, Lakshmi et al. (2022) focused on Collaborative-ITS (C-ITS), working on intelligent deep learning, based on short-term traffic flow prediction. The objective of this work was to assist in the optimization of signal timing by traffic signal controllers and route adaptation for travelers.
The use of fuzzy logic in the design of ITS has been studied for decades. Palacharla and Nelson (1999) presented a fuzzy reasoning model for dynamic travel time estimation. Naranjo et al. (2003) used logic fuzzy to present an ACC (Adaptative Cruise Control) for intervehicle gap keeping. Fuzzy logic is also used by Montero et al. (2012) in controllers for collision avoidance or by Alzamzami and Mahgoub (2019) in Vehicular Ad hoc NETworks (VANETs). More recently, Chen et al. (2020) proposed a fuzzy Markov prediction model with the aim of estimating the short-term traffic conditions in VCPS (Vehicular Cyber-Physical Systems) in urban environment. Moreover, the use of fuzzy logic with Neural Networks, known as FNNs (Fuzzy Neural Networks), for the design of ITS has been extended. For instance, Yin et al. (2002) and Quek et al. (2006) applied FNNs to predict the urban traffic flow. Fuzzy logic has also been used with other formal methods. For instance, Placzek (2013) proposed a traffic model based on fuzzy cellular automata. In the field of eHealth, Calvo et al. (2019) presented a methodology to analyze heart data using fuzzy automata.
Modeling ITS by using PN is not new. Cavone et al. (2018) presented a survey with contributions of PNs and extensions of PNs in the development of ITSs. Ng et al. (2013) reviewed the application of PNs in the scope of urban traffic control, and Qi et al. (2016) showed the use of PNs to model a real-time traffic emergency system for intersections to prevent accidents. CPNs were used by Huang and Chung (2008) to model traffic lights, by Zhou et al. (2013) to control traffic flow, and by Bentaher et al. (2019) in VANETs, who used Petri Nets Vehicular Communication protocol (PNVC). In the field of mobile robot navigation, Kumar et al. (2019) proposed a control approach based on Petri Nets to avoid intercollision among multiple humanoids during their navigation.
To address road traffic optimization, the integration of ITS with the CEP technology is appropriate, as demonstrated the works by Terroso-Saenz et al. (2012), Eswaran et al. (2015) and Figueiras et al. (2018), due to CEP's ability to correlate and analyze several thousands of data in real time. In this research line, our preliminary results (Díaz et al., 2020;Díaz et al., 2017), with the aim of controlling air quality in cities, not only integrated an ITS with CEP, but also with CPNs. On the other hand, integrating only CEP and Petri Nets, in Macià et al. (2016), Boubeta-Puig et al. (2019) and Valero et al. (in press) we used Petri Nets formalism as semantic validation of event patterns defined in EPL.
Since the purpose of the present work is to control the spread of COVID-19 in a determined geographic area, we extended our mentioned ITS to control air quality by using fuzzy logic. This fuzzy ITS continues being flexible but with the capability to capture important information to make decisions about traffic regulations. More specifically, this information about health parameters is gathered and processed using a CEP engine. A FIS is then used to help in making decisions about when and how to restrict the traffic in the affected areas. Afterwards, the CPN model allows us to calculate and re-calculate the traffic routes.
With respect to other works tackling different emergency situations using ITS, Ye et al. (2010) evaluated the use of rural transportation infrastructure in evacuation operations under hurricanes. Park et al. (2009) used an Advanced Traveler Management and Information System (ATMIS) as an emergency evacuation system under tsunamis, and Chang (2010) presented the available ITS solutions to overcome climate change risks. The main difference with our work is the all-inone solution based on CEP, fuzzy logic and CPNs, being CEP recently applied to emergency management in the presence of disasters as in Luthra et al. (2019), in airport use cases as in Mijović et al. (2019) and in nuclear disaster scenarios (Barthe-Delanoë et al., 2018) as in the Fukushima Daiichi nuclear plant.
In the context of the COVID-19 pandemic, Hendrickson and Rilett (2020) indicated several research areas to mitigate the negative effects of this pandemic, such as the use of activity-based travel information as an analysis tool and the complementariness of the transportation and public health systems with the goal of making transportation systems resilient, efficient, reliable, and sustainable in pandemic times. For instance, Bian et al. (2021) studied time lag effects of COVID-19 policies on transportation systems, including a comparative study of New York City and Seattle.

COVID-19 in Madrid
In this paper, the geographic area of the Madrid region (Spain) is studied as a proof of concept, but other geographic areas could easily be considered as well. In Madrid, we have considered seven health areas as illustrated in Fig. 1.  In October 2020, the Health Spanish Ministry published the COVID-19 Coordinated Response Actions for the Control of Transmission document. 1 Table 1 shows the indicators used to assess health risk levels, which have been obtained from this document. This table is divided into two sections. Section 1 contains the transmission indicators used to evaluate the transmission level in a certain area, while Section 2 contains the public health capacity indicators used to evaluate the occupation level of the assistance services offered by the public healthcare system in that area. Thus, the first section includes the cumulative incidence of COVID-19 cases diagnosed in the last 14 and 7 days for either general population and people aged 65 and over, the percentage of active infection diagnostic tests (PCR and antigen tests) and the percentage of traceable cases, i.e. positive cases linked to a previous patient. In the second section, we have the percentage of hospital beds occupied by patients with COVID-19 and percentage of Intensive Care Unit (ICU) beds occupied by COVID-19 patients.
The assessment of the health risk level is performed by a group of domain experts. The assessment is performed based on this information, but other information can also be considered, such as the proximity of a vacation period -to avoid an increase in population mobility -and a sudden upwards trend in COVID-19 cases. General alert levels, provided in this document, are based on these indicators. There are four alert levels -from 1 to 4 -when at least two indicators from SECTION I and one from SECTION II are: low (alert level 1), medium (alert level 2), high (alert level 3), and very high (alert level 4).
The action protocol defines a set of actions to restrict the mobility according to the alert level: for 1 and 2, recommendation to limit nonessential travels outside the territorial area; for 3, recommendation to the population to leave their home only when necessary, considering restrictions to coming in and out of the territorial area, except for essential activities; for 4, exceptional measures, including the request of the state of alarm, which allows the Government to restrict the fundamental rights of people.

Background
This section explains the background on CEP used for defining the event patterns related to COVID-19 indicators, the FIS used to determine risk levels and the CPN formalism.

Complex event processing
CEP (Luckham, 2012;Ramírez et al., 2021) is a powerful technology for detecting relevant situations in real time through the analysis and correlation of huge amounts of incoming data. These data can be obtained from several data producers, such as sensors and IoT devices (Ortiz et al. , 2022).
An event can be described as anything that happens or could happen. A simple event occurs at a point in time, while a complex event is a result of a set of other simple or complex events. From simple or complex events, higher complex events can be derived by matching event patterns, which specify the conditions to be satisfied for detecting such relevant situations in real time.
A CEP engine is the software needed to automatically detect these event patterns and, subsequently, to generate their associated complex events, which will be sent to the interested data consumers, such as actuators and dashboards. Fig. 2 illustrates the stages of the CEP technology: (1) the event reception, which consists of obtaining the simple events to be analyzed from an application domain, in that case, health data; (2) the event processing, in which these simple events are analyzed and correlated by the CEP engine, which generates complex events (health indicators) when an event pattern is matched; and (3) the event consumption, where the consumers will then make use of the complex events received.
Event Processing Languages (EPLs) are languages tailored for implementing event patterns . A particular EPL is provided by each CEP engine. As an example, Esper EPL is the language supported by the Esper CEP engine (EsperTech, 2022), one of the most known and widely used open source CEP engines.

Fuzzy Inference system
Fuzzy logic is an extension of classical Boolean logic in the form of a many-valued logic. It can be considered as an approach to the computing based on ''degrees of truth''. The first author who introduced this term through fuzzy sets was (Zadeh, 1965). A fuzzy set is a class of objects that uses a membership function which assigns a grade of membership to each object (a real value), ranging between zero and one. In contrast, in classical set theory, the grade of membership of an element to a set can only be 0 or 1. A fuzzy set is then a set of objects with non-well defined boundaries. Fuzzy logic can be used as a mathematical framework to model the uncertainty of human cognitive processes. Furthermore, a fuzzy logic inference system can be used to make decisions, which consists of a collection of fuzzy ifthen rules performing logical operations on fuzzy sets, thus providing an inference mechanism that simulates human reasoning procedures in knowledge-based systems.
More specifically, a Fuzzy Inference System (FIS) is a system that uses fuzzy set theory to map inputs (features in the case of fuzzy classification) to outputs (classes in the case of fuzzy classification). This mapping provides a basis from which decisions can be made. Mamdani's fuzzy inference method (Mamdani and Assilian, 1975) is one of the most commonly FIS used. This method involves the following steps to define a FIS (see Fig. 3): (1) definition of fuzzy sets (fuzzification of each input and output variable), (2) IF-THEN rules (knowledge base), (3) aggregation of the consequent by applying the rule (inference engine), and (4) defuzzification of the output.
There are toolboxes based on Phyton, such as Skfuzzy (Oliphant and Jones, 2020), which facilitate the implementation of a FIS, by implementing such third and fourth steps. By using Skfuzzy, for instance, we only need to define the input/output sets and the if-then rules.

Petri Nets
PNs are a widely used formalism for the modeling and simulation of systems in different domains, because of their mathematical rigour and the graphical representation of the models. Next, PNs are described using a city map as a running example. More detailed information of PNs and CPNs can be found in Peterson (1981) and Jensen and Kristensen (2009), respectively.
A PN is a directed bipartite graph that has two types of node: places (depicted as circles) and transitions (depicted as rectangles). Places and Transitions can be connected by directed arcs, either place-transition (PT) or transition-place (TP) arcs (see Fig. 4). All places connected with a transition by an arc from to are called the preconditions of , whereas those from to are the postcondition places. Places usually represent states or system conditions while transitions are the actions or events that produce changes in the system state. In Fig. 4, places represent the geographic locations associated to the health areas shown in Fig. 1 and transitions represent the actions to move to adjacent areas. Places are annotated by a set of tokens, which represent system states. The number of tokens on each place is called the marking of this place, and the marking of the PN is defined as the marking of all its places. For instance, in the PN model shown in Fig. 4, one token on a place indicates that there is a object/vehicle/person currently at that location. A transition is enabled and, thus, can be fired when all its precondition places have at least one token at the current marking, and with the firing of one token is removed from each precondition place, and one token is written into each postcondition place of . In Fig. 4, the current marking of place Nn3 is one token (depicted in green in the right-hand side of the place), and this place had initially one token (number above the current marking). The transitions enabled at the marking indicated in the figure are depicted in green. These transitions represent the possible movements from place Nn3. For instance, the firing of transition NtoNW removes the token from Nn3 and adds a new token in place NWn2. Thus, starting from an initial marking, with all the possible sequences of transitions that can be fired, we obtain the so-called reachable markings of PN. The set of all reachable markings from an initial marking is called the state space. Fig. 5 shows the state space of the PN of Fig. 4, as obtained from CPN Tools (Westergaard and Verbeek, 2022). The state space is in general infinite, but in the case of bounded PNs (the number of tokens on each place is bounded) this graph will be finite. However, even when the graph is finite, in many cases it will have a huge size, so different strategies can be applied to reduce the exploration, as explained in Díaz et al. (2020), or we can use simulation techniques for the analysis.
PNs can be extended in several ways. CPNs (Jensen, 1995) is a widely used extension, in which the basic model is extended considering tokens with information (data) and time. In this paper, we use CPN Tools to provide support for the creation, edition, simulation and analysis of CPNs. Thus, this paper makes use of CPN Tools notation.
In CPNs, a place has an associated color set (a data type), which specifies the set of allowed token colors at this place (values). Places are graphically annotated with their corresponding color sets, which are indicated in the bottom right-hand side of them. Tokens can also have a timestamp associated, indicating the time at which they will be  available in order to fire some transitions. Timed tokens are written as n'val@t, where indicates the number of tokens we have with value val and timestamp . Symbol ++ is used for the union of untimed multisets, whereas +++ is used for the union of timed multisets. Thus, a timed marking such as 1'5@10+++3'2@20 indicates that we have 1 token with value 5 and timestamp 10 and 3 tokens with value 2 and timestamp 20. Fig. 6 shows a CPN model with 2 zones interconnected. Each zone is represented by a place, both with the same color set INTlist (a timed list of integers), representing the zones that have been traversed by a car. Place Xn1 has 1'[1]@0++2'[1]@10 as initial marking, Yn2 is unmarked initially. Transitions XtoY and YtoX represent the movements, so a vehicle is represented by one token, which moves from one place to another. Both transitions have a guard to check that the destination zone number is not already in the list (see the predicates in brackets). Guards are used to restrict the firing of transitions, they can only be fired when their associated guards are evaluated as true under the binding used. In particular, the binding used for the firing of transition XtoY is shown in the gray rectangle (x = [1]), i.e. variable x is assigned to the list [1], which is the value of the token binded in the Xn1 place. Transitions can have a priority associated, which will be used in the event of a conflict. Arcs have inscriptions, which are expressions to produce multisets of colored tokens. In the case of pt-arcs these are usually variables that are bound to the token values in their preconditions, while for tp-arcs they are used to produce the tokens on the output places. As an illustration, variable in the figure will be bound to one token in place Xn1, so transition XtoY will only fire if zone 2 is not in the list , producing the list extended with 2 in the Yn2 place. Transitions can have a delay associated (inscription @+t), so the tokens produced by their firing are delayed by the time indicated ( ).
In this CPN, transition XtoY can be fired at time 0, and the marking obtained with this firing is that shown in green in the places of Fig. 6.
At this marking only transition XtoY can be fired, because the guard of transition YtoX is false. A second firing of transition XtoY at time 10 leads to the marking 1'[1,2]@20++1'[1,2]@10 in the Yn2 place.

ITS to control mobility
This section presents our ITS, called PITS, for facilitating the decision-making process on mobility restrictions during pandemic times. This is a novel ITS which integrates CEP, fuzzy logic and CPN as explained through this section.
In our system, we consider the mobility restrictions shown in Table 2 for the five level alerts considered depending on the risk assessments provided by the domain expert. Each Spanish regional government makes its own interpretation of the recommendations described in Section 3 for the different alert levels. In this paper, we have considered a restrictive interpretation of them. As an example, the proposal in that section recommends to limit the mobility for level 2, while we propose to close the mobility during the curfew hours. Thus, the proposal considered in the present work extends the measures indicated in Section 3 in order to reduce the SARS-CoV-2 spread. Fig. 7 depicts an overview of our proposal which consists of six steps. In step 1, we obtain data from several health areas. In step 2, these data are processed and correlated by the CEP engine, which is responsible for creating the complex events to feed the FIS system. Next, in step 3, the domain expert interprets the alert levels provided by the FIS system, emitting a set of alert levels for the different areas. In step 4, these values are then used in the CPN model to apply the mobility restrictions. Thereby, when a car driver asks for a fast route, in step 5, the CPN model simulation will provide this driver with the route solution in the last step 6. For this purpose, we simulate several cars with the same origin and the same destination, and the route for the fastest one is returned. We remark that the route thus provided will not necessarily be the optimal one, because this depends on the number of initial cars and the number of possible routes.

Pattern modeling and automatic implementation
Next, a set of event patterns to automatically compute the risk indicators specified in Table 1 is modeled and automatically transformed into code thanks to the use of the MEdit4CEP tool Boubeta-Puig et al., 2019). Fig. 8 shows the CEP domain modeled with the MEdit4CEP tool. This domain consists of two simple event types: AreaBedStatus and AreaTestStatus. AreaBedStatus is used to capture the information about the available hospital beds in a health area, and AreaTestStatus captures the information about the COVID-19 tests performed in a health area. We assume that the information for both event types is registered daily for each health area.
More specifically, AreaBedStatus has the following fields: a timestamp indicating the event date, the health area, number of occupied hospital beds, number of occupied ICU beds, number of beds with COVID-19 patients, and number of ICU beds with COVID-19 patients.
AreaTestStatus has the following fields: timestamp, health area, total number of inhabitants in this area, number of inhabitants aged 65 years or more, total number of COVID-19 tests done, number of COVID-19 tests done to people aged 65 years or more, total number of positive COVID-19 test, number of positive COVID-19 test done to people aged 65 years or more, and number of traceable positive COVID-19 tests in this area.
Taking now into account the information from Table 1, we have considered the following eight event patterns: • HOS: daily hospital-bed occupation rate by COVID-19 patients (beds occupied by COVID-19 patients/total beds). • ICU : daily critical-care-bed occupation rate by COVID-19 patients (critical-care-bed occupied by COVID-19 patients/total criticalcare-beds). • CI7 : 7-day case notification rate per 100,000 inhabitants.
As an example, Fig. 9 shows the HOS pattern modeled with MEdit4CEP. For each AreaBedStatus simple event, this pattern will produce a complex event, called HOS, with the following information: timestamp, health area and percentage of occupied COVID-19 beds. This percentage is obtained as the division between the number of beds occupied and the number of COVID-19 beds occupied, and multiplying the result by 100. Listing 1 shows the Esper EPL code automatically generated by MEdit4CEP for this pattern.
Listing 1: EPL code automatically generated by MEdit4CEP for the HOS pattern.
@Name( " HOS " ) i n s e r t i n t o HOS s e l e c t a1 . timestamp as timestamp , a1 . h e a l t h A r e a as healthArea , ( ( a1 . covidBeds / a1 . beds ) * 100) as covidBedPerc from p a t t e r n [ ( every a1 = AreaBedStatus ) ] Fig. 10 shows the CI7 pattern modeled with MEdit4CEP. For each AreaTestStatus event, this pattern checks if there are 6 more subsequent AreaTestStatus events that share the same health area. In that case, this pattern will create a new complex event, called CI7, with the following information: timestamp, health area and the 7-day case notification rate per 100,000 inhabitants. This is obtained as the sum of the positive COVID-19 tests per area, divided by the total number of inhabitants, and the result is multiplied by 100,000. Listing 2 shows the Esper EPL code automatically generated by MEdit4CEP for this pattern.
Listing 2: EPL code automatically generated by MEdit4CEP for the CI7 pattern.

a4 = A r e a T e s t S t a t u s ( a4 . h e a l t h A r e a = a3 . h e a l t h A r e a ) −> a5 = A r e a T e s t S t a t u s ( a5 . h e a l t h A r e a = a4 . h e a l t h A r e a ) −> a6 = A r e a T e s t S t a t u s ( a6 . h e a l t h A r e a = a5 . h e a l t h A r e a ) −> a7 = A r e a T e s t S t a t u s ( a7 . h e a l t h A r e a = a6 . h e a l t h A r e a ) ) ]
The other event patterns and their implementations are available for downloading from the following Mendeley repository: http://dx.do i.org/10.17632/tmfkmr9wgn.1.

The expert system: COVID-19 FIS
In this subsection, we present the FIS implementation for our PITS system.
In Fig. 3 we presented the different elements we need to implement a Mamdani's FIS. These elements are the input and output fuzzy sets as well as the if-then rules and the configuration parameters. The tool used to implement the FIS is the Skfuzzy Python toolbox. The specific configuration parameters used are the following: Defuzzification ⇒ centroid, Rule aggregation ⇒ combine all output membership function using a maximum operator, T-norm (AND) ⇒ minimum; and S-norm (OR) ⇒ maximum. The centroid computes the center of gravity of the fuzzy set along the -axis (the output fuzzy set). The rule aggregation specifies how the rule outputs must be combined when more than one is applied. The values for the AND and OR operators determine how to obtain the truth degree when we consider several inputs in the same rule.
For the sake of simplicity, the FIS proposal only considers three input variables (CI7, HOS, ICU), whose values are provided by the CEP engine, and one output variable (Alert). The input variables are: CI7, 7-day case notification rate per 100,000 inhabitants; HOS, hospital-bed occupation rate by COVID-19 patients; and ICU, critical-care-bed occupation rate by COVID-19 patients. Each input variable is defined using five different levels of risk: ''Normal'', ''Low'', ''Medium'', ''High'' and ''Extreme''.
Each variable has fuzzy sets associated, and for each membership function we use a trapezoidal function, taking into account the indicator levels indicated in Table 1. Trapezoidal functions are commonly used for membership functions, since they are simple and computationally efficient (Sadollah, 2018). Fig. 11 shows the fuzzy sets for the input and output variables. As mentioned, the actions to be taken for these levels are more restrictive that those showed in Table 1, to prevent the scenario to get worse. Table 3 shows the if-then rules for this proposal. As we can observe, an advantage offered by fuzzy logic is that its computing, imitating the human reasoning, allows the system to be easily adapted and extended to other situations of interest by, for instance, updating the FIS rules. Fig. 12 depicts the surface for the alert output variable when the input variables are CI7 and HOS, keeping constant ICU. Five surfaces are then depicted, considering five values for ICU (from 2 to 27.5). The left-hand side graph corresponds to ICU = 2 (normal), and we can observe that for values of HOS and CI17 close to zero the alert level is 0, but the alert level increases as HOS and/or CI17 values increase until reaching an alert value close to 4. In contrast, for ICU = 27.5 (extreme), the alert value will always be 4, independently of the values of HOS and CI7. In this last case, only Rule 1 in Table 3 is applied.
However, when ICU is 2 (first graph), if we consider values 59.7 and 10 for IC7 and HOS, respectively, rules 3 and 19 are applied at the same time with a combined output of 2.65 for the alert level. The domain expert is then in charge of interpreting this value, and decide whether the alert level is 2 or 3, possibly taking into account some other considerations/indicators.

A CPN model as a map to compute routes
A CPN is used to represent the city map, 2 in a similar way as our running example in Section 4.3. The CPN model proposed to compute available routes consists of 4 pages. This is a mechanism that CPN Tools facilitates to produce complex models in a modular way, splitting the model into pages, the glue being the so-called fusion places, which are places that technically represent a same place, i.e., a place that appears in different pages. These fusion places are identified by a label, indicating their associated fusion set.
In the following subsections we describe these CPN pages of the model. 2 We use the concept of city map as a geographic area map.

Main page: the map
This page models how a token (a car) moves across the different areas of a map. The color set of these tokens has the following information: final destination, list of traversed zones, and accumulated time for the journey. Furthermore, these tokens are timed, which means that our model is a timed CPN, in which the tokens carry a timestamp indicating the time at which they are available. When a token moves from one area to another, the token age is increased to represent the duration of this step. We use the color set Zo for the zone places:   13. Excerpt of the City_Map page (Fig. 14).
Alert levels are associated to zones, including the places alertZi ( = 1, … , 7), with the color set defined as follows: colset A=int with 0..4; The token value on each one of these places will then indicate the current alert level in the corresponding zone. Fig. 13 shows an excerpt of the whole CPN with the movements throughout the city map (see Fig. 14). The movements between zones are represented by transitions. For instance, transition WtoNW in Fig. 13 represents the movement from zone Wn1 to NWn2. The token 1'(2, [1], 0)@0 in place Wn1 represents a car whose destination is NWn2 (the zone number is the number at the end of the place names), which is at zone Wn1 (the only one in the list), and has not yet moved. Transition WtoNW is depicted in green, which means that it is enabled and can be fired at the current time. The guard pass associated to these transitions is defined as follows: fun pass(j:INT,x:Zo,ai:A,aj:A,t:INT,cij:INT)= isOpen(j,x) andalso OAlert(ai,t) andalso OAlert(aj,t+cij) fun noReturn(j:INT,x:Zo)= not(mem (#2x) j) fun isDest(x:Zo)=hd(rev(#2x)) = #1x fun isOpen(j:int,x:Zo) = noReturn(j,x) andalso not(isDest(x)) This guard pass is used to check that the movement is allowed.
The following conditions must be satisfied: 1. The car has not yet reached its final destination (function is-Dest). 2. A car cannot pass twice by the same zone (function noReturn).
3. The alert conditions allow the movement, as explained below.
Notice the use of the predefined functions mem, which checks whether an element belongs to a given list, hd, which returns the head of a list, and rev, which returns the list in reverse order. Alert functions are defined as follows: fun OAlert(a:A,t:INT) = if (a=0 orelse a=1 orelse (a=2 andalso day_hour(t)>q1 andalso day_hour(t)<q2 ) orelse (a=3 andalso week_day(t)<6 andalso day_hour(t)>q1 andalso day_hour(t)<q2 )) then true else false; This function implements the mobility restrictions indicated in Table 2 for the five alert levels considered. Functions day_hour and week_day are used to compute the day and hour of a given value in minutes, using as a reference the first Monday at 0 h 0 min when the protocol is enacted. The constants q1 and q2 determine the time when mobility is allowed depending on the alert level.
fun day_hour(t:INT)=(t div 60) mod 24; fun week_day(t:INT)=(((t div 60) div 24) mod 7)+1; When transition WtoNW is fired, the token on the Wn1 place is removed, and a new token is written into the NWn2 place, using the function traverseSection to produce this new token. This function preserves the first field (destination), extends the list of traversed zones by including zone , and adds the time to complete this movements to the third field. The definition of this function is then as follows: fun traverseSection(j:INT,x:Zo, cij:INT)= (#1x, (#2x^^[j]),#3x+cij) In Fig. 13, the token (2,[1],0)@0, will be consumed and a new token (2,[1,2],4)@4 will appear at place NWn2, if the travel time wTnw is four minutes. Fig. 15 shows the EndDestination CPN page. Once a token (car) has reached its destination, the corresponding endi transition, which has P_HIGH priority, is fired (see guard isDest ). This CPN page is used to obtain the fastest route for the movement represented by the token on the corresponding destination zone for this simulation. With the firing of the endi transition, the token is removed from the destination zone and a new token is written into the Destination place, with the list of traversed zones and travel duration (color set De).

colset De=product INTlist*INT;
There is a control place, named end_d, which is used to ensure that only the fastest route is stored at Destination, i.e., with this place we only capture the information for the fastest route for the simulation performed. Fig. 16 shows the Time_alerts page of the CPN model. The righthand side part of this CPN generates the random alert levels for the different areas and the left-hand side part is used for time elapsing, using transitions tick (1 min) and new_day (days). The right-hand side part of Fig. 16 consists of a set of alert places alertZi for the different areas, and both transitions gen_alert and set_alert, which are used to produce the random alert values using the functions genAlert and setAlert on a daily basis (p_init is marked with the firing of new_day). These random values are obtained in two steps in order to avoid huge differences between the alert levels of the health areas, only allowing a maximum difference of two alert levels between areas. In addition, higher alert levels will have smaller probabilities than medium and low levels. In the first step, genAlert generates a value between 1 and 3 in place g_init by the firing of the gen_alert transition. This function establishes a higher probability to the alert level 1 (50%), a probability of 35% for alert level 2 and 15% for level 3. Transition set_alert is then fired after gen_alert, but at the same time instant (see Fig. 16), to produce a value between 0 and 4 in the alert places alertZi, using the setAlert function. This function increases or decreases in one unit the value obtained by genAlert  with a probability of 25%, respectively, otherwise, with a probability of 50% returns the same value. Place g_init in Fig. 16 is marked with one token with value 3, and the alert levels obtained for the different areas vary between 2 and 4, as obtained using the custom distributions shown above. On the left-hand side of the figure time elapsing is modeled. As mentioned previously, CPN Tools only re-evaluates guards when a transition is fired and not when time elapses. Thus, we need a direct control on time to allow the re-evaluation of guards as time advances. Place init_time is a timed integer token, whose value is the current model time, whereas time_inf keeps this information in an untimed place. This is important to allow the reading of the time without aging it, which would disturb the net behavior.

Time_alerts page
Notice that both transitions tick and new_day have the lowest priority in the CPN model, so time elapsing can only occur when no other transition can be fired. Regarding the guards, t<max is used to avoid an infinity ticking behavior, and t>0 avoids to produce the alert values twice in time zero. Both transitions are mutually exclusive, tick is used to advance the time in minutes, except when a new day starts, in which case new_day is fired.

Model simulation
Simulation is used in order to produce a fast route, by using a certain number of cars (tokens) traveling from the same origin to a same destination. Thus, the key point is that all of these cars are in a race and the winner is the fastest one. As we increase the number of cars (tokens) in the model we will have a greater probability to obtain the fastest route. Of course, the more possible paths to reach the destination, the more number of tokens we should include to obtain a good result.  However, as we intend to obtain fast routes, but not necessarily the fastest one, we have considered in all cases 100 cars (tokens), and the experiments have demonstrated that with this number we always obtain the fastest route for the case of Madrid. Notice that simulations terminate when no transition can be fired in the CPN model. Furthermore, before simulating the CPN model, we need to set the travel times (in minutes) between the different areas. These times are shown in Table 4. These values are specified using constants in the model. For instance, wTnw is the travel time between areas Wn1 to NWn2 (4 min).
In addition, the curfew time begins at q2 hours at night, and finishes at q1 hours in the morning. We assume q1=7h and q2=22h. Under these conditions, the marking in the Destination place (Fig. 15) shows the best route to travel from area Nn3 to area Wn1. This route was obtained on a Monday at 3h12m (see the starting time in Fig. 14 for place Nn3, 192 min). We can observe that the obtained route Nn3->Cn5->Wn1 has as total travel time 12 min. The alert levels considered for this simulation are the following: 0 for SEn6, 1 for Wn1, Nn3, En4, Cn5 and Sn7; and 2 for NWn2.
Other alert levels could be considered. For instance, taking 1 for Wn1, NWn2, Nn3 and En4; 2 for SEn6 and Sn7 and 3 for Cn5, the route obtained would then be Nn3->NWn2->Wn1 with a total travel time of 6 min.
In the case that the alert levels were 1 for Nn3, En4, SEn6 and Sn7; 2 for NWn2 and 3 for Cn5, then the route obtained would be Nn3->En4-> SEn6->Sn7 ->Wn1 with a total travel time of 19 min.
Regarding the scalability of the model, depending on the number of areas and the number of connections between them, we only need to replicate Fig. 13 and adapt Figs. 15 and 16 to produce the final model, as shown in Fig. 14. With respect to the simulation time, notice that a car cannot traverse twice the same area, which means that a transition cannot be fired twice for the same car (token), and thus, the simulation time is linearly bounded by the number of transitions.
Another point of interest is termination. It can be the case that there is no available route to the final destination, due to the current restrictions (connections closed), so our proposal would not be able to provide a solution. In addition, it is also possible that such a route exists, but it cannot be found if few cars have been considered as initial marking.
With respect to the net behavior, for small city maps we can perform some analysis using the reachability graph (markings that are reachable from the initial one), which can be generated using the CPN Tools engine. However, notice that in general, as mentioned in Section 4.3, the reachability graph can have an enormous size, and actually, it can only be constructed for bounded Petri nets. In the case of timed CPNs this problem is worse, so in general, state exploration cannot be used to analyze the net behavior. In our case, we can produce the reachability graph for some specific configurations and only for small city maps. As an illustration, we have generated the reachability graph for this CPN considering only one car and taking all alert levels equal to 1 (low risk) and a time limit of 292 min, starting at time 192. Thus, we are only interested in the routes that are reachable within 100 min from the starting time. With this configuration, the reachability graph has been constructed, and it consists of 2577 nodes and 2580 arcs. In addition, there are 25 dead markings, and 20 of them are terminating routes, from area 3 to area 1. One of these 20 terminating markings is the one obtained as solution by the simulations, which takes 6 min to reach the destination.

CPN external communication
In the previous simulations we have used random values for the alert levels, as produced by functions genAlert and setAlert.
Now, the CPN model is fed with the alert levels produced by our FIS system implemented in Python, with the help of the domain expert. This information is provided using the five alert levels defined in Table 2 and encoded by color set A. Gallasch and Kristensen (2001) presented the Comms/CPN library, which allows us to establish a communication between CPN models and external processes. The Python FIS system uses this library to send the alert levels to the CPN model according to the authority decision about the mobility restrictions.
Comms/CPN is designed to act as an interface between CPN models and TCP/IP containing all TCP/IP and socket related primitive functions. The connection strategy is based on a unique identification string and a set of attributes to identify the IP and port used. The library has the capability to either send and receive all types of data, which includes the data types defined by the user (color sets). Encoding and decoding functions are provided with this purpose. The primitives used in an interaction include connect, accepts, send, receive and disconnect in the external part implemented in Standard ML and Java, while openConnection, acceptConnection, send, receive and closeConnection can be used to model the interaction in the CPN model. Fig. 17 depicts the implemented model to read the alert levels provided by the FIS system implemented in Python. Constant gen-Type is introduced in the CPN model to decide whether the alert There is an input section, which indicates the input variables used, an output section, which indicates the variables which will contain the results obtained in this interaction, and the action section, in which the actions to be performed in this interaction are defined.
For instance, the interaction associated to transition t_connection opens a connection ''Con1'' in the localhost using the port 9000. This connection can now be used by the transitions t_status1 and t_data to gather the alert values that will be stored in the corresponding alert zone places alertZi, using the variables sti and the receive routine over connection ''Con1'', using the stringDecode function. Function toInt is used to transform a string into an integer number.
Finally, notice that the CPN model has been designed to be working continuously, so the connection never closes.

Conclusions and future work
In this paper, an ITS, called PITS, was proposed considering different scenarios of mobility restrictions according to the alert levels associated to the spread of the COVID-19.
This novel proposal, integrating CEP, fuzzy logic and CPN, fulfills the following desirable aspects in an ITS for these situations: (1) it is consistent with the pandemic emergency situation, (2) it is flexible so as to modify and adapt the model to new situations, and (3) it is simple, but rich enough to allow us to make decisions and draw conclusions about mobility restrictions.
Health indicator data are assumed to be provided by a set of health stations (hospitals, health primary centers, clinical laboratories, among others). The CEP technology is then used to process the information gathered and determine the official health indicators. Specifically, we used the MEdit4CEP tool to specify the event patterns regarding the indicators: CI7 (cumulative incidence of COVID-19 cases in the last 7 days), HOS (daily percentage of confirmed hospitalized COVID-19 cases with respect to full capacity of the hospital), ICU (daily percentage of confirmed hospitalized COVID-19 cases in ICU beds with respect to full capacity of the hospital in ICU beds), CI14 (cumulative incidence of COVID-19 cases in the last 14 days), POS (percentage of positive in the tests of COVID-19 in the last 7 days) and TRA (percentage of traceable positive cases with respect to all positive tests in the last 7 days).
Then, a FIS is applied considering the three first indicators in order to determine a preliminary crisp number. This number is rounded to a risk level according to the domain expert criteria, possibly considering other indicators.
The system, with the help of the domain expert, provides the mobility restrictions for the affected areas. The CPN model of a city map was then defined considering that some connections between the areas could be closed at certain hours, depending on the alert levels. Afterwards, simulation was used to obtain fast routes from the CPN model, by feeding the CPN with a large number of tokens that compete to reach a same destination.
Moreover, this is a scalable proposal, since we could extend the system by including a great number of zones as well as varying the time periods to cross from one zone to another. In addition, it can be adapted to other scenarios and restrictions: a different topology could easily be considered, travel times could also be adapted to the vehicle type, the user might choose the route by avoiding to transit in the most affected COVID-19 areas, among others.
As future work, we plan to include traffic flow data measured by sensor stations and to incorporate queueing theory and machine learning techniques as in Gal et al. (2017) for traveling time prediction. Other health indicators or emergency situations, such as traffic accidents, could be included in our FIS, or in the final decision made by the domain expert to close an area. This decision process can also be performed using group consensus techniques as stated by Pérez et al. (2018). We plan also to extend our proposal by applying these indicators and techniques to face other emergency scenarios, such as air pollution, floods and earthquakes.

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.