## 4 Implementation of the Extended Algorithm
### Model Optimization  
In initial uses of an algorithm, one can change process model detail by tuning activity and transition rates and move from the simplest model to complex and complete one. However, it is preferable to obtain a model automatically when it comes to the tool's adaptiveness and massive processing. Therefore, we attempted to apply machine learning formalization in PM and defined the problem of discovering an optimal process model automatically. Let \(p\) be the algorithm for discovering a process model from an event log. The set of traces \(L=\cup_{i=1}^{N}\sigma_{i}\) is an event log, where \(\sigma_{i}=\left\langle e_{1},\;e_{2},\ldots,\;e_{k_{i}}\right\rangle\) is the \(i\)-th process execution instance (trace) of the length \(k_{i}\), and \(\sigma_{i}(j)=e_{j}\) is an event from the set of events \(X\), which the log can contain, and the log size, therefore, is \(l=\sum\limits_{i=1}^{N}k_{i}\). An event can be defined as a set of attributes (activity type, resource type, time stamp, etc. ), but here and further we imply an atomic event log, i.e., each event is an activity. We also assume that activities within a trace are ordered by the time registering in a system. Let \(p\left(L,\overline{\theta}\right)=M=\left\langle V,\;E,\;v_{start},v_{end},\; sig\right\rangle\) be a process model, which is a DFG, discovered by the algorithm \(p\) with parameters \(\overline{\theta}=(\theta_{1},\theta_{2})\), activity and transition rates, respectively, from the event log \(L\), where:  
* \(V\subseteq X\) is a set of nodes, \(|V|=n\);
* \(E\subseteq V\times V\) is a set of edges, \(|E|=m\);
* \(v_{start}\) is a \"start\" (initial) node;
* \(v_{end}\) is an \"end\" (terminal) node;
* \(sig:X\cup(X\times X)\rightarrow(0,\;1]\) is an activity and transition significance defined as case frequency, a fraction of traces that contain an activity or transition: \[sig(x)=\frac{\sum_{j=1}^{k}1_{\sigma_{j}}(x)}{k}\] (1) for an element \(x\), where \(1_{\sigma}(x)\) is an indicator function that equals \(1\) if an element \(x\) is contained in a trace \(\sigma\) and equals \(0\) otherwise. For an activity, it is defined as follows: \[1_{\sigma}(x)=\left\{ \begin{matrix}1,\;\exists i=\overline{1,n}:\;x=\sigma(i ),\\ 0,\;\text{otherwise};\end{matrix} \right.\] (2) and in case of transition: \[1_{\sigma}(x)=\left\{ \begin{matrix}1,\;\exists i=\overline{1,n-1}:\;x=\left\langle \sigma(i),\;\sigma(i+1)\right\rangle,\\ 0,\;\text{otherwise};\end{matrix} \right.\] (3)  
Let \(P=\left\{p\left(L,\overline{\theta}\right)|\overline{\theta}\in\Theta\right\}\) be the process model space, where \(\Theta\) is a domain of the algorithm parameters. Here, we consider \(\overline{\theta}=\left\langle r_{a},r_{t}\right\rangle\). Thus, \(\Theta=[0;100]\times[0;100]\). One needs to find an algorithm \(p\in P\) (more precisely its parameters) that maximizes \(Q\) on \(L\):  
\[Q(p,L)=(1-\lambda)\cdot F+\lambda\cdot(1-C_{\mathcal{J}})\rightarrow\max_{ \overline{\theta}}, \tag{4}\]  
where  
\[F=\frac{1}{|L|}\sum_{\sigma\in L}\left(\frac{1}{|\sigma|}\sum_{i=1}^{|\sigma| }z_{i,n}-\alpha\delta(\sigma,s^{*})-\beta\frac{\phi(M,\sigma,s^{*})}{n}\right) ^{+} \tag{5}\]  
\(z_{i,n}\) is a binary variable equal to \(1\), if event \(i\) is represented by node \(n\), \(\phi\) is the number of forced transitions, \(\delta\) is the event skipping indicator, and \(s^{*}\) is the subtrace of all events represented by the process model \(M\)[35],  
\[C_{\mathcal{J}}=\frac{\mathcal{J}\left(p\left(L,\;\overline{\theta}\right) \right)}{\mathcal{J}\left(p\left(L,\;\overline{\theta^{100}}\right)\right)} \tag{6}\]\[\mathcal{J}\big{(}p\big{(}L,\ \overline{\theta}\big{)}\big{)}=\frac{m}{n} \tag{7}\]  
and \(E_{0}:\ p\Big{(}L,\ \overline{\theta^{0}}\big{)}=\langle V_{0},\ E_{0},\ v_{start},\ v_{ end},\ sig\rangle,\ \overline{\theta^{0}}=(0,\ 0);\ \overline{\theta^{100}}=(100,\ 100)\). In the optimization problem (4), an objective function includes fitness (5) and complexity (6) terms where \(\lambda\) is the regularization parameter to weight them.