# Addressing Business Process Deviations through the Evaluation of Alternative Pattern-Based Models
## 3 Materials and Methods
### Output State Token Estimation
#### 3.1.6 Repairing Mechanism  
The proposed repairing mechanism can benefit from task characterization, state tokens, and a library of patterns. These concepts provide a better understanding of a task's role and expected outcome, aiding in identifying process deviations. In fact, monitoring task input, output, constraints, and resource requirements can quickly identify deviations in process execution, while, repairing deviations in a model can be a complex and challenging task, especially when dealing with large and complex systems. The proposed method employs pattern matching to identify candidates for deviation repairing. It utilizes a library of patterns to search for suitable solutions to the problem. An efficient search is achieved by using simple methods to quickly remove incompatible patterns as simple as comparing intervals and mathematical operations, reducing the set of candidates to a more manageable size. Afterwards, more complex analyses and methods, such as fuzzy sets and probabilistic approaches or even simulation, can be employed to further refine the search, and rank and choose the best solution. Each phases of the method uses a different approach to process the evaluated estimated states throughout the model to compute the estimated state tokens as mention in Section 3.1.3. In each phases it is assumed that the set of valid state tokens is included in the estimated state tokens computed by the method. While using more complex solutions, the number of states in the estimated state tokens is narrowed down, converging towards the real set of state tokens. However it is important to mention that the more complex the methods, the longer the computation time. Thus, due to enormous number of potential  
Figure 5: General model of a library. Figure 6: Repairing typology. reparations, it is necessary to start with very simple computations that allow as many candidates as possible to be eliminated with minimum computations. The remaining candidates are then reduced using more and more complex methods; however, these are also more costly in terms of time (cf. Section Output State Token Estimation of Section 3.1.2). As shown in Figure 7, the first step of computation comprises using a method based on valid interval computation without considering resources. It can easily be proven that the obtained estimated state tokens follow the definition in Section Output State Token Estimation of Section 3.1.2, meaning that all real state tokens are included in any of the computed estimated state tokens. The temporal management of resources is one of the most time-consuming processes and is executed in the last steps of computation on a very limited set of alternatives (couple \((pattern,returning-point)\)). The proposed repair mechanism comprises several steps as outlined in theBPMN, Figure 7, and in the following. 1. Deviation detection: This paper assumes that a deviation has already been detected and focuses on the repair mechanism. Before calculating the state token, it is important to highlight three types of deviations: at the entry, during the execution and at the exit of a task (cf. Figure 6). 2. State token calculation: The subsequent step entails the computation of all estimated state tokens \(\widetilde{ST}_{X_{i}}\) that would be correct if no deviation had been encountered. All \(\widetilde{ST}_{X_{i}}\) (at the start and exit of tasks, and AND and XOR gates) between the deviation point \(D\) and the exit of the model are computed. In the following \(X_{i}\) is called nodes. The estimated state tokens (\(\widetilde{ST}_{X_{i}}\)) are compared with the estimated state token of the exit point for each pattern from the library to assess their compatibility and identify potential points of return for each pattern in the main model. (cf. matching output requirements below 3). This step is reprocessed for each advanced computational iteration. However, with each iteration, the number of computed nodes is reduced. As the computational method becomes more complex, it become more time consuming.