# Optimal Opacity-Enforcing Supervisory Control of Discrete Event Systems on Choosing Cost
## 6 Scenario 2: Secret \(K\) Is Not Opaque with Respect to \(L(G)\) and \(\Sigma_{a}\)  
For system \(G\) and secret \(K\subseteq L(G)\), if \(K\) is not opaque with respect to \(L(G)\) and \(\Sigma_{a}\); we need to design a supervisor to prohibit all the secrets disclosed. To obtain the supervisor, we can use the method of [1,4] to end up with the maximal permission sublanguage of \(L(G)\) which can ensure the opacity of \(K\). Then, Scenario 1 is fulfilled. Next, we propose Algorithm 7 to solve Model (1). ```
0: Automaton \(G\), secret \(K\), and choosing cost \(c(s,\gamma)\);
0: Closed-loop behavior \(L(f/G)\). 1: Compute the observer \(obs(G)\) of \(G\)
2: Compute the parallel composition \(G\parallel obs(G)\)
3: For the parallel composition \(G\parallel obs(G)\), find supervisor \(g\) such that \(L(g/G)\) is the maximal permissive closed-loop behavior which can ensure \(K\) opaque [1,4]. 4:\(G^{\prime}=g/G\)
5:\(K^{\prime}=K\cap L(g/G)\)
6:if\(\overline{K}=L(G^{\prime})\)then
7: Design supervisor \(f^{\prime}\) such that \(L(f^{\prime}/G^{\prime})=L(G^{\prime})\)
8:else
9:if\(\forall s\in K^{\prime},\exists\overline{K}^{\prime}-K^{\prime}\ s.\ t.\ \theta(s)=\theta(s^{\prime})\)then
10: Design supervisor \(f^{\prime}\) from \(\overline{K}^{\prime}\) by Theorem 3, and then output closed-loop behavior \(L(f^{\prime}/G^{\prime})\)
11:else
12: Perform Algorithm 3 to design supervisor \(f^{\prime}\), and then output closed-loop behavior \(L(f^{\prime}/G^{\prime})\)
13:endif
14:endif
15:\(L(f/G)=L(f^{\prime}/G^{\prime})\)
16:return\(L(f/G)\)
```  
**Algorithm 7** Optimal supervisory control II \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{\(s\)} & \multicolumn{1}{c}{\(j=0\)} & \(j=1\) & \(j=2\) & \(j=3\) \\ \cline{2-5}  & \(Label_{s}V_{min}\) **(s)** & \(Label_{s}V_{min}\) **(s)** & \(Label_{s}V_{min}\) **(s)** & \(Label_{s}V_{min}\) **(s)** \\ \hline \(t_{s}\) & \(\{t_{s}\},0\) & & & \\ \hline \(eabg\) & & \(\{t_{s},eabg\},5.126\) & & \\ \(eabeg\) & & \(\{t_{s},eabg\},5.1256\) & & \\ \(eabgb\) & & \(\{t_{s},aebgb\},0.0002\) & & \\ \hline \(eabgt\) & & \(\{t_{s},eabg,eabgt\},5.126\) & & \\ \(eabgt\) & & \(\{t_{s},aebgb,aebgbt\},0.0002\) & & \\ \(aebgt\) & & \(\{t_{s},aebgb,aebgt\},0.00025\) & & \\ \hline \(t_{t}\) & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The set \(Label_{s}\) of shortest path and its minimal discount total choosing cost \(V_{\min}(s)\) at every node \(s\) of the diagram. Figure 9: Closed-loop language \(L(f/G)\). According to the above algorithm, we first construct maximal permissive supervisor \(g\) to enforce the opacity of \(K\). And then, it is verified that closed-loop behavior \(L(g/G)\) and restricted secret \(K\cap L(g/G)\) meet the requirements of Scenario 1. As shown in Theorem 2, Theorem 3, and Theorem 4, we can conclude that Algorithm 7 can produce an optimal solution of Model (1). Theorem 5: _We consider system \(G\) and secret \(K\subseteq L(G)\). In Scenario 2, closed-loop behavior \(L(f/G)\) obtained in Algorithm 7 is an optimal solution of Model (1)._  
Proof. : Firstly, we prove that \(L(f^{\prime}/G^{\prime})\) is a controllable and closed sublanguage of \(L(G)\). As shown in Lines 7, 10, and 12, \(L(f^{\prime}/G^{\prime})\) is a closed sublanguage of \(L(G)\). Next, we prove \(L(f^{\prime}/G^{\prime})\) is controllable with respect to \(L(G)\). \[ \begin{array}{ll}&\forall s\in L(f^{\prime}/G^{\prime}),\sigma\in\Sigma_{u}, s\sigma\in L(G)\\ \Rightarrow&s\in L(g/G),\sigma\in\Sigma_{u},s\sigma\in L(G)\\ &(\because L(f^{\prime}/G^{\prime})\subseteq L(G^{\prime})=L(g/G))\\ \Rightarrow&s\sigma\in L(g/G)\\ &(\because L(g/G)\text{ is }\text{ controllable }\text{ with respect to }L(G))\\ \Rightarrow&s\sigma\in L(f^{\prime}/G^{\prime})\\ &(\because L(f^{\prime}/G^{\prime})\text{ is }\text{ controllable }\text{ with respect to }L(g/G))\end{array} \]  
\(L(f^{\prime}/G^{\prime})\) is a controllable and closed sublanguage of \(L(G)\). At Line 15, there exits supervisor \(f\) such that \(L(f/G)=L(f^{\prime}/G^{\prime})\).