Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 10, No. 2, 2024 114 Improved Crab Algorithm Based on Chaos Theory and Its Application in Parameter Identification of Fresnel Refractive Index Lifei Zhu, Lipu Zhang* College of Media Engineering, Communication University of Zhejiang, Hangzhou, 310018, China * Corresponding author: 215702224@stu.cuz.edu.cn Abstract: The Crab Algorithm is an evolutionary algorithm inspired by the behavior of crabs, which balances global search and local optimization by simulating the behavioral strategies of crabs. This paper introduces chaos theory and proposes a chaos disturbance strategy. Chaos variables are introduced into the iteration process of the Crab Algorithm to perturb the position and velocity of individuals, thereby escaping local optima and achieving global optimization. Several test functions are used to compare the new algorithm with the original one, yielding better results. In the application of parameter identification of Fresnel refractive index, an optimization model is constructed, and the improved Crab Algorithm is applied to solve the model. The experimental results show that compared with the traditional Crab Algorithm, the improved algorithm proposed in this paper has significantly improved identification accuracy and convergence speed. In addition, by comparing with other optimization algorithms, the superiority of this paper's algorithm is verified. Keywords: Hermit Crab Algorithm, Chaotic, Optimization, CEC2005, intelligent algorithm. 1. Background Introduction Crab optimization algorithms are a type of heuristic optimization algorithm inspired by natural phenomena or human behavior, which seeks the optimal solution based on the characteristics of natural phenomena. Heuristic optimization algorithms include Bat Algorithm (BA), Particle Swarm Optimization (PSO), Simulated Annealing (SA), Ant Colony Optimizer (ACO), Differential Evolution (DE), Whale Algorithm (WA), etc. These algorithms can be combined with different algorithms for improvement according to different situations. The improved algorithms can be used to solve various practical problems, such as: the improved NLM strategy based on genetic algorithm [1], vehicle network computing offloading based on improved whale optimization algorithm [2], DV-Hop positioning algorithm optimized by improved sparrow search [3], and wireless sensor network coverage optimization based on improved particle swarm algorithm [4]. The Crab Algorithm (CA) was proposed by Li Shuanglong and Gu Siyu in 2012, which simulates the method of crabs constantly searching for the most suitable shell for their survival in coastal wetlands. It has the advantages of strong global search ability and strong adaptability. However, there is still a lot of room for improvement in parameter setting and convergence speed. In 2023, Guo Jia et al. proposed a hermit crab optimization algorithm (HCOA) [5], in which the randomly wandering crabs balance breadth-first search and depth-first search based on the two search methods of optimal search and historical path search, making them jump out of local optima. The adaptability of each crab is compared, and the crab with the highest adaptability is set as the alpha crab. Since the alpha crab has more and better survival experience, it is more likely to attract more crabs to wander around the highly adaptable alpha crab. The search range for the optimal solution gradually decreases, making the algorithm more likely to fall into local optima. Both search strategies only produce linear changes in time complexity, without considering non-linear changes. Chaos algorithm (CA) was first proposed by the French mathematician Henri PoincarΓ©. Chaos search strategy is a search method based on the form of chaos variables, aimed at improving the efficiency of later searches. Chaos is a common phenomenon in nonlinear systems, and its search has become a novel global optimization technology. The chaos search strategy uses chaos mapping to generate chaos sequences and follows specific rules during the search process. This strategy is renewable, can show ergodicity in the search space, and any state will not reappear, thus helping to coordinate global search and local development. Applying this algorithm to other optimization algorithms can improve the search ability of the algorithm, such as: multi-robot conflict resolution simulation study based on improved chaos ant algorithm [6], improved cuckoo search algorithm based on chaos algorithm and its application [7], traffic light duration adjustment simulation based on chaos genetic algorithm [8]. In general, ordinary crabs will follow the alpha crab to find the most suitable shell, but in reality, some crabs may not closely follow the alpha crab. To simulate this phenomenon, this paper introduces chaos theory, and at each iteration, chaos values are introduced as step lengths, increasing the randomness and ergodicity in the process of crabs searching for shells. This results in an improved Crab Algorithm based on chaos theory, which can dynamically adjust the search direction and step length according to the progress of the search. When the algorithm falls into a local optimum, the chaos search strategy can guide the crabs to jump out of the current area and enter a new search space, thus avoiding premature convergence. To fully verify the effectiveness of the two algorithms designed in this paper - the Crab Algorithm based on chaos search strategy (referred to as HCOA-CS) and its original algorithm HCOA, this paper conducts a series of detailed numerical example tests. These tests cover multiple 115 commonly used CEC (Congress on Evolutionary Computation) test functions to ensure the universality and robustness of the algorithms. And we use the improved HCOA-CS algorithm to solve the problem of parameter identification of Fresnel refractive index. The structure of this paper is as follows: Chapter 1 introduces the background; Chapter 2 introduces the algorithm flow of the Crab Algorithm, incorporates the chaos search strategy into the Crab Algorithm, and compares the algorithms; Chapter 3 applies the improved Crab Algorithm to the problem of parameter identification of Fresnel refractive index; Chapter 4 summarizes and generalizes the paper. 2. Improved Crab Algorithm Based on Chaos Theory 2.1. Crab Optimization Algorithm The Crab Optimization Algorithm simulates the method of crabs in reality to find shells as their homes. The alpha crab, with more valuable experience, allows other crabs to find more suitable homes near the alpha crab. However, when it doesn't find a more suitable home, it will return to its original home. For crabs, a home is the foundation of their survival. Without a home, there is nothing to provide protection and shelter, and they will be exposed to predators. Moreover, the shell can protect the crab's abdomen, maintaining body humidity and temperature. Without a shell, crabs will die due to environmental factors (wind, sun, dryness, cold, etc.). The Crab Optimization Algorithm simulates the process of crabs constantly searching for a more suitable home for their survival. In this algorithm, there are two types of crabs: ordinary crabs and alpha crabs. In each iteration, the alpha crab is selected through the optimal search algorithm and is used as a temporary optimal solution. Crabs wander around the selected alpha crab, and in order to better find suitable homes for themselves, they search near the five houses recently left by the alpha crab through the historical path search algorithm, updating the position of the crabs. 2.2. Main steps of HCOA The specific steps of the Crab Optimization Algorithm are as follows: (1) Initialize data. Set the number of populations, dimensions, iteration times, and other parameters, and initialize the positions of crabs within the limit range, and calculate the fitness. Record the historical position and fitness value of the global best house (shell). (2) Determine the alpha crab. Select the crab with the best fitness from the initialized crab population as the alpha crab. (3) Use the optimal search algorithm to select an alpha crab for each crab, and update the parameter values according to the position of the alpha crab. Crabs wander around the selected alpha crab, and in order to better find suitable homes for themselves, they search near the five houses recently left by the alpha crab through the historical path search algorithm, updating the position of the crabs. (4) Calculate the fitness values of crabs and alpha crabs, and update the position of the alpha crab according to the position and fitness of the crabs. The best position is the new alpha crab's position. (5) Determine whether the algorithm's stopping conditions are met. If so, output the results, return the position and fitness of the alpha crab, and end the iteration; otherwise, go back to step (3). 2.3. Optimal Search Strategy and Historical Path Search Strategy The optimal search strategy is a mechanism in the Crab Optimization Algorithm used to guide individual crabs to search towards the currently found optimal solution. In each iteration of the algorithm, each crab individual updates its position and search direction based on the information of the current optimal solution. The optimal search strategy calculates the distance and direction between the current optimal solution and the crab individual, guiding the crab individual to approach the optimal solution. This strategy allows the algorithm to continuously approach the global optimal solution during the search process, thereby improving the convergence speed and solution accuracy of the algorithm. The implementation of the optimal search strategy usually involves the storage and update mechanism of the optimal solution. The algorithm maintains a global optimal solution list to record the current optimal solution information. In each iteration, the algorithm updates this list, adding new better solutions to it. Then, crab individuals formulate their search strategy based on the optimal solution information in this list. This strategy allows the algorithm to make full use of known optimal solution information, avoiding redundant searches of already explored areas, thereby improving search efficiency. The historical path search strategy is a mechanism in the Crab Optimization Algorithm used to guide individual crabs to search based on their past search paths. During the search process of the algorithm, each crab individual records its search history, including previously visited positions and search directions. The historical path search strategy uses this information to guide crab individuals to avoid revisiting areas that have been fully explored in the current search and instead turn to areas that have not been fully explored for search. If the current position is similar to a historical position, the algorithm will guide the crab individual to search in another direction to avoid falling into local optima. 2.4. Chaos Search Strategy Chaos mapping is used to describe and generate chaotic behavior, and common chaos mappings include one- dimensional Logistic mapping, two-dimensional He'non mapping, three-dimensional Lorenz mapping, piece wise linear chaos mapping, piecewise nonlinear chaos mapping, etc. This paper selects the one-dimensional Logistic mapping to affect the position update of crabs. The one-dimensional Logistic mapping is a simple chaotic mapping with extremely complex dynamic behavior. Its mathematical expression is as follows: Xn 1 Xn ΞΌ 1 Xn , (1) ΞΌ is called the logistic parameter, which is the value of the chaotic parameter introduced in this paper, X∈ [0,1]. The original search method is as follows: step_size rand 1, dim (2) After introducing chaos mapping: step_sizes chaos_values; (3) chaos_values = chaos_function(rand(1, dim), 116 chaos_parameter, dim); And the chaos_values are obtained by applying the formula (1) in the chaos_function.Then, according to the obtained step_sizes, the position is updated and the fitness value after position update is calculated. new_individual = best_individual + step_sizes .* (population(i, :best_individual); (4) 2.5. Main Steps of HCOA Based on Chaos Search Strategy The steps of the improved algorithm are as follows: (1) Initialize data. Set the number of populations, dimensions, iteration times, and other parameters, and initialize the positions of crabs within the limit range, and calculate the fitness. Record the historical position and fitness value of the global best house (shell). (2) Determine the alpha crab. Select the crab with the best fitness from the initialized crab population as the alpha crab. (3) Use the optimal search algorithm to select an alpha crab for each crab, and update the parameter values according to the position of the alpha crab. Crabs wander around the selected alpha crab, and in order to better find suitable homes for themselves, they search near the five houses recently left by the alpha crab through the historical path search algorithm, updating the position of the crabs. (4) Introduce the chaos search algorithm, and the position of crabs is updated according to formula (4). (5) Calculate the fitness values of crabs and alpha crabs, and update the position of the alpha crab according to the position and fitness of the crabs. The best position is the new alpha crab's position. (6) Determine whether the algorithm's stopping conditions are met. If so, output the results, return the position and fitness of the alpha crab, and end the iteration; otherwise, go back to step (3). 2.6. Experiment and analysis This section compares the newly proposed Crab Optimization Algorithm based on chaos mapping (HCOA- CS), Particle Swarm Optimization Algorithm (PSO), Bat Algorithm (BA), and the original Crab Optimization Algorithm (HOCA) through comparative experiments. By comparing the solutions of some test functions in CEC2005, the effectiveness of the algorithm improvement is analyzed. The test functions used in the experiments are shown in the Table 1 below: Table 1. Some CEC2005 Test Functions NO Functions D Search space f F1 𝐹 π‘₯ π‘₯ 30 100,100 0 F2 𝐹 π‘₯ |π‘₯ | |π‘₯ | 30 10,10 0 F3 𝐹 π‘₯ π‘₯ 30 100,100 0 F4 𝐹 π‘₯ π‘šπ‘Žπ‘₯ |π‘₯ |, 𝑖 𝑖 𝑛 30 100,100 0 F5 𝐹 π‘₯ 100 π‘₯ π‘₯ π‘₯ 1 30 30,30 0 F6 𝐹 π‘₯ π‘₯ 0.5 30 100,100 0 F7 𝐹 π‘₯ 𝑖π‘₯ π‘Ÿπ‘Žπ‘›π‘‘π‘œπ‘š 0,1 30 1.28,1.28 0 F8 𝐹 π‘₯ π‘₯ 10π‘π‘œπ‘  2πœ‹π‘₯ 10 30 5.12,5.12 0 F9 𝐹 π‘₯ 20𝑒π‘₯𝑝 0.2 1 𝑛 π‘₯ 𝑒π‘₯𝑝 1 𝑛 cos 2πœ‹π‘₯ 20 𝑒 30 32,32 0 F10 𝐹 π‘₯ 1 4000 π‘₯ cos π‘₯ βˆšπ‘– 1 30 600,600 0 F11 𝐹 π‘₯ πœ‹ 𝑛 10sin πœ‹π‘¦ 𝑦 1 1 10sin πœ‹π‘¦ 𝑦 1 𝑒 π‘₯ , 10,100,4 30 50,50 0 F12 𝐹 π‘₯ 0.1 sin 3πœ‹π‘₯ π‘₯ 1 1 sin 3πœ‹π‘₯ π‘₯ 1 1 sin 2πœ‹π‘₯ 𝑒 π‘₯ , 5,100,4 30 50,50 0 F13 𝐹 π‘₯ = βˆ‘ βˆ‘ 2 65.536, 65.536 0.99800383779445 F14 𝐹 π‘₯ π‘Ž π‘₯ 𝑏 𝑏 π‘₯ 𝑏 π‘₯ 𝑏 π‘₯ 4 5,5 0.0003075 F15 𝐹 π‘₯ 4π‘₯ 2.1π‘₯ 1 3 π‘₯ π‘₯ π‘₯ 4π‘₯ 4π‘₯ 2 5,5 0.99800383779445 F16 𝐹 π‘₯ 1 π‘₯ π‘₯ 1 19 14π‘₯ 3π‘₯ 14π‘₯ 6π‘₯ π‘₯ 3π‘₯ 30 2π‘₯ 3π‘₯ 18 32π‘₯ 12π‘₯ 48π‘₯ 36π‘₯ π‘₯ 27π‘₯ 2 2,2 2.99999999999992 117 The experimental parameters are set as follows: the population size is 40, the maximum number of iterations is 10,000, and the chaos value is 6. To ensure the accuracy of the results, both algorithms will be independently run 30 times in the same version of Matlab software, and the mean (mean) and standard deviation (std) of each benchmark function will be calculated. The experimental results are shown in Table 2 Table 2. Comparison of Results for Solving Test Functions F index HCOA HCOA-CS POS BA F x mean 6.96009E+03 3.82009E-16 2.8431E-01 3.0287E+00 std 1.21585E+06 2.60852E-30 6.3156E-03 1.1864E-01 F x mean 3.33325E+01 7.64726E-86 2.7590E-02 7.6621E+00 std 4.67371E+01 2.35289E-171 3.5397E-04 2.0926E-01 F x mean 9.16933E+03 4.28676E+00 3.2065E+00 5.2386E+00 std 3.48270E+06 1.59863E+01 1.9552E-01 2.9499E-01 F x mean 3.58488E+01 1.06552E+01 4.0499E-01 6.5580E-01 std 8.31680E+00 4.36604E+00 1.8465E-03 1.4393E-03 F x mean 3.31712E+06 2.81164E+01 5.2637E-01 3.7003E+02 std 7.41495E+11 3.68310E+02 2.0322E-02 1.4062E+03 F x mean 7.15686E+03 8.07189E-12 6.08095E-01 3.1273E+00 std 1.38309E+06 1.26931E-21 9.70426E-03 5.1356E-02 F x mean 2.75649E+00 3.31727E-01 1.55748E-01 1.0920E+01 std 1.52481E-01 8.93019E-03 9.97981E-04 2.7477E+00 𝐹 π‘₯ mean 1.40078E+02 1.22279E+01 4.27201E+01 1.8838E+02 std 7.33128E+01 3.92991E+00 4.74940E+01 1.2603E+02 𝐹 π‘₯ mean 1.40515E+01 7.04206E-07 1.59951E+00 2.9700E+00 std 2.81215E-01 4.60463E-12 2.80632E-02 1.8230E-02 𝐹 π‘₯ mean 6.69868E+01 1.04419E-12 3.31032E-02 1.5080E-01 std 1.11385E+02 9.52328E-24 2.07988E-05 2.1080E-04 𝐹 π‘₯ mean 2.36775E+05 2.58009E-08 2.65789E-02 1.1030E+01 std 1.06020E+10 1.18660E-14 2.70534E-05 1.8471E+00 𝐹 π‘₯ mean 6.83287E+06 2.61707E-04 4.99101E-01 4.7660E-01 std 2.43027E+13 5.81193E-07 9.45255E-03 1.7206E-03 𝐹 π‘₯ mean 1.0489E+00 9.98004E-01 1.26705E+01 1.0311E+00 std 4.02780E-02 0 0 3.2936E-02 𝐹 π‘₯ mean 6.28932E-04 4.2898E-04 3.07487E-04 4.4827E-04 std 6.76832E-08 6.32091E-09 0 4.19197E-09 𝐹 π‘₯ mean -1.031628E+00 -1.031628E+00 -1.031628E+00 -1.031627E+00 std 0 0 0 1.55417E-12 𝐹 π‘₯ mean 2.9999E+00 2.9999E+00 2.9999E+00 3.0001E+00 std 3.2915E-30 0 0 2.4440E-09 The following is a statistical chart of the number of times the four algorithms achieve the optimal mean and standard deviation in solving the above 16 functions, as shown in Figure 1. Among them, the HCOA-CS algorithm's solution results are mostly optimal, and the stability is strong, indicating that the improvement of the Crab Algorithm with chaos algorithm has a certain effect. Figure 1. Proportion of Optimal Mean and Standard Deviation Achieved by Four Algorithms 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% mean std HCOA 118 To more intuitively reflect the superiority of the HCOA-CS algorithm, the following are some convergence diagrams of PSO, BA, and HCOA algorithms in solving the above partial test functions under 1000 iterations, as shown in the Figure2 below.The horizontal axis of all the following figures represents the number of iterations, and the vertical axis represents the convergence value. The convergence curves of four different algorithms are displayed. F1 F2 F3 F4 F5 F6 F8 F9 119 F10 F11 Figure 1. Partial test function convergence result 3. Application of Improved Crab Algorithm in Identification of Fresnel Refractive Index Parameters 3.1. Fresnel Formula π‘Ÿ 𝑛 cos πœƒ 𝑛 cos πœƒ 𝑛 cos πœƒ 𝑛 cos πœƒ π‘Ÿ 𝑛 cos πœƒ 𝑛 cos πœƒ 𝑛 cos πœƒ 𝑛 cos πœƒ 𝑑 2𝑛 cos πœƒ 𝑛 cos πœƒ 𝑛 cos πœƒ 𝑑 2𝑛 cos πœƒ 𝑛 cos πœƒ 𝑛 cos πœƒ When the reflected light wave only contains the component perpendicular to the incident plane, i.e., the S wave, with ΞΈ ΞΈ , we call ΞΈ the Brewster angle. In this case, the reflected light wave only contains S-polarized light, with r = 0. When ΞΈ is the Brewster angle, ΞΈ ΞΈ , and it is known that sin ΞΈ cos ΞΈ =1. These two formulas can be substituted into a certain formula. r , and the results are obtained r r In this context, π‘Ÿ represents the amplitude reflectivity of the p-component when the incident angle is πœƒ , and π‘Ÿ represents the amplitude reflectivity of the s-component when the incident angle is πœƒ . Additionally, 𝑛1 and 𝑛2 represent the refractive indices of the media. 3.2. Apply the improved hermit crab algorithm to the identification problem of Fresnel refractive index parameters. (1) The steps for applying the improved algorithm to parameter identification problems are as follows: Through various experimental data, the refractive index of a specific medium and the corresponding incident angle are known, and the specific data are added to the algorithm. (2) Define the loss function as: F 0.5( Rp_estimated Rp_true Rs_estimated Rs_true οΌ‰ In this context, Rp_estimated represents the amplitude reflectivity of the p-component calculated by the algorithm optimization, while Rp_true is the amplitude reflectivity of the p-component obtained by substituting the actual values into the formula. Similarly, Rp_estimated represents the 120 amplitude reflectivity of the s-component calculated by the algorithm optimization, and Rp_true is also the amplitude reflectivity of the s-component derived from the formula with the real values. (3) Set the dimension of the algorithm to 2, and use the improved hermit crab algorithm to optimize the Fresnel refractive index. The two values corresponding to the best_solution in the algorithm code represent the optimized 𝑛1 and 𝑛2 values. The fitness_value obtained after optimization is the optimal solution of the defined loss function when used as the test function. (4) Estimate the refractive indices of the media under three different refraction scenarios. The estimation results are shown in the Table3 below. Table 3. The result of HCOA-CS for estimating the refractive index of different media The type of medium. the true refractive index value the optimized value obtained by the algorithm the optimal solution of the loss function Air and Water Air:1 Water:1.33 Air:1.017 Water:1.353 7.120e-26 Glycerin and Alcohol Glycerin:1.47 Alcohol:1.36 Glycerin:1.477 Alcohol:1.367 6.0487e-17 Diamond and Water Diamond:2.42 Water:1.33 Diamond:2.435 Water:1.339 3.0965e-19 It can be seen that the results of the identification of Fresnel refractive index parameters estimated by the improved Crab Algorithm based on chaos theory are quite ideal, showing excellent performance, which proves that the improved Crab Algorithm based on chaos theory has a certain value in practical applications. It fully verifies the practicality and effectiveness of this algorithm in practical applications. 4. Conclusion This paper combines chaos theory and Crab Optimization Algorithm, proposing an improved Crab Algorithm based on chaos theory, which effectively solves the problem of the original algorithm easily falling into local optima. The improved Crab Algorithm based on chaos theory is applied to the problem of parameter identification of Fresnel refractive index, achieving good results. This improvement not only enhances the accuracy and efficiency of the algorithm but also expands its scope of application in practical applications. This optimization work not only verifies the effectiveness of chaos theory in the Crab Algorithm but also demonstrates the potential and value of the algorithm in solving complex optimization problems. We believe that with in-depth research, the improved Crab Algorithm based on chaos theory will play an important role in more fields, providing strong support for scientific research and technological innovation. And there are not many algorithms related to crabs at present, we believe that in the future, there will be more mature and excellent algorithms. References [1] Yu Yang, Zhang Jun, Wang Lei, et al. Optimized Strategy for Multi-source Data Relay Protection Setting Based on Improved Genetic Algorithm [J]. Electronic Design Engineering, 2024, 32(06): 81-85. DOI: 10.14022/j.issn1674-6236.2024.06.017. [2] Zhao Zhenbo, Ren Xuerong, Fu Qingkun. Vehicle Network Computing Unloading Based on Improved Whale Optimization Algorithm [J/OL]. Computer Systems & Applications, 1-11 [2024-03-21]. https://doi.org/10.15888/j.cnki.csa.009478. [3] Xing Yuhua, Wu Qi, & Wang Mingjun. Improved Sparrow Search Algorithm for DV-Hop Localization Optimization [J]. Microelectronics & Computer, 1-10. [4] Ren Jin, Li Yibo, & Min Chang. Wireless Sensor Network Coverage Optimization Based on Improved Particle Swarm Algorithm [J]. Radio Engineering, 1-8. [5] Guo, J., Zhou, G., Yan, K., Shi, B., Di, Y., & Sato, Y. (2023). A novel hermit crab optimization algorithm. Scientific Reports, 13, 9934. https://www.nature.com/articles/s41598-023-37129- 6. [6] Tong Liang, Yang Jie, Gan Xusheng, Shen Di, Yang Wenda, & Chen Daxiong. Multi-robot Conflict Resolution Simulation Based on Improved Chaos Ant Algorithm [J]. Journal of System Simulation, 1-11. doi: 10.16182/j.issn1004731x.joss.23-1117. [7] Yin Wenming & Li Hui. (2021). Improved Cuckoo Search Algorithm Based on Chaos Theory and Its Applications [J]. Journal of Mathematical Modeling and Application, (02), 25- 31. doi: 10.19943/j.2095-3070.jmmia.2021.02.03. [8] Yang Daoping, Ge Gengyu, & Xia Deyou. (2023). Traffic Light Duration Regulation Simulation Based on Chaos Genetic Algorithm [J]. Computer Simulation, (05), 192-196.