# Addressing Business Process Deviations through the Evaluation of Alternative Pattern-Based Models
## 1 Introduction  
Business processes have evolved to become increasingly complex, often consisting of a multitude of tasks that need to be executed. While these processes are typically modelled to manage their inherent complexity, deviations from these models can occur during their execution. The ability to anticipate every possible scenario and incorporate it into the models is practically impossible. Consequently, the challenge arises of how to effectively model the response to these unforeseen problems. The approach outlined in this study involves the creation of a primary model in collaboration with domain experts. In the event of a deviation during execution, the system searches for compatible patterns within a collaborative library of workflows, rather than relying on specific solutions tailored for individual problems. Selecting the most appropriate candidates from a vast number of patterns and identifying optimal injection points in the primary model to rectify the deviation constitute the main challenges in this approach. The proposed method introduces three basic types of repairs, which differ from conventional approaches that typically focus on predicting and solving locally identified deviations or exceptions. By modifying the model dynamically through the insertionor deletion of parts of the workflow, the proposed method offers a more flexible and comprehensive approach to addressing unexpected situations. Additionally, the compatible solutions are evaluated and ranked based on performance indicators, enabling decision makers to select the best solution automatically or manually. Central to the proposed approach is a collaborative library of random patterns, which stores patterns that may serve as potential candidates for unexpected deviations in workflow execution. Unlike conventional approaches that store solutions for each problem, this library leverages the expertise of domain experts and external sources to identify compatible solutions based on the current state of the system. The searching mechanism employed in this approach efficiently narrows down the pool of candidate solutions by rapidly eliminating non-compatible patterns using simple algorithms. Subsequently, more sophisticated methods are utilized to refine and rank the remaining patterns, leading to improved workflow performance. In order to accurately calculate the impact of candidates on the system and determine the most effective course of action, this study introduces new characterizations and notations that enrich BPMN elements. These characterizations provide a valuable framework for accurately assessing the impact of repairs on the workflow. The ease of implementation is another significant advantage of the proposed methodology, as demonstrated through the utilization of Python to implement the entire approach, enabling practitioners to readily incorporate it into existing systems and workflows. Furthermore, the proposed iterative solution injection approach allows the system to continuously analyse historical data and suggest optimizations at the main model level. By learning from past experiences and adapting to new circumstances, the system can continually enhance its performance. This opens up possibilities for future studies in artificial intelligence, where historical databases can be leveraged to further refine and improve the design of the model. The remainder of this paper is organized as follows: Section 2 presents a comprehensive review of the related work, Section 3 provides a comprehensive overview of the materials and methods employed in this study. In Section 4, a concise case study is presented as a compelling proof of concept, illustrating the ease with which this method can be implemented in real-world scenarios. Section 5 delves into a comprehensive discussion of the findings, exploring their implications, limitations, and potential applications. Lastly, Section 6 presents a conclusion summarizing the key insights and contributions of this approach.