## 4 Adaptive Genetic Algorithm for Joint Optimization
### Genetic Encoding and Evaluation  
GA is a popular nature selection based heuristic approach to efficiently search the near-optimal solutions with low complexity [55]. The search procedures of GA are based on the mechanics of natural selection and natural genetics. GA is developed to allow computers to evolve solutions to difficult function optimization problems [56; 57]. The basic operation of a GA could be divided into three steps: (1) maintain a population of solutions to a problem, (2) select the better solutions for recombination with each other, and (3) use their offspring to replace poorer solutions. A candidate solution for the given problem is encoded as a chromosome (or an individual). Each individual is evaluated by a fitness function, and better individuals have more opportunities to go through further genetic procedures: including selection, crossover, and mutation operations.  
Each optical fronthaul link, including corresponding transceiver, ONU, and RRU, is indicated by a gene vector. The gene is encoded in \(\xi_{i,j}=\left\{s_{i},r_{i},\sigma_{j},\delta_{Wj},O_{i},R_{i}\right\}\). Boolean variables \(s_{i}\), \(r_{i}\), and \(\sigma_{j}\) indicate whether the \(i\)th ONU, RRU, and \(j\)th transceiver are active, respectively. In addition, Boolean variable \(\delta_{Wj}\) shows that whether wavelength \(W_{j}\) is distributed to ONU \(O_{i}\) (or RRU\(R_{i}\)) for signal forwarding.  
For the energy and transmission efficiency optimization problem in the reconfigurable fronthaul, our objective is to search a series of near-optimal Boolean variables (e.g., \(s_{i}\), \(r_{i}\), \(\sigma_{j}\), and \(\delta_{Wj},(O_{i},R_{i})\)that satisfied with Equations (1), (2) and (4). Each wavelength is served by a transceiver in the OLT, which means that there is one-to-one correspondence between wavelength \(W_{j}\) and \(\sigma_{j}\). A chromosome is consisted of \(N\) genes, denoted as \(\mathrm{I}=\left\{\zeta_{1,j1},\ldots,\zeta_{N,jN},j_{1},\ldots,j_{N}\in\{1, \ldots,S\}\right\}\). Then we define a population with \(\mathrm{K}\) individuals as \(\psi\). Each individual is a candidate solution for the energy and transmission efficiency problem in the TWDM-PON enabled fronthaul.  
The initial population \(\psi\) with \(K\) individuals is formed randomly. Since there are three sub-objectives in the problem, weighting method is introduced during optimization. The fitness function is shown in Equation (10).  
\[F(\mathrm{I})=(\alpha_{1},\alpha_{2},\alpha_{3})\cdot\left(\frac{1}{P_{ fronthaul}},\eta,\frac{1}{LB_{fronthaul}}\right)^{\prime}(\mathrm{I}) \tag{10}\]  
Meanwhile, during the chromosome generation for initial population, selection, crossover, and mutation phase, not all individuals are feasible, since some of them may not meet the constraints shown in Equations (7)-(9). A penalty function is adopted to face the potential problem, considering of the constraints described in Section 4. For any illegal individual who does not satisfy the constraints, a penalty is added to decrease its fitness value. Finally, the modified fitness function is shown in Equation (11).  
\[F\left(\mathrm{I}\right)=\begin{cases}F(\mathrm{I}),&\text{I \ is legal}\\ F(\mathrm{I})-\epsilon\,0\sum\limits_{k=1}^{3}penalty(k,\mathrm{I}),&\text{I \ is illegal}\end{cases} \tag{11}\]  
where \(\epsilon\)0 is defined as the penalty factor, indicating the degree of penalty. Penalty function \(penalty(k,\mathrm{I})\) returns 0 if individual \(\mathrm{I}\) meets the corresponding constraint, and 1 otherwise.