Application of Hierarchical Colored Petri Nets for Technological Facilities’ Maintenance Process Evaluation

: The high reliability of modern engineering systems is achieved by performing predictive maintenance. Mathematical models based on stochastic timed colored Petri nets are an effective tool for developing complex production processes for Industry 4.0. This article discusses the maintainability evaluation used in hierarchical Petri net models. The hierarchical simulation model was built using timed colored Petri nets, and was constructed with four levels of repair and maintenance modules. New module structures are proposed for simulating the schedule of production tasks and interaction with technological units. The emphasis is on the processes of predicting maintenance and repair, moving units to service, replacing units, and forming a reserve. The design of the simulation modules allows the setting of probabilistic parameters for the distributions of equipment failures, requests for unit maintenance, repair time, and recovery time after repair. The article proposes to use the hierarchical Petri model in conjunction with solving the problem of minimizing the cost of service. The iterative procedure consists of obtaining an approximate unit distribution by tasks, subsequent simulation of the technological process, and adjusting the optimization problem constraints. For example, the hierarchical Petri net is considered to assess the maintainability of autonomous agricultural vehicles. The results of the simulation experiments are presented. A simulation of the agrotechnical production process was performed, during which vehicles were maneuvered, taken out for repair or maintenance, and returned to the reserve fund. The interdependencies of preventive maintenance periods, service operations, failure rates, and predictive maintenance requests were obtained in order to comply with the task scheduling. The proposed model is a generalization, but it is especially effective in studying mobile equipment servicing.


Introduction
The development of technologies in industry moves along the path of complicating technological operations, creating flexible and robotic industries. At the same time, the requirements for the reliability of technological equipment are increasing. There is a trend towards a shift from preventive maintenance to predictive maintenance of equipment, which corresponds to the general direction of technological process development according to the concept of Industry 4.0 [1,2].
Today, virtual testing and virtual commissioning based on the behavior simulation of production systems are widely used. Such technologies rely on a model-based development [3,4]. At this stage, the studies of maintenance and repair processes become essential, as they provide the organization of the predictive maintenance system at the time of actual product output. Another important aspect is the continuous monitoring of technological equipment in the production process to replace parts or serviced units in a timely manner, predicting failure or defect.
For many applications in industry, discrete-event simulation is the most appropriate tool for studying technological processes and equipment properties. Many kinds This article contains the following parts: Related works are presented in Section 2. The problem statement of evaluating maintenance and repair efficiency is discussed in Section 3. Section 4 briefly describes the definitions of colored Petri nets (CPNs) and timed colored Petri Nets (TCPNs). Section 5 presents the hierarchical Petri net model (HPN), and describes how this architecture is abstracted and modeled using TCPNs. Sections 6 and 7 provide an example of the use of HPN to simulate an autonomous agricultural vehicle system and discuss the results obtained. The future extensions to the proposed approach are presented in Section 8.

