# Fault Diagnosis in Partially Observable Petri Nets with Quantum Bayesian Learning
## 3 A Quantum Bayesian Fault Diagnosis Method for Partially Observable Petri Nets
### Quantum Bayesian Probabilistic Fault Diagnosis for Partially Observable Petri Nets  
We build the QBPN model of fault transition to diagnose the fault state of the system. According to quantum Bayesian estimation, the prior probability can be calculated by the corresponding observable transitions in the fault transitions pre-set, then the firing order of observable transitions in the post-set can provide us the posterior probability of fault transitions. See Algorithm 1.  
Aiming at the unobservable fault transition in the POPN model, according to the firing relationship between the parent node and the child node, the parent node first traverses forward, stops searching when the observable transition is encountered. Transforms the transitions, places and arcs in the traversal process into quantum Bayesian node elements, and continues to traverse other parent node branches until the parent node collection is traversed. Then, the sub-nodes start to traverse backward, and stop searching when they encounter observable transitions. The transitions in the process of traversal, transform the transitions, places and arcs in the traversal process into the quantum Bayesian node element, and other sub-nodes continue to traverse until the collection of sub-nodes is traversed. Remove the transition elements causing the dead state to simplify the QBPN model structure. According to the quantum interference caused by the uncertain path, recalibrate the conditional probability table of the transition to obtain the quantum probability amplitude table. According to the pre-set of fault transition and quantum Bayesian reasoning, calculate the firing prior probability of the transition, and then the posterior probability is modified by the observable transition in the post-set. Estimate the state of the system by the maximum posteriori probability. When the fault transition is not unique, the fault with the maximum probability is selected as the fault source.  
```
INPUT: The POPN model, quantum Bayesian probability table \(\psi\) and possible fault transition \(t_{f}^{i}\) OUTPUT: System's fault probability \(Pr(\sigma_{o},\psi,T_{f}^{i})\)
1 Initialization \(\forall t_{f}^{i}\in Q(\sigma_{o})\), \(Pr_{i}\in[0,1],\varphi(t_{i}),\rho\in[0,1)\)
2 for\(\forall t_{f}^{i}\in\sigma\in Q(\sigma_{o})\) do  While \(\forall t_{k}\in T_{o},t_{k}\in M_{k},M_{i}[t_{f}^{i})\cdots M_{j}[t_{j}) \cdots M_{k}[t_{k})\), \(i<j\leq k,t_{j}\in T_{u}\)do  Copy all transitions \(t_{j}\), place \(p\) and arcs between \(t_{k}\) and \(t_{f}^{i}\) to QBPN, \(t_{k}\in\cdot T_{QB_{*}}\), \(t_{j}\in T_{QB_{*}}\)  While \(\forall t_{k}\in T_{o},t_{k}\in M_{k},M_{k}[t_{k})\cdots M_{j}[t_{j})\cdots M _{i}[t_{f}^{i})\), \(k<j\leq i,t_{j}\in T_{u}\)do  Copy all transitions \(t_{j}\), place \(p\) and arcs between \(t_{f}^{i}\) and \(t_{k}\) to QBPN, \(t_{k}\in T_{QB_{*}}\), \(t_{j}\in T_{QB_{*}}\) 3 if\(\exists t_{k}\wedge M_{i}[t_{f}^{i})\), \(t_{k}\) cannot be fired then  Delete \(t_{k}\) and its input and output arcs 4 for \(t_{i}\in T_{QB}\)do  According to the quantum probability table \(\psi\), set quantum probability amplitude \(\varphi(t_{i})\). 5 for \(\forall t_{k}\in\cdot T_{QB_{*}}\) do  According to the observable transition state of the forward path, calculate \(Pr(t_{f}^{i}|\cdot T_{QB_{*}})\). 6 for \(\forall t_{k}\in T_{QB_{*}}\)do  According to the firing order of the post-set of observable transitions, calculate \(Pr(t_{f}|\cdot T_{QB_{*}}\cup T_{QB_{*}}\cdot)\) 7 Choose the maximum probability of the fault transitions as the fault probability of the system \(Pr(\sigma_{o},\psi,T_{f}^{i})\) 8 if \(Pr(\sigma_{o},\psi,T_{f}^{i})>\rho\) then \(W(\sigma_{o},\psi,T_{f}^{i},\rho)=F\) else\(W(\sigma_{o},\phi,T_{f}^{i},\rho)=N\) 9 return \(W(\sigma_{o},\phi,T_{f}^{i},\rho)\)
```  
**Algorithm 1** Fault Diagnosis Based on QBPN