## 2 Method
### Magnetic Anomaly Inversion
#### 2.4.5 Implementation of the Inversion Algorithm  
In the above, we have discussed the objective function, adaptive regularization coefficient, mutation strategy based on a smooth vector of individual, and control parameters of adaptive DE. In this section, the adaptive DE algorithm for 2-D \(l_{p}\) norm magnetic anomaly inversion was systematically presented. The flowchart of the DE algorithm is shown in Figure 2. Its main content includes the following parts:  
1. Load the observation data, and generate the inversion grid according to the inversion area. Store the coefficient sparse matrix related to the control equation for the forward modeling calculation. Create model weighted vectors and store them. The geomagnetic parameters related to magnetic anomaly are known.
2. Population initialization of DE: Given the population size and the initial \(\mu_{CR}\) and \(\mu_{F}\), and the population vector is initialized by Algorithm 1. Smooth the vectors of the population and store them, and initialize the Regularization coefficient by Equation (26).
3. Mutation and crossover: The variation vector \(\mathbf{v}\) is generated by Equation (18), and the trial vector \(\mathbf{u}\) is generated by Equation (8).
4. Selection and update of DE control parameters: The smooth trial vector \(\mathbf{u}_{s}\) is evaluated. According to Equation (19), to determine whether to update the population \(\mathbf{m}\) and the individual vector in the population \(\mathbf{m}_{s}\). Update \(\mu_{CR}\) and \(\mu_{F}\) according to Equations (14) and (11).
5. Termination condition: Judge whether the termination condition is satisfied. If it is true, the current inversion result will be output; otherwise, turn to step (6).  
(6) Update the regularization coefficient. If the regularization coefficient changes, it is necessary to update the objective function value of the population under the new regularization coefficient and turn to step (3).  
The pseudo-code of the inversion Algorithm 2 is as follows:  
```
01: Data preprocessing. Read in the observation data, and generate the inversion grid and forward modeling sparse matrix, and then generate the weight vector \(W_{m}\) of the model
02: \(G=1\); \(NFES=0\)
03: Set \(NP=100\), \(\mu_{CR}=0.9\), \(\mu_{F}=0.9\), \(c=0.1\). The population initialization based on Algorithm 1: \(\mathbf{m}=(\mathbf{m}_{0,1},\cdots,\mathbf{m}_{0,NP})\). Generate smooth population \(\mathbf{m}_{s}\). Initialize the regularization coefficient \(\lambda^{0}\), \(NFES=NFES+NP\)
04: While termination conditions are not satisfied do
05: \(G=G+1\)
06: For\(i=1\) to \(NP\) do
07: \(CR_{i}^{G}=randn_{i}(\mu_{CR},0.1)\)
08: \(F_{i}^{G}=rand_{i}(\mu_{F},0.1)\)
09: End For
10: For\(i=1\) to \(NP\) do
11: Using the difference vector of smooth individuals, the mutation vector is generated according to the mutation strategy in Equation (18)
12: According to Equation (8), the trial vector \(\mathbf{u}_{i}^{G+1}\) is generated
13: End For
14: Evaluate the trial vector \(\mathbf{u}_{i}^{G+1}\)
15: According to Equation (19), the new populations \(\mathbf{m}^{G+1}\) and \(\mathbf{m}_{s}^{G+1}\) are formed.
16: Update \(\mu_{CR}\) and \(\mu_{F}\) by Equations (14) and (11)
17: The maximum number of estimates \(NFES=NFES+NP\)
18: End While
```  
**Algorithm 2**\(l_{p}\) Norm Inversion Algorithm of Magnetic Anomaly Based on Improved DE  
Figure 2: Flowchart of the differential evolution (DE) algorithm for the inversion of magnetic data.