Related Works
Models based on Petri nets have been used to describe discrete-event systems with the parallel-serial nature of the processes. The reason for choosing PNs is that, unlike traditional models for modeling discrete events (DEs), the PN model provides an intuitive graphical representation of the studied complex system, and has been proven to be more flexible and efficient [7][8][9]. Among the many practical applications of Petri nets, works related to the modeling of flexible manufacturing systems (FMSs) stand out. Early work has shown the effectiveness of various Petri nets for simulating production systems for defect and failure prediction [10][11][12]. In the subsequent period, new modeling tools for studies of production systems were built, which describe the process of equipment degradation and deterioration [13,14]. In [12,15], high-level Petri nets were developed, corresponding to the hierarchical organization of production structures. This explains the continuing interest of researchers, which has led to the creation of various extensions of Petri nets. As a result, the most widely used models are colored CPNs [16,17], timed TCPNs [18,19], and stochastic SCPNs [20].
Another relevant area of Petri net model application is in developing, testing, and verifying software systems, computational processes, and communication protocols. Mainly, the successful application of Petri nets should be noted in the description of information processing, microprocessor systems, and others.
In such systems, there are strict requirements for fault tolerance and timing relationships. Kumar et al. [21,22] applied CPNs to formalize component operation scheduling, and presented a method for analyzing system dependencies based on a service-oriented architecture (SOA). The various types of dependency relationship are formalized using service algebra. Such a model-driven approach provides a process for reworking and restructuring the software application. Del Foyo and Silva [23] developed a similar approach for requirements analysis in real-time systems. They proposed a reachability-based algorithm for real-time testing of discrete systems, in which timed computational tree logic is used as a specification language, and timed transition graphs are introduced to represent system behavior.
Among a wide range of topics for the practical use of PNs, one should highlight the construction of stochastic Petri nets for studying the degradation, aging, and deterioration processes of various units, mechanisms, and machines. The study of these phenomena and processes is necessary for the organization of maintenance and repair. A review of the existing research in this area shows that many researchers successfully use the apparatus of Petri nets to design reliable and maintainable industrial systems in various areas of technology.
Preventive and predictive maintenance strategies are used in technological processes; however, discrepancies exist between the mathematical models used and the actual maintenance activities. One of the main reasons for this is insufficient mathematical modeling methods to accurately describe the equipment interactions during maintenance. In this regard, the use of simulation models on Petri nets is actively developing.
The relevance of modeling the interactions between units and component manufacturing processes causes the active development of Petri nets in this area. Boukredera et al. [24] developed color PNs as a formalization of the temporal aspects of the elements functioning in a decentralized task distribution. Simultaneously, the presentation of the object as a multi-agent system is combined with the CPN model simulation. The CPN model for production-logistics problems, which implements the self-adaptive collaboration method, was investigated by Guo et al. in [18]. The objective of the proposed TCPN model is to minimize the waiting time of all jobs, the makespan, and the electricity consumption of all machines and AGVs. Three key performance indicators, including waiting time, makespan, and electricity consumption, are considered. Pla et al. suggested a new Petri net extension for modeling workflow activities together with their required resources: resource-aware Petri nets (RAPNs) [25]. Workflows are modeled with Petri nets, since they are a wellknown tool for workflow modeling, and offer a wide range of extensions to facilitate this task. In the article, five different scenarios were considered for testing the latency of the maintenance prediction procedure. Each scenario includes a specified number of jobs and different resources depending on the source of the workflows.
Technological processes are stochastic due to the impact of some external random factors. Accordingly, many kinds of research have been conducted on creating Petri nets to simulate random events with a given probability density distribution. Various modifications of stochastic colored Petri nets (SCPNs) have been developed for these purposes. In [26], Santos et al. developed generalized SCPNs with predicates for Monte Carlo simulation. The times to component failure are considered to be the Weibull distribution. Marsan [27] proposed to simulate random processes at PN transitions using delays with negative exponential probability density functions. Stochastic colored Petri nets are used for a comprehensive class of objects, particularly when assessing maintainability and reliability. Lu et al.,in [17,28,29], also investigated the application of SCPN tuples and the calculation of the required resources according to the equations of the model state. Consumable and reusable resources are represented as multisets in SCPN places. The simulation of maintenance allows for the estimation of resource requirements at each stage.
There are known examples of the effective use of SCPNs in studying the maintenance of an electric car-sharing system [30], researching the degradation and deterioration of ceramic claddings [31], and modeling cyber-physical systems [32]. The simulation models are developed, integrating physics-based and dependability models in order to monitor the state evolution of dam protection from natural phenomena and improve maintenance decision-making processes [33].
Researchers at the University of Nottingham, UK, actively work on the theory and practical use of simulation models for railway infrastructure. Le, Andrews, and Fecarotti in [34][35][36] presented a bridge model developed based on the Petri net (PN) approach. Their method allows for detailed modeling of the individual components in the structure, while maintaining the analytical problem at a manageable size, resulting in an efficient analysis. The bridge model is formed from sub-models of each of the bridge components, and considers the component deterioration process, the interactions and dependencies between different component deterioration processes, and the inspection and maintenance processes. The model states are defined based on the actual degraded component conditions that they experience.
In [37], several types of Petri nets with different properties were introduced. The extension of Petri nets, adaptive Petri nets (APNs), which satisfy the specific requirements of Appl. Sci. 2021, 11, 5100 4 of 26 railway rolling stock maintenance, was proposed. The authors developed an application of APNs in combination with Monte Carlo simulations to evaluate the maintenance of railway rolling stock.
The development of these approaches has continued with the creation of offshore wind turbine models. Le and Andrews in [38] used stochastic Petri nets. This method's versatility made it possible to include details of degradation and maintenance operations in the model. Dependent deterioration processes between subsystems of wind turbines were considered, defining the maintenance rules for early indication of failure to ensure replacement. Leigh, Yan, and Dunnet produced simulation models of offshore wind turbines [39,40]. Their model is based on SCPNs, describing three types of maintenance: periodic, conditional, and corrective maintenance. The wind turbine conditions were monitored to determine the frequency of service, and then the repair and maintenance processes were simulated.
On the other hand, one more positive property of CPNs should be noted: implementing the hierarchical models of complex systems. The functionality of many modeling systems that support Petri nets allows the realization of both top-down and bottom-up designs. Lorbeer [41] proposed reconfigurable Petri nets based on a hierarchical principle. Sheng et al. [42,43] developed hierarchical CPNs to simulate the air fleet service. These papers presented hierarchical models of a fleet operation and maintenance process, which considers mission-oriented operation, multiple-level maintenance, multiple cannibalization policies, maintenance schedule, and spare inventory management.
One work by Baruwa and Piera [44] was devoted to managing autonomous vehicle schedules, which is closest to the area of our research on autonomous agricultural vehicle maintenance. The attention of researchers has also been paid to the planning of mobile robot movement [45], human-robot interaction [46], and the positioning of autonomous vehicles on territory [47]. However, this work did not consider the procedures for servicing autonomous cars based on failure and defect prediction.

Organization of the Maintenance and Repair of Technological Process Units
We assume that the main component of the technological process is the "Task." The unit of equipment used in the technological process is denoted as "Unit." We consider a set of technological tasks z k ∈ Z, k = 1, K,, a set AU of available units u n ∈ AU, n = 1, N,, and a Gantt chart G t , which describes the schedule for performing technological tasks.
The maintenance and repair management system should perform the following functions: 1.
The model assigns available units u n for tasks according to the schedule G t . 2.
The system performs other tasks in case of the absence of the necessary units for task z k . When the unit becomes available, the model assigns them to the delayed task z k . 3.
The model removes a unit from service in a defect or equipment failure, and replaces it with an available unit from the reserve AU.

4.
When a unit maintenance request is received, similar actions are taken.

