# A Setting Optimization Ensemble for a Distributed Power Grid Protective Relay
## 4 Quantum Genetic Optimization Model
### The Operational Step of QGO  
Qubits can exist in states \"1\" or \"0\", or they may simultaneously exist in any superposition between the two. The main steps of the QGO model process are as follows:  
1. Initialize the qubit chromosome population \(P(t)\). 2. Solve a set of two-state solutions \(S(t)\) by \(P(t)\) states. 3. Evaluate \(S(t)\), and solve the optimal solution stored in \(S(t)\). 4. If the termination condition is not reached, generate \(S(t)\) from the previous time sequence \(P(t-1)\) of the qubit chromosome population in each iteration. 5. Update \(P(t)\) according to quantum gate \(V(t)\). 6. Store the optimal solution in \(S(t)\) until the termination condition is reached. On the basis of the genetic algorithm, QGO adds a probability analysis model. QGO often takes a qubit chromosome population as the object of genetic evolution, and in the \(t\) generation, the population can be represented as  
\[P(t)=\left\{p_{1}^{t},p_{2}^{t},\cdots,p_{n}^{t}\right\} \tag{30}\]  
where \(n\) is the population size, that is, the total number of qubit chromosomes in the population, and \(p_{j}^{t}\) is a qubit chromosome, which can be written as  
\[p_{j}^{t}= \begin{bmatrix}a_{1}^{t}&a_{2}^{t}&\cdots&a_{m}^{t}\\ b_{1}^{t}&b_{2}^{t}&\cdots&b_{m}^{t}\end{bmatrix}  \tag{31}\]  
where \(m\) is the number of qubits in a qubit chromosome, that is, the string length of the qubit chromosome, \(j=1,\,2,\,\ldots,\,\,n\). During the initialization of \(P(t)\), \(p_{j}^{t}\) in all \(P(t)\) is preset to \(1/\sqrt{2}\). That is, \(\left.p_{j}^{t}\right|_{t=0}\) refers to a qubit chromosome with the same probability of linear superposition of all possible states, whose states can be written as  
\[\langle\psi_{p_{j}^{t}}\rangle=\sum_{k=1}^{2^{m}}\frac{1}{\sqrt{2^{m}}}X_{K} \tag{32}\]where \(X_{K}\) is composed of the two-state strings \(x_{1},\ x_{2},\ \ldots,\ x_{m}\) and represents the kth state. Next, based on \(P(t)\), we solve a set of binary solution \(S(t)=\left\{x_{1}^{t},x_{2}^{t},\cdots x_{n}^{t}\right\}\). Any binary solution \(x_{j}^{t}\) is a two-state string of length \(m\). The variable \(x_{j}^{t}\) is formed with the probability of each qubit, \(p_{j}^{t}\), and has the state \(\left|a\right|^{2}\) or \(\left|b\right|^{2}\). Each solution \(x_{j}^{t}\) can be used to evaluate its fitness, and the optimal solution is selected and stored in the two-state solution \(S(t)\). In the iterative process, the two-state solution \(S(t)\) is solved according to the state of the previous time sequence \(P(t-1)\) of the qubit chromosome population, and the relevant fitness is obtained by evaluating each two-state solution. Next, each set of qubits of chromosome \(S(t)\) is updated by constructing a quantum gate \(V(t)\). \(V(t)\) is usually formed by the two-state solution \(S(t)\) and the optimal storage solution, which can be designed according to actual needs. In this paper, a revolving gate is chosen, whose mathematical expression is as follows:  
\[V(\theta)= \begin{bmatrix}\cos\theta&-\sin\theta\\ \sin\theta&\cos\theta\end{bmatrix}  \tag{33}\]  
In the iterative step, the best solution in a set of two-state solutions, \(S(t)\), is stored and compared with the next set of solutions in the next cycle, and the better solution is preserved. The iterative steps are repeated until an optimal solution is reached. In general, quantum genetic optimization (QGO) maintains a constant population size, implying that the number of qubit chromosomes remains unchanged. This is a consequence of the qubit conservation principle in quantum computing theory. When compared to the conventional genetic algorithm (GA), QGO, utilizing qubit representation, demonstrates superior performance in terms of diversity and convergence. This distinctive characteristic enables QGO to effectively preserve population diversity while exhibiting enhanced efficiency in the search for optimal solutions.