# Quantum Computing Approaches for Mission Covering Optimization
## 4 Algorithm Implementation
### Scenario 2 (Two Constraints)
#### 4.2.2 Qaoah
, \tag{26}\]  
and the mixing Hamiltonian \(H_{m}\) becomes\[H_{m} =\sum_{p\in\mathbf{R}_{1}\times\mathbf{R}_{2}\times\mathbf{M}}\sum_{j=0 }^{\text{ID}_{max}}\text{C-DSWAP}(p,j) \tag{27}\] \[\quad+\frac{1}{2}\sum_{r_{1}\in\mathbf{R}_{1}}\sum_{ \begin{subarray} {c}r_{1}^{\prime}\in\mathbf{R}_{1}\\ r_{1}\
eq r_{1}^{\prime}\end{subarray} }\text{COL-SWAP}(r_{1},r_{1}^{\prime}) \quad.\] (28) \[\quad+\frac{1}{2}\sum_{r_{2}\in\mathbf{R}_{2}}\sum_{ \begin{subarray} {c}r_{2}^{\prime}\in\mathbf{R}_{2}\\ r_{2}\
eq r_{2}^{\prime}\end{subarray} }\text{COL-SWAP}(r_{2},r_{2}^{\prime})\]  
The constant \(\text{ID}_{max}\) represents the maximum required binary states to represent all columns. This is the number of resources in either \(\mathbf{R}_{1}\) or \(\mathbf{R}_{2}\), and it is represented by \(\text{ID}_{max}\):  
\[\text{ID}_{max}=|\mathbf{R}_{1}|=|\mathbf{R}_{2}|. \tag{29}\]  
Figure 5: (**a**) Initial State Layout. The initial state is similar to the QAOA case except with additional ID qubits to be used to support the constraint mixer. Each column of ID qubits forms a unique binary number for that resource within its resource set. (**b**) First Control Dual-Swap Operation. Through mixing, resource 2 is allocated to mission 2. In order to not violate the row constraint, resource 6 from \(\mathbf{R}_{2}\) is allocated using a dual-swap gate with controls on the ID qubits. (**c**) Column Swap. The mixing operator can never produce a valid solution where just resource 4 and 6 are paired to mission 2 using just Controlled Dual-Swap Operations. Therefore, column-swap operations are permitted, which swap any two columns in the table within its resource set. Here, resource 2 and 4 in resource set \(\mathbf{R}_{1}\) have their entire columns swapped. (**d**) Second Control Dual-Swap Operation. This operation is exactly the same as (**b**), but the Control Dual-Swap operator is used to unallocate resource 4 from mission 2 to mission \(U\). Notice that the Control Dual-Swap operator has its control configuration identical on both resource 4 and 6 ID-qubit columns; this is to ensure that the row constraint cannot be violated. A violation occurs when leaving resource 6 with no pair on mission 2. The column-swap gate, notated as \(\mathsf{COL-SWAP}(r,r^{\prime})\), swaps the columns represented by resources \(r\) and \(r^{\prime}\). Its decomposition is trivial as it employs many swaps tensored together. The control dual-swap, notated as \(\mathsf{C-DSWAP}(p,j)\), has parameters \(p\) and \(j\). The parameter \(p=(r_{1},r_{2},m)\) is a tuple composed of a resource from \(\mathbf{R_{1}}\), a resource from \(\mathbf{R_{2}}\), and a mission \(m\) in \(\mathbf{M}\). This gate applies a control swap gate to resource \(r_{1}\) and \(r_{2}\) between the mission \(m\) and the unallocated mission U. The parameter \(j\) is an ID which represents how to control the swap gate. For example, \(10_{\mathsf{b}}\) is applying a control-true, control-false gate to both IDs in the columns represented by \(r_{1}\) and \(r_{2}\). To implement the algorithm on the IBM machine, we must decompose \(H_{m}\) such that it is a sum of tensored Pauli gates. The column-swap gates \(\mathsf{COL-SWAP}(r,r^{\prime})\) can be decomposed, knowing that they are made up of swap gates, as from Equation (18). Decomposing a generalized version of the control dual-swap gate is tedious, so we provided an example decomposition for \(\mathsf{C-DSWAP}(*,10_{\mathsf{b}})\), which is the gate used in Figure 4(b),d. First, we present the Pauli-decomposition of the control-true and control-false unitary operations shown in Equations (29) and (30), respectively. Unitary \(A\) is arbitrarily acting on \(m\) qubits. \[\mathsf{C-T}(A)=\frac{1}{2}\big{(}(I+Z)\otimes I^{\otimes m}+(I-Z)\otimes A \big{)}. \tag{29}\]  
\[\mathsf{C-F}(A)=\frac{1}{2}\big{(}(I-Z)\otimes I^{\otimes m}+(I+Z)\otimes A \big{)}. \tag{30}\]  
Now, \(\mathsf{C-DSWAP}(*,10_{\mathsf{b}})\) can be represented in terms of control-true and control-false unitaries and the dual-swap gate \(\mathsf{DSWAP}\):  
\[