5.
Continuous monitoring of the unit parameters "residual resource" and "time to preventive maintenance". When the specified resources are depleted, the unit is decommissioned and replaced with a reserve one. 6.
The model controls the unit queues for repair, maintenance, distribution, or recovery of consumable resources. 7.
Returning serviced units to reserve AU for further use in the technological process.
A generalized hierarchical structure for scheduling production tasks, assigning units, and maintenance and repair processes is shown in Figure 1. The first level L 1 is formed by technological tasks performed according to the Gantt chart. The diagram shows units' movement from the state of availability to the state of activity (level L 2 ), as well as the transfer of units for repair or maintenance (level L 3 ). It is also possible to use the mobile service station MM, located closer to the technological process. The level L 4 corresponds to consumable resources Cs and reusable resources Ru for maintenance and repair.
where ID is the identification number of the unit, Md is the model (type) and modification of the unit, trt is the value of the unit operating time after the last maintenance or repair procedure, tRL is remaining useful life (RUL), tMT is remaining time before scheduled maintenance, tti is the start time of the next exploitation period, and tta is the accumulated unit operating time. if tI = tPrM then: unit predictive replacement; if tI = tF then: unit corrective replacement; where tPrM is the prognostic maintenance time, and tF is the time of a failure occurrence.
As follows from Figure 1, the modeled object has a hierarchical character, and belongs to the class of discrete-event systems. Therefore, the adequate model should also have a hierarchical structure. We have chosen hierarchical timed colored Petri nets to simulate the schedule, task execution events, maintenance, and unit repair. Figure 2 shows the relationship of the main modules of the hierarchical HPN model. We describe the unit with a vector of parameters: where ID is the identification number of the unit, M d is the model (type) and modification of the unit, t rt is the value of the unit operating time after the last maintenance or repair procedure, t RL is remaining useful life (RUL), t MT is remaining time before scheduled maintenance, t ti is the start time of the next exploitation period, and t ta is the accumulated unit operating time.
Decision making is carried out according to the condition-based policy. The inspection time t I is related to the timing of the serviceability, degradation, and deterioration states of the unit components: if t I ≥ t RL or t I ≥ t MT then: preventive replacement of unit; if t I = t PrM then: unit predictive replacement; if t I = t F then: unit corrective replacement; where t PrM is the prognostic maintenance time, and t F is the time of a failure occurrence.
As follows from Figure 1, the modeled object has a hierarchical character, and belongs to the class of discrete-event systems. Therefore, the adequate model should also have a hierarchical structure. We have chosen hierarchical timed colored Petri nets to simulate the schedule, task execution events, maintenance, and unit repair. Figure 2 shows the relationship of the main modules of the hierarchical HPN model. The ZSch module, based on the specified Gantt chart Gt, builds a task graph and assigns unit types for each task. A PZS set of assigned units are transferred to the ZO module to complete tasks. It is possible that a technological task cannot be performed using the available set AU units. Such tasks PZA are then removed from the model before decision making on the new unit's inclusion in the AU. During the execution of task Z, the following events may occur: (a) equipment failures; (b) requests for maintenance of The ZSch module, based on the specified Gantt chart Gt, builds a task graph and assigns unit types for each task. A P ZS set of assigned units are transferred to the ZO Appl. Sci. 2021, 11, 5100 6 of 26 module to complete tasks. It is possible that a technological task cannot be performed using the available set AU units. Such tasks P ZA are then removed from the model before decision making on the new unit's inclusion in the AU. During the execution of task Z, the following events may occur: (a) equipment failures; (b) requests for maintenance of units. Unit repair and maintenance operations are simulated in the MR module.
It is known that the coordination of task schedules with assigned technological equipment is the generalized assignment problem solution [48]. However, solving this problem poses difficulties for a large number of tasks and units. Furthermore, there are problems with the use of units in parallel tasks. We proposed to use an optimization-simulation approach to solve such problems [49,50]. This approach consists of the solution to the optimization problem and the study of the simulation model combined.
The optimization problem of unit allocation has the form: under constraints: where x n is the Boolean optimization variable, specifying the unit allocation D(x n ), J is the number of constraints, N is the number of units, N j is an index set of units for the Jth constraint, N j ≤ N, C n are capital costs of units, and C O n are operating costs. Variable x n = 1 if the unit is assigned to execute a task in Z scheduling. The problem shown in Equations (2) and (3) is not final, but serves the initial unit distribution by tasks in the simulation model. Simulation in HPNs is carried out with algorithmic restrictions. This allows the detection of situations such as deadlocks, resource insufficiency, and the simultaneous use of resources.
Thus, in general, decision making is an iterative process of solving an optimization problem, simulating, evaluating the results obtained, and returning to the optimization problem to correct the constraints if the algorithmic constraints are not satisfied.

Formal Description of Timed Colored PNs
We use a formal description of colored Petri nets as nonuples [16]: where: 1. P is a finite set of places.

2.
T is a finite set of transitions such that P∩T =/0.

