# Dynamic Compensation of a Fluxgate Magnetometer Based on a Hybrid Optimizing Algorithm
## 2 Materials and Methods
### GA-SA Hybrid Optimization Algorithm  
GA is an optimization algorithm established by Professor [PERSON] of the University of Michigan and influenced by Darwinian evolution [23; 24]. By simulating the process of biological heredity, biological individuals can be selected and eliminated according to the rule of \"survival of the fittest\" in biological heredity. Finally, the best individual is obtained. However, in the process of population evolution, variation is only a small probability event. The population has limited ability to explore new solution space, which can easily to fall into the local optimal and be unable to obtain the global optimal solution. SA is an optimization algorithm proposed by Professor [PERSON] with reference to the Metropolis criterion, based on the recognition of the similarities of combinatorial optimization and solid annealing [25]. The simulated annealing algorithm simulates the annealing process of a solid substance in physics and randomly searches for the global optimal solution of the objective function in the solution space by combining probabilistic jump characteristics. However, in order to obtain the optimal solution to the problem, a relatively high initial temperature is generally set during initialization, and a relatively slow  
Figure 8: Block diagram of the dynamic compensator. cooling rate and a relatively low-end temperature are set during de-warming, resulting in a long execution time of the algorithm. Moreover, the simulated annealing algorithm keeps only one possible solution in the iterative process, which creates a lack of historical information storage and fault tolerance. Considering the respective problems of the above two algorithms, this paper combines the two algorithms for hybrid optimization and proposes the hybrid optimization strategy of the genetic algorithm-simulated annealing algorithm (GA-SA): the defect of GA falling into the local optimum can be avoided by utilizing the probabilistic jump of SA, which changes time and tends to zero in the search process. In the evolutionary process of GA, the population is large and diverse, and the cross mutation can further increase the diversity of the population and solve the shortcomings of the SA iterative process of lack of historical information and fault tolerance [24; 25]. Finally, the full-space search capability of the hybrid algorithm can be improved to ensure that the output solution is globally optimal to the greatest extent. Therefore, the objective function in Equation (5) is taken as the fitness function of the GA-SA algorithm and is iteratively updated to solve parameters in the dynamic compensator. The algorithm flow is shown in Figure 9.  
Figure 9: Flowchart of the GA-SA hybrid optimization algorithm. The specific steps of the algorithm are as follows:  
1. Initialization: the simulation process of biological evolution. For this problem, each feasible solution (Parameter \(Ai\)) is represented as an individual, and different individuals constitute the population, which is the set of feasible solutions for the current problem, expressed as:  
\[A=\left\{\,A_{1},A_{2},\cdots,A_{n}\right\} \tag{6}\]  
where \(n\) represents the population size, namely, the number of individuals in the population. According to experience, in the initialization process, set the population size \(n=100\); that is, generate 100 possible solutions randomly (Parameter \(A\), where the value range is [\(-10\), 10]). Generate the initial population and set the crossover probability \(pc=0.7\), the variation probability \(pm=0.05\), the initial temperature \(T0=100\)\({}^{\circ}\)C, the maximum number of iterations \(tmax=5000\), the threshold value \(th=0.001\), and the annealing temperature attenuation parameter \(\alpha=0.85\). 2. Calculation of the fitness function:  
Equation (5) is utilized to calculate the fitness function \(f_{i}\) of each \(Ai\) in the population, and the optimal fitness \(f_{opt}\) of individuals in the population is obtained. 3.