# Towards a Digital Twin for Open-Frame Underwater Vehicles Using Evolutionary Algorithms
## 4 BlueROV2 Case
### Genetic Algorithm
As previously stated, the fitness function evaluated the performance of each candidate solution in the population. It quantified how well the solution matched the desired behavior or characteristics of the system being optimized. In our study, the fitness function was defined as the sum of absolute differences between the ground truth data and the simulated data for each parameter over time. The problem to solve is a multi-objective one. Even when considering each DOF as decoupled, there are multiple thruster speeds for each one. Specifically in this work, eight different thruster speeds were selected for each DOF. To find an optimal solution, the partial fitness functions for all these tests were combined, adding them into the final fitness function. A series of weights were applied in this process to improve the low-speed movements, as they were more interesting during the inspections. Crossover  
In the crossover stage, pairs of parent solutions were selected from the population based on their fitness values. These parent solutions underwent a crossover operation, where portions of their parameter values were exchanged to produce offspring solutions. The crossover operation introduces diversity into the population by combining beneficial traits from different parent solutions. In our implementation, we used a two-point crossover strategy with a probability of 0.5 to generate offspring, where two random points were selected along the parameter vectors, and the segments between these points were swapped between parents. Mutation  
Following the crossover, the offspring solutions underwent a mutation operation, which introduced small random changes to their parameter values. Mutation helps to explore new regions of parameter space and prevents premature convergence to suboptimal solutions. We applied a Gaussian mutation operator, where random Gaussian noise was added to each parameter value with a mutation probability of 0.25, introducing variability to avoid local optima. The magnitude of the mutation was controlled by the standard deviation parameter. Replacement  
The offspring replaced the previous population, and the optimization process continued for a predetermined number of generations or until a termination criterion was met. Common termination criteria include reaching a maximum number of generations, achieving a satisfactory level of fitness, or observing negligible improvement over successive generations. In our case, we established a maximum of 30 generations. Once the termination criterion was satisfied, the algorithm returned the fittest solution found during the optimization process. Table 4 summarizes all the relevant parameters and information related to the genetic algorithm. It is important to highlight that the novelty in our implementation lay in the custom initialization of the first generation using experimentally informed parameters, which biased the search toward realistic solutions. Additionally, multiple DOFs were optimized independently, and the fitness function combined the outcomes of multiple tests with a weighted approach to emphasize low-speed movement accuracy, an aspect critical in underwater inspection scenarios.