3.
A ⊆ P × T ∪T × P is a set of directed arcs. 4.
C is a finite set of non-empty color sets. 5.
V is a finite set of typed variables such as Type [v] ∈ C for all variables v ∈ V. 6.
S: P→C is a color set function that assigns a color set to each place. 7.
G: T→EXPR is a guard function that assigns a guard to each transition such that Type [G (t)] = Bool. 8.
E: A→EXPR is a function that assigns an arc expression to each arc such that Type [E (a)] = C (p) MS , where p is the place connected to the arc a. 9.
I: P→EXPR is an initialization function that assigns an initialization expression to each place p such that Type [I (p)] = C (p) MS .
Timed colored Petri nets are: where CPN stands for colored Petri net, and Θ 1 , Θ 2 , and Θ 3 are time delays assigned to net places, arcs, and transitions, respectively. We used CPN Tools 4.0.0 [51] to implement a hierarchical model of technological processes and equipment maintenance and repair. This software package's capabilities allow the multiset processing equipment to consider the timing relationship Gantt chart in order to analyze process control features.

General Scheme
The design of the hierarchical HPN model was carried out using a top-down development. The top-level page uses subpages for which only a set of inputs and outputs are still defined. The structure of the hierarchical HPN model is depicted in Figure 3.
8. E: A→EXPR is a function that assigns an arc expression to each arc such that Type [E (a)] = C (p)MS, where p is the place connected to the arc a. 9. I: P→EXPR is an initialization function that assigns an initialization expression to each place p such that Type [I (p)] = C (p)MS.
Timed colored Petri nets are: where CPN stands for colored Petri net, and Θ1, Θ2, and Θ3 are time delays assigned to net places, arcs, and transitions, respectively. We used CPN Tools 4.0.0 [51] to implement a hierarchical model of technological processes and equipment maintenance and repair. This software package's capabilities allow the multiset processing equipment to consider the timing relationship Gantt chart in order to analyze process control features.

General Scheme
The design of the hierarchical HPN model was carried out using a top-down development. The top-level page uses subpages for which only a set of inputs and outputs are still defined. The structure of the hierarchical HPN model is depicted in Figure 3. Hierarchical PNs include four levels of modules. The first level consists of the following modules: 1. ZSch module handles task scheduling and unit assignment; 2. ZO module handles task operations; 3. MR module handles maintenance and repair performance; 4. RS module is the resource for maintenance and repair.
The first level is formed by the modules described in the previous paragraph. The main ZO module contains K basic ZExec modules of the task's operation, where K is the number of tasks in the technological process schedule. The ZExec module provides a simulation of unit assignment and basic task operations. Each ZExec module is associated with its own RTA (runtime analyzer) module, which evaluates the time parameters of running units and determines failures or predictive maintenance requests. The RTA module simulates an ensemble of m units for a specific task zk. The Unit ID sub-module determines the accumulated operating time, remaining useful life, and time before pre- Hierarchical PNs include four levels of modules. The first level consists of the following modules: 1.
ZSch module handles task scheduling and unit assignment; 2.
MR module handles maintenance and repair performance; 4.
RS module is the resource for maintenance and repair.
The first level is formed by the modules described in the previous paragraph. The main ZO module contains K basic ZExec modules of the task's operation, where K is the number of tasks in the technological process schedule. The ZExec module provides a simulation of unit assignment and basic task operations. Each ZExec module is associated with its own RTA (runtime analyzer) module, which evaluates the time parameters of running units and determines failures or predictive maintenance requests. The RTA module simulates an ensemble of m units for a specific task z k . The Unit ID sub-module determines the accumulated operating time, remaining useful life, and time before preventive maintenance, and simulates stochastic processes of failures and prediction maintenance. A detailed description of the implementation of HPN modules is given below.

ZO Module
All basic operations for performing production tasks are simulated in the ZO module. The topology of the ZO module is determined by the process Gantt diagram. Each task has a base operations module BOM associated with it. Figure 4 shows the ZO module structure as an example, including three blocks of operations BOM1-BOM3; these are substitution transitions that correspond to ZExec modules on the lower level of the model hierarchy.

ZO Module
All basic operations for performing production tasks are simulated in the ZO module. The topology of the ZO module is determined by the process Gantt diagram. Each task has a base operations module BOM associated with it. Figure 4 shows the ZO module structure as an example, including three blocks of operations BOM1-BOM3; these are substitution transitions that correspond to ZExec modules on the lower level of the model hierarchy. ZBM modules are intermediate substitution transitions to ZExec modules. The example ( Figure 4) implements sequentially parallel execution of the production "Main Task." The global color sets and variables are given in Table 1. Table 2 contains a description of the ZO places.
Thus, according to Equation (1), the main color set U is defined in the HPN model as a tuple U = (id, md, rt, rl, mt, ti, ta). The unit's unique id and model md associate it with the tasks being performed. The time parameters rt, rl, mt, ti, and ta are used to control the unit's residual life. Only the active unit of work time determines the remaining useful life RUL (rl parameter). In periods of service or repairs to the unit, time rt does not change. The global color sets and variables are given in Table 1. Table 2 contains a description of the ZO places. Thus, according to Equation (1), the main color set U is defined in the HPN model as a tuple U = (id, md, rt, rl, mt, ti, ta). The unit's unique id and model md associate it with the tasks being performed. The time parameters rt, rl, mt, ti, and ta are used to control the unit's residual life. Only the active unit of work time determines the remaining useful life RUL (rl parameter). In periods of service or repairs to the unit, time rt does not change.  (1), the expression for the unit current operating time t cu follows: where t c is the model time.
Requests for the unit's predictive maintenance are simulated in the process of performing tasks. For this purpose, the random distribution functions are used corresponding to the degradation and deterioration processes of unit parts. At random time t Mrq , the Mrq signal is formed, causing a transfer of the unit for maintenance. Similarly, at the moment of time t F , the signal F is generated to simulate the failure occurrence.
The unit is operated in the technological process under the following conditions: • The inspection time is less than the value of RUL defined for each unit.

