# Rapid Estimation of Earthquake Magnitude and Source Parameters Using Genetic Algorithms
## 2 Materials and Methods
### GAs
#### 2.2.2 Fitness Calculation  
The optimization problem in the source parameter estimation in this study is to find, for the four estimated variables, the optimal solutions that result in the minimum error value between the estimated displacement and the actual displacement. In other words, the closer the estimated displacement value is to the actual displacement value, the more optimal the model parameter estimation value is. Therefore, the objective function used  
Figure 2: Generic flowchart of a GA.  
in this study is the minimize function, and the minimized parameter is the error value between the estimated displacement and the actual displacement. The smaller the error value is, the more individuals that will be generated that will fit the optimal solution.  
Error value representations used in the objective functions in this study are the mean square error (mse), square error (se), and the number of elements in the displacement matrix with a specific error value. Two objective functions were tested in the experiment to find the optimal estimation as follows:  
\[e_{dis\_1}=\left(\sum\
olimits_{i=0}^{n}(dis_{est_{i}}-dis_{ref_{i}})^{2} \right)+n_{(e_{dis_{j}>1})}, \tag{3}\]  
\[e_{dis\_2}=\frac{1}{N}\cdot\left(\sum\
olimits_{i=0}^{n}(dis_{est_{i}}-dis_{ ref_{i}})^{2}\right)+\left(\sum\
olimits_{i=0}^{n}(dis_{est_{i}}-dis_{ ref_{i}})^{2}\right)+n_{(e_{dis_{j}>1})}, \tag{4}\]  
where \(e_{dis}\) is the displacement error between the estimated displacement and actual or referred displacement; \(dis_{est_{i}}\) is the estimated displacement result from element data \(i\); \(dis_{ref_{i}}\) represents the referenced displacement value for element data \(i\), \(N\) is the number of data points; and \(n_{(e_{dis_{j}>1})}\) represents the number of elements for which the displacement errors are >1.  
The estimated displacement (\(dist_{est}\)) is obtained from the forward calculation of Okada's model based on Equation (2) as follows:  
\[dist_{est}=Okada(E,N,depth, strike, dip,v_{1},v_{2},v_{3},v_{4}) \tag{5}\]  
where \(E\), \(N\), \(depth\), \(strike\), and \(dip\) are the predetermined parameters based on the earthquake's fault model used in the calculation as described previously, while \(v_{1},v_{2},v_{3},v_{4}\) are the estimated variables of the source parameter length, width, rake, and slip, respectively. GA generates the estimation values for the estimated variables. The more optimal the estimation value for the variables, the more minimal the displacement error value will be. In other words, the estimated displacement (\(dist_{est}\)) values are getting closer to the reference displacement (\(dist_{ref}\)) values.  
Both objective functions in Equations (3) and (4) include the square error between estimated displacement and actual displacement, and the number of elements in the displacement matrix for which the displacement errors are >1. However, the second objective function also includes the mean square error of the displacements. Hence, the second objective function attempts to capture the central value of the displacement errors, in addition to accumulating the error values. One of the objective functions will be selected as the recommended optimal function based on the experimental results.