# Quantum Circuit Synthesis Using Fuzzy-Logic-Assisted Genetic Algorithms
## Appendix A Fitness Function  
Here, we discuss some of the issues with using an Euclidean distance-based method for combining multiple metrics into a single one. To enable proper combination and avoid bias, we need to first rescale all metrics to the same range. While the approximation error function already gives us a value in the range \([0,1]\), the other two metrics also need to be scaled to such a range. The metrics for depth and CNOT could, therefore, be calculated by first measuring them for each circuit and then normalizing them to the range \([0,1]\), using (A1) and (A2).  
\[\mathbf{D}(C_{syn})=\frac{\text{No. of layers}}{\text{Highest no. of layers in the population}}\] (A1)  
\[\mathbf{G_{2}}(C_{syn})=\frac{\text{No. of CNOTs}}{\text{Highest no. of CNOTs in the population}}\] (A2)  
Once normalized, the three values can be combined using the Euclidean distance formula, as shown in (A3), to obtain the final fitness value of a chromosome, also in the range \([0,1]\).  
\[\mathbf{F}(C_{syn})=\sqrt{\mathbf{E}(U_{in},C_{syn})^{2}+\mathbf{D}(C_{syn} )^{2}+\mathbf{G_{2}}(C_{syn})^{2}}\] (A3)  
This method, however, presents several challenges. Firstly, the Euclidean distance-based aggregation implies that in a Cartesian space with the metric axes, all points in a given hypershpere would have the same overall fitness; see Figure A1. In our testing, this would often cause the population of chromosomes to be saturated with shallow, low gate-count circuits with high approximation error, since it was easier for the GA to remove gates and layers than to optimize for approximation error.  
This method can also lead to extreme edge cases where circuits with zero (or close to zero) depth and zero CNOTs automatically gain an (unfair) advantage, even though for most cases they would have very low accuracy. For example, for two synthesized circuits \(C_{1}\) and \(C_{2}\), let \(\mathbf{E}(U_{in},C_{1})=0.3\), \(\mathbf{D}(C_{1})=0.6\), \(\mathbf{G_{2}}(C_{1})=0.3\), while \(\mathbf{E}(U_{in},C_{2})=0.9\), \(\mathbf{D}(C_{2})=0.1\), \(\mathbf{G_{2}}(C_{2})=0.0\). Using (A3), we have \(\mathbf{F}(C_{1})=0.735\), whereas \(\mathbf{F}(C_{2})=0.316\), indicating \(C_{2}\) is roughly twice as better, despite having three times the approximation error!To counteract this issue, weights could be added to each objective, to encourage the GA to find more accurate circuits, without completely disregarding depth and CNOT count. This, however, still does not solve the edge case of zero depth or zero CNOT circuits. Moreover, introducing weights add yet another set of parameters which need tuning, and ascertaining a good ratio between accuracy, depth and gate count is a difficult task.  
Euclidean distances can also be affected by the statistical distributions of the metrics. For example, if the standard deviations observed in \(\mathbf{E}(U_{in},C_{syn})\) are small compared to the standard deviations in \(\mathbf{G_{2}}(C_{syn})\), the overall fitness value becomes more _sensitive_ to the CNOT count. We observed this when a small change in the number of CNOTs affected the final fitness value much more than changes in approximation error.  
Since useful compilations of quantum circuits for NISQ devices require optimizing for multiple objectives, an alternative means of combining the metrics was still needed, which led us to choose the NSGA-II algorithm. It allowed the use of different objective metrics without needing to normalize them, assign weights or combine them into a single metric, alleviating many of the issues of the method discussed here.