•
The inspection time is less than the time before scheduled maintenance.

•
There are no signals about the appearance of failure.

•
There are no predictive maintenance requests.
Therefore, the step sequence for simulating a technological process execution is as follows: 1.
Module initialization: Unit model types that can perform operations on the BOM module are set in place MZ. The number of operation cycles is set in place Cc. If necessary, the FE (failure enable) and PrME (predictive maintenance enable) indicators are set.

2.
Each BOM k module assigns specific units to perform task z k according to the rule: ∃u : u n ∈ AU ∧ md(u n ) = mdz(BOM k ).
As a result, the places UPZ 1-UPZ K contain sets of unit models that can perform these tasks throughout the entire period. Note that the set AU of available units can contain several units of the same model with different IDs.

3.
The "Main Task" token movement through the BOMs simulates the execution of a technological process. When a task is completed in the BOM, the place EndZ in the ZExec module receives a token.

4.
The RTA analyzer checks the unit operating conditions throughout the BOM module's activity period. If conditions 1 and 2 are not satisfied, the residual resource is exhausted; then, the unit stops working, and it is directed to preventive maintenance.

5.
In cases where the FE and PrME features are set, the RTA analyzer generates random failure or defect prediction events; then, at the appropriate time, the unit is transferred for repair or maintenance. This action is simulated by moving the unit token to the places UM or UF, and then to the MR module, for maintenance or repair operations. During this period, the unit token is only in the MR module, and the value of the operating time t rt does not change. 6.
If the task is suspended, then another unit with the required model is selected from the set AU to the BOM module, and the task continues.

7.
The "Main Task" token appears at the output place PZfin when the technological process is completed.

ZExec Modules
The ZExec module is a substitution transition for ZBM modules. Figure 5 shows the structure of a ZExec with substitution transitions TASK and RTA.

TASK Sub-Module
The hierarchical approach assumes that the internal organization of any technological task can have a complex structure. Figure 6 shows a sub-module with three phases of task execution.  The appearance of a token at the input position Pin allows the assignment of units to execute the task. A set of required unit models is contained in the place MZ. For the transition T0, a code segment is defined that specifies the function newTI (u) for setting the start time t ti for a given operating period. The task operations begin after moving units from place AU to place UPZ.
The operation of module ZExec when simulating failures or predictive maintenance requests is as follows: 1.
The token appearance in F or Mrq places determines the model of the new unit that should replace the unit being serviced or repaired. Transitions T3 and T4 send the lock token to the place Lock.

2.
The T5 or T6 transitions fire if a unit with a required model is in place AU; then, the unit is replaced in UPZ.

3.
The transition T7 unlocks the operation execution after replacing a unit in place UPZ.

4.
At the end of the task, the Cc counter is reset to zero, and the inhibitor arc starts transition T2 to move units from place UPZ to place AU, to be used in other BOM modules. The function newRT (u) sets new values of t rt and t ta .
In the ZExec module, the meaning of places and transitions are explained in Tables 3 and A1.

T0
Selecting a unit from the general set of available units T1 Start task execution T2 Returning units to AU after completing a task T3, T4 Selecting the unit model for replacement T5, T6 Replacing units in UPZ T7 Unlocking task execution

TASK Sub-Module
The hierarchical approach assumes that the internal organization of any technological task can have a complex structure. Figure 6 shows a sub-module with three phases of task execution.

TASK Sub-Module
The hierarchical approach assumes that the internal organization of any technol ical task can have a complex structure. Figure 6 shows a sub-module with three phase task execution. The transition T1 performs a preparatory operation for the task execution. The tr sition T2 corresponds to the main operation, and the firing of the transition T3 is the fi Figure 6. The three-phase TASK sub-module.
The transition T1 performs a preparatory operation for the task execution. The transition T2 corresponds to the main operation, and the firing of the transition T3 is the final action. The iterative cycle of operations is organized by transitions T3 and T4 and places Cc and CYCLE END. After all of the task operations, the units are removed from the place UPZ in the ZExec module. An empty token in place CYCLE END allows the firing of transition T5 through the inhibitor arc. It sets the flag End and moves the token "Main Task" to the place Pout. This concludes the work of the TASK and ZExec modules.
Such a task structure is the simplest case, but it is often encountered in applications. Next, an example of the practical use of a simulation model will be considered, while the TASK module has a more complex structure.

