# GAO-FCNN-Enabled Beamforming of the RIS-Assisted Intelligent Communication System
## 3 Gao-Fnn
### Genetic Algorithm Optimization  
As shown in Figure 2, the network parameters are optimized using GA. Firstly, some preparations are defined as follows. \(\mathbf{W}^{(l)}\) is represented as FCNN to denote weight matrices,\(\mathbf{e}^{(l)}\) is represented as bias vectors, and \(L\) is represented as the number of layers. For each weight \(\mathbf{W}^{(l)}\) and bias \(\mathbf{e}^{(l)}\), they are first converted to floating point numbers within \([0,1]\), then these floating-point numbers are converted to binary strings of length 4. Individuals are encoded as  
\[\mathbf{u}=(\mathbf{W}^{(1)},\mathbf{e}^{(1)},\mathbf{W}^{(2)},\mathbf{e}^{(2)},\ldots,\mathbf{W}^{(l)},\mathbf{e}^{(l)},\ldots,\mathbf{W}^{(L)},\mathbf{e}^{ (L)}), \tag{20}\]  
so that the first step is carried on to initialize the population in Figure 2. According to Equation (22), the number of individuals is defined as the size of the initial population and each individual in the population is expressed as a set of coded weights \(\mathbf{W}^{(l)}\) and bias \(\mathbf{e}^{(l)}\). These encoded individuals allow GA to explore different FCNN parameter configurations in the searching space. And the population \(\mathbf{u}\) can be subsequently initialized as  
\[\mathbf{U}=\{\mathbf{u}_{1},\mathbf{u}_{2},\ldots,\mathbf{u}_{o},\ldots, \mathbf{u}_{O}\}, \tag{21}\]  
where \(O\) represents the population size, and \(\mathbf{U}\) is the population. Here, configurations of FCNN are defined as individuals. Then each individual \(\mathbf{u}_{o}\) can be trained by FCNN to calculate the output of \(\hat{\mathbf{y}}\) through forward propagation. Consequently, the loss function is given by  
\[Loss(\mathbf{u}_{o})=\frac{1}{O}\sum_{o=1}^{O}\left(\hat{\mathbf{y}}_{o}- \mathbf{y}_{o}\right)^{2}, \tag{22}\]  
where \(\mathbf{y}_{o}\) denotes the actual value matching the \(o\)-th sample, and \(\hat{\mathbf{y}}_{o}\) is a predicted value of the \(o\)-th sample. Then, the next step is carried out to evaluate the fitness. Here, the individual performance is evaluated by computing the error between the output of FCNN and actual values. A higher fitness level means a better effectiveness of each individual. Afterward, the optimal chromosome (i.e., the best FCNN configuration) is saved following the third  
Figure 2: Genetic algorithm optimization flowchart. step in Figure 2. As shown in Algorithm 2, the evaluation of the adaptive value function is denoted by  
\[f(\mathbf{u}_{o})=T\log_{2}(1+SNR(\
u)){=T\log_{2}(1+\frac{||\mathbf{H}_{1} \mathbf{\Phi}\mathbf{H}_{2}\mathbf{g}v||^{2}}{N_{r}\sigma^{2}})}, \tag{23}\]  
so that the optimal chromosome (i.e., the best FCNN configurations) can be saved according to Algorithm 2. Then, the next step is carried out to select the best individual in Figure 2. Here, the best FCNN configurations are selected by using the roulette algorithm. The idea is to convert fitness values into selection probabilities using a \"roulette\" method. Therefore, individuals with higher fitness are more likely to be chosen to ensure that better genes are retained. The performance metrics of each network configuration are firstly calculated. Then, the selection probability of each configuration is determined based on its corresponding performance metrics. It can be given by  
\[\zeta(\mathbf{u}_{i})=\frac{f(\mathbf{u}_{i})}{\sum\limits_{o=1}^{O}f(\mathbf{ u}_{o})}, \tag{24}\]  
where \(\zeta(\bullet)\) is a function to determine the selection probability of each configuration and the signal strength enhancement or interference minimization under specific channel conditions can be achieved according to the designed performance metrics. Notably, network configurations with higher performance metrics are more likely to be selected in practice and the quality configurations are retained for performing the next generation.