# A Novel RPL Algorithm Based on Chaotic Genetic Algorithm
## 3 RPL-Cga
### Optimizing Weighting Factors of Routing Metrics
In contrast, the key issue of determining \(F(i)\) is determining weighting factor of each metric (\(\mathbf{a}=(a_{1},\ a_{2},\cdots,\ a_{m})\)). To this end, the fitness function can be defined as shown in Equation (11). \[\mathit{Fitness}(a)=\frac{1}{F(i)+1},(i=1,2,\cdots,n) \tag{11}\]  
\[\max\mathit{Fitness}(a),\ s.t.\ \sum_{j-1}^{m}a_{j}=1,0\leq a_{j}\leq 1 \tag{12}\]  
It can be seen that the fitness function \(\mathit{Fitness}(a)\) only changes with the weighting factor variables. Therefore, as shown in Equation (12), the weighting factors can be evaluated through calculating the maximum value of the fitness function under constraint conditions. Then, the population individual corresponding to maximum \(\mathit{Fitness}(a)\) is the final weighting factor allocation plan of each routing metric. Therefore, this is a kind of complicated nonlinear optimal solution problem. To this end, we proposed the chaotic genetic algorithm to solve this problem. Step 3: generating initial population by chaotic system  
The chaotic system [25] is characterized by sensitive to initial values, generating better randomness sequence, traversing all state points in chaotic region, long term unpredictable etc. Therefore, this paper uses the representative logistic map [26] to produce initial population genes and chaos perturbation vectors. The system state equation of the chaotic system is shown in Equation (13). \[\tau_{z+1}=\eta\tau_{z}(1-\tau_{z}),z=0,\ 1,\ 2,\cdots,\ 0<\tau_{0}<1,0\leq\eta\leq 4 \tag{13}\]  
In Equation (13), \(\eta\) is a control parameter. When \(\eta>3.57\) and \(\tau\
eq 0.25,0.5,0.75\), the system goes into a chaotic state, and the iteration results are similar to random numbers [0, 1]. In this paper, \(\tau=4\). RPL-CGA selects \(w\) population individuals and assigns \(m\) genes to each population individual. That is, RPL-CGA chooses \(w*m\) population genes from a chaotic sequence produced by the chaotic system. The individual gene corresponds to the weighting factor of each routing metric. So the selection of individual genes should satisfy the constraint conditions shown in Equation (10). Then, the initial population can be recorded as \(\left\{h_{ij}|(i=1,2,\cdots,w;j=1,2,\cdots,m)\right\}\), and \(h_{i}\) is a probable weighting factors distribution method of metrics (\(\mathbf{a}=(a_{1},\ a_{2},\cdots,\ a_{m})\)). Step 4: selecting superiority individuals  
RPL-CGA computes fitness function values for every \(\mathbf{h_{i}}\) (population individual) based on Equation (11). Then, the larger the value of \(\mathit{Fitness}(h_{i})\), the closer \(\mathbf{h_{i}}\) is to the optimal solution, and also, the better to select \(\mathbf{h_{i}}=(h_{i1},h_{i2},\cdots,h_{im})\) as weighting factors allocation scheme. That is, RPL-CGA calculates the fitness function value \(\mathit{Fitness}(h_{i})\) of each population individual, arranges \(\mathbf{h_{i}}\) in descending order based on the fitness function values, selects the first 15% of them as superior individuals, and brings these superior individuals to the next generation population directly (no crossover, mutation, and other operations). Step 5: generating the next generation population  
The rest of 85% population individuals of the next generation are generated via crossover and mutation of the genetic algorithm. Step 6: adding chaotic perturbation  
Adding chaotic perturbation to population individuals can make RPL-CGA reduce evolution algebra, avoid local convergence, and find the best solution as quickly as possible. Moreover, RPL-CGAonly applies chaotic perturbation to the 85% individuals with lower fitness function values according to Equation (14), which will shrink the search range and improve optimization efficiency. \[h^{\prime}=(1-\alpha)h+\alpha h^{\prime\prime} \tag{14}\]  
In Equation (14), \(h\) is the current 85% population individuals generated in step 5. \(h^{\prime\prime}\) is \(m\)-dimension chaotic perturbation vector chosen from the chaotic series.