RTA Module and Unit ID Sub-Module
Each RTA is assigned to a single task z k , and is associated with the corresponding BOM module. Essentially, RTA is a multifunctional unit's time counter, and includes several Unit ID sub-modules ( Figure 3). The structure of the Unit ID module is depicted in Figure A1. The meanings of the module's places and transitions are briefly explained in Tables A2 and A3.
The primary operations of the Unit ID module are: • Selecting a unit with a given ID = j from place UPZ and moving to place UPZ j; • Setting in place E the status "Unit activity" and starting the internal time counter; • Checking the conditions n ≥ rl (RUL) and n ≥ mt (time before maintenance) performed on the output arcs of the transitions T2 and T3 in each time step; • If at least one condition is satisfied, the unit is transferred to the MR module by transition Tout2; • Generating a predictive maintenance request on the transition T4 output arc according to the Poisson distribution, with a given rate λ M , and moving the unit to the place UM; • Generating a failure event on the transition T5 output arc according to the Poisson distribution, with a given rate λ F , and moving the unit to the place UF; • Removing the unit from the place UPZ j, if it becomes inactive; • Setting new values of unit accumulated operating time t ta and t rt = 0 using the code segments of function newRTLM (u); • Resetting the module marking to its initial state upon work completion on a signal in the place EndZ.
The researcher can study the influence of stochastic processes in the simulated equipment. Tokens in the FE and PrME positions of the Unit ID module allow the firing of transitions T4 and T5. The output arc expressions for these transitions generate random times of failure or requests from the predictive maintenance system. CPN Tools provides random distribution functions: normal, Poisson, Weibull, gamma, exponential, and others. The example module in Figure A1 shows Poisson failure flow generation with a rate of λ = 3. It should be noted that the values of the random distribution parameters depend on the ratio of the model and the real time of the technological process.

Maintenance and Repair Module
Repairs and maintenance are simulated in the MR module (Figure 7). The queues of units for maintenance and repair are formed in the places UMQ and UFQ, respectively. Tokens in these places are transferred from the ZExec modules. The tokens in the places AM and AR allow the maintenance or repair operations for the next unit. At the same time, tokens leave these places through transitions T1 and T2, blocking the service of new units.    Returning a unit to the set of available units

Simulation of Autonomous Agricultural Vehicles (AAVs)
The robotic system of autonomous agricultural vehicles (SAAV), based on the KA-MAZ vehicle family, with autonomous and remote control, is a human-machine system. The system aims to perform transport tasks using a KAMAZ robotic chassis controlled by a dispatching subsystem. A robotic car is a cyber-physical system; its functioning is based on a combination of complex physical and information processes: the physics of fuel combustion, mechanical motion, material fatigue processes, information processes, intelligent data processing systems, and motion control using machine vision [52]. The construction of full-scale models in the design of such systems is costly, and does not allow for the consideration of various scenarios or prediction of the AAV's performance. In this regard, an effective method is to integrate digital models of AAV aggregates and subsystems and conduct numerous digital tests [53].
In a predictive maintenance system, the parameters characterizing the actual state of the AAV come from the onboard system. These are periodically compared with the AAV models' parameters, taking into account the wear of components and environmental influences. The AAV's state is assessed by the deviation magnitudes of the parameters from the model values. The alert states of the subsystems and units are determined, and the residual life of the equipment and subsystems is forecast. Based on the analysis, the predictive maintenance system generates recommendations for the AAV service personnel regarding the timing of component replacement and the maintenance schedule.
SAAV consists of the following subsystems ( Figure 8): • AAV group; • Data transfer system; • AAV system of remote diagnostics and predictive maintenance; • AAV models (digital twins).

Hierarchical Petri Net Model for Autonomous Vehicle Simulation
The simulation experiment to study the predictive maintenance of the AAV is conducted using a model similar to a hierarchical HPN model (Figure 3). The difference between the models is the implementation of the TASK module. It is assumed that the technological process of delivering goods to/from the location of the agrotechnical production task includes five operations. The TASK AV module structure for this case is depicted in Figure 9.
from the model values. The alert states of the subsystems and units are determined, and the residual life of the equipment and subsystems is forecast. Based on the analysis, the predictive maintenance system generates recommendations for the AAV service personnel regarding the timing of component replacement and the maintenance schedule.
SAAV consists of the following subsystems ( Figure 8): • AAV group; • Data transfer system; • AAV system of remote diagnostics and predictive maintenance; • AAV models (digital twins).

Hierarchical Petri Net Model for Autonomous Vehicle Simulation
The simulation experiment to study the predictive maintenance of the AAV is conducted using a model similar to a hierarchical HPN model (Figure 3). The difference between the models is the implementation of the TASK module. It is assumed that the technological process of delivering goods to/from the location of the agrotechnical production task includes five operations. The TASK AV module structure for this case is depicted in Figure 9. The production task consists of operations that are simulated by the following transitions: • Transition T1 is the AAV's movement along a given route from the home base to the operational position; • Transitions T2 and T4 are maneuvering near the operating position; • Transition T3 is the execution of the main production operation; • Transition T5 is the AAV's return route to the place of deployment.
It should be noted that the processes of vehicle maneuvering in the field when approaching the target place, in many cases, take place under increased loads and increased risk of emergencies. The TASK AV module simulates these factors. The HPN AV model structure description provided in the CPN Tools, and the HPN declarations, are shown in Figures A2-A4.
An example of evaluating the AAVs' predictive maintenance effectiveness is made for a parallel-sequential schedule of three tasks and three vehicles. It simulates the KAMAZ three models, which correspond to the value of the variable md for color set U:  Figure A3 shows the initial marking of the ZO module, with vehicle models M1 and M2 assigned to BOM1, models M1 and M3 to BOM2, and model M3 to BOM3. Therefore, the initial marking of the ZO module places is represented by multisets: MZ1 = 1' "M1" ++ 1' "M2 "; MZ2 = 1' "M1"++ 1' "M3"; MZ3 = 1' "M3".
For this example, the final marking of HPN AV is depicted in Figure A4. Studies of KA-MAZ family vehicles were carried out in order to assess the degradation and deterioration of their components and assemblies. Tables 6 and 7 list MTBF (mean time between failures) data for the autonomous vehicles' brake systems and fuel systems. Two distributions are involved here: normal, with mean µ and standard deviation σ; and Poisson, with failure rate λ per 10,000 h.
Appl. Sci. 2021, 11, x FOR PEER REVIEW 15 of Figure 9. TASK AV module with five phases of operations for autonomous agrotechnical vehicles.
The production task consists of operations that are simulated by the following tra sitions: • Transition T1 is the AAV's movement along a given route from the home base to t operational position; • Transitions T2 and T4 are maneuvering near the operating position; • Transition T3 is the execution of the main production operation; • Transition T5 is the AAV's return route to the place of deployment.
It should be noted that the processes of vehicle maneuvering in the field when a proaching the target place, in many cases, take place under increased loads and increas risk of emergencies. The TASK AV module simulates these factors. The HPN AV model structure description provided in the CPN Tools, and the HP declarations, are shown in Figures A2-A4.
An example of evaluating the AAVs' predictive maintenance effectiveness is ma for a parallel-sequential schedule of three tasks and three vehicles. It simulates t KAMAZ three models, which correspond to the value of the variable md for color set U  Figure A3 shows the initial marking of the ZO module, with vehicle models M1 a M2 assigned to BOM1, models M1 and M3 to BOM2, and model M3 to BOM3. Therefo the initial marking of the ZO module places is represented by multisets: MZ1 = 1` "M1" ++ 1` "M2 "; MZ2 = 1` "M1"++ 1` "M3"; MZ3 = 1` "M3".
For this example, the final marking of HPN AV is depicted in Figure A4. Studies KAMAZ family vehicles were carried out in order to assess the degradation and dete oration of their components and assemblies. Tables 6 and 7 list MTBF (mean time b tween failures) data for the autonomous vehicles' brake systems and fuel systems. Tw distributions are involved here: normal, with mean μ and standard deviation σ; a Poisson, with failure rate λ per 10,000 h.  Analyzing the time scales of service processes and the occurrence of failures in KA-MAZ vehicles, the following relationship between model time (MTU) and real time was adopted: 1 MTU = 1 h.
To obtain the integrated parameters of the car from the data of its components, we used the technique described in [54]. A mathematical model for determining the uptime probability was based on monitoring the vehicle mileage, the impact of factor influence, and the residual component life. As a result, for the considered example of modeling the fuel and braking systems, the integral stochastic parameters of failures were obtained. For example, Table 8 shows the time parameters of three AAVs given in the model time. At the initial time taken RT = 0 and TI = 0. We evaluate the maintainability effectiveness by the schedule completion degree of the technological process. Factor Y is determined in the form of a task completion delay ratio obtained during statistical tests by the Monte Carlo method: where t Z is the task's scheduled completion time, t A is the task's actual completion time, and µ(t A ) is the average actual completion time.
For determining the required set of vehicles for the technological process, the AAV operating rate E j is applied: where t zk is the task z k execution time, t jk is the operation time for AAV with id = j during task z k execution, and I j is the index set of tasks to which jth car is assigned.
The HPN model has been tested on multiple datasets corresponding to various repair and maintenance modes for autonomous vehicles. In the presented article, the results of the following experiment are given as an example: statistical tests were conducted under the normal distribution of the AAV maintenance time at the service station and a set of time values until preventive maintenance.
Tables A4 and A5 contain the values of parameters of the hierarchical PN model, and show obtained factor Y and operating rate E. In addition, the charts of factor Y and operating rate E are presented in Figures 10 and 11 where tzk is the task zk execution time, tjk is the operation time for AAV with id = j during task zk execution, and Ij is the index set of tasks to which jth car is assigned.
The HPN model has been tested on multiple datasets corresponding to various repair and maintenance modes for autonomous vehicles. In the presented article, the results of the following experiment are given as an example: statistical tests were conducted under the normal distribution of the AAV maintenance time at the service station and a set of time values until preventive maintenance.
Tables A4 and A5 contain the values of parameters of the hierarchical PN model, and show obtained factor Y and operating rate E. In addition, the charts of factor Y and operating rate E are presented in Figures 10 and 11, illustrating the parameter interdependencies.

Discussion
The developed hierarchical CPN model describes many objects, their states, and their parameters. The model allows us to study various properties in the autonomous vehicle system, and make decisions to improve process control. Planning multifactorial experiments is based on the identification of the main components that affect key indicators. Based on the results of the presented experiment, the following conclusions can be drawn: The researcher sets the limit value for exceeding the scheduled completion time of the technological task Z. Assume that max Y = 15% (red dotted line in Figure 11). The graphs in Figure 11 show that for Y ≤ 15%, the acceptable value range for the parameters tMT and tM is determined by the inequalities: Hence, the preventive maintenance period for autonomous vehicles must be at least 320 h. Otherwise, the AAV's transfer to service and repair work leads to a significant

Discussion
The developed hierarchical CPN model describes many objects, their states, and their parameters. The model allows us to study various properties in the autonomous vehicle system, and make decisions to improve process control. Planning multifactorial experiments is based on the identification of the main components that affect key indicators. Based on the results of the presented experiment, the following conclusions can be drawn: The researcher sets the limit value for exceeding the scheduled completion time of the technological task Z. Assume that max Y = 15% (red dotted line in Figure 11). The graphs in Figure 11 show that for Y ≤ 15%, the acceptable value range for the parameters t MT and t M is determined by the inequalities: slowdown in the technological process. The useful time of autonomous vehicles is similarly estimated using the operating rate indicator E. For a given rate E ≥ 75%, the parameters t MT and t M must satisfy the following ratios: By combining the conditions Y and E, we obtain the limit value t MT = 320 h. We are also considering using reserve autonomous vehicles to reduce the loss of repair and maintenance time. To do this, in HPN AV, a multiset of place AU is added, according to a fourth vehicle with model "M1" and id = 7. Thus, when a car with id = 1 is brought to the service, it is replaced by a reserve car with id = 7 when performing tasks z 1 and z 2 . The experiment shows that, for t M = 48 h and t MT = 200 h, the Y criterion decreases from 67% to 30%. At the same time, the vehicle rate E also decreases (Table 9). However, this leads to the timely completion of task Z. These results are taken into account when correcting the constraints of the optimization problem shown in Equations (2) and (3) to find a balance between the unproductive idle time of vehicles and the degree of compliance with the schedule.

Conclusions
The hierarchical HPN model presented in this article can describe processes in a comprehensive class of flexible manufacturing systems. However, some structural and technical features of this model determine its most effective area of application. In the HPN model, the emphasis is on putting units into operation, their replacement, and the formation and use of a reserve of units. In this regard, the model is more suitable for the organization of maintenance and repair of mobile industrial equipment.
It should be noted that the novelty of our approach also lies in the application of an optimization-simulation procedure. In modeling the maintenance of the autonomous robotic vehicle system, we managed to solve the problem of the rational placement of AAVs in a production area with the required number of reserve units. The simulation experiment results obtained via the Monte Carlo method were used to adjust the constraints of minimizing the maintenance cost, as shown in Equations (2) and (3). We can say that such an iterative procedure is, to some extent, analogous to machine learning; the difference is that, at this stage of our work, the decision to correct the optimization problem is made by the production system's analyst/manager. In our study of AAV systems, we obtained solutions close to optimal, in the performance of no more than 15-20 iterations.
The HPN model contains a set of UNIT ID modules, which are individual multifunctional timers for each technology unit. This solution is new, and allows us to keep track of the time parameters of the unit's activity, the residual resource, and the remaining time before maintenance. The UNIT ID module performs these functions regardless of the production task or the place of the unit's use. This provides the ability to quickly move information about a unit to other hierarchical models, in order to transfer it to a new production system.
It should be noted that the structure of the hierarchical model and its main modules can be adapted to a vast class of flexible production systems. The ZO module and the ZExec module structure allow the substitution of local models of various production tasks and technological equipment units. However, there are certain limitations to the application of the proposed hierarchical model.
First, the desire to perform deeper detailing, in order to study the stochastic processes of the behavior of individual subsystems and elements of technological units, leads to congestion of the model's connections and an increase in the dimension of the PN model. As a result, the simulation time increases significantly, and the analysis of the obtained solutions becomes more complicated.
Secondly, the tools that support PN modeling have limitations on the number of places and transitions in the model. Experiments with the AAV system have shown that it makes no sense to build a complete simulation model for an enterprise with 50-100 robotic vehicles. It is enough to divide the AAV fleet into groups that perform local production tasks, with the number of vehicles no more than 15. In this case, the simulation can be performed reasonably, and the obtained solution adequately describes the manufacturing system.
A possible direction for further research is the development and complication of the hierarchical model of autonomous agricultural vehicles. The idea is that AAVs include several microcontroller-based control subsystems. Predictive maintenance uses information obtained from monitoring while operating the vehicle in challenging road conditions. Therefore, it is necessary to perform the detailing of the HPNs at the lower levels of the model. This approach allows the study of process failures in microcontrollers, measurement subsystems, and data transmission devices. In this case, external signals and factors should be investigated. Hence, the model HPN AV is transformed into a non-autonomous Petri net. Some works are known in the field of the application of non-autonomous Petri nets. L. Gomes et al. conducted research in which they implemented IOPT models for simulating microcontrollers [55][56][57]. There are many reasons to use the IOPT tool [58]; in this case, the basic premise is related to describing interfaces and signals in the onboard diagnostic system of an autonomous vehicle.

Data Availability Statement:
No new data were created in this study. Data sharing is not applicable to this article.

Conflicts of Interest:
The authors declare no conflict of interest. Table A1. Places of module ZExec.

Place
Meaning Color Set P in Input place Z P out Output place Z P Start The token represents the task operation start Z UPZ The tokens represent units that perform the task U AU The tokens represent an available unit U MZ The tokens represent unit models suitable for task operations. Model P1, P2 The tokens represent the unit models to replace at UPZ Model P3 Auxiliary place UNIT Cc The tokens represent a task cycle number INT F, Mrq A token represents the type of model for replacing a unit in position UPZ U Exec A token represents a task execution enable Unit Lock A token represents blocking the execution Unit EndZ A token represents the task execution finish Unit The occurrence of a predictive maintenance request BOOL UM, UF, F, Mrq A token represents a unit for replacing U EndZ Task completion and reset UNIT Table A3. Transitions in the RTA module.

Transitions Description of Transitions
Tin Input unit data u j from a place UPZ T1 Forming the current module time T2, T3 Checking unit stop conditions T4, T5 Generating random timestamps T6, T7 Permission to output unit data to the MR module Tout1 Output unit u j for maintenance Tout2 Output unit u j for repair