## 2 The Quick Preliminary Design Model
### The Genetic Algorithm  
In the genetic algorithm (GA) used here, one single individual is defined by the values of the 13 variables and 8 constraints listed in Table 2. They are collected in a population matrix, A, where each column represents one individual [33]. These values are coded as binary numbers to facilitate the calculation process. DMFC-AUV\QpDM allows establishing the upper and lower limits of each variable and the number of bits that defines it, i.e., its resolution. The larger the number of bits of a variable, the more precisely it can be defined and the more values that can be evaluated. However, the calculation time soars and the convergence to a solution is more difficult. The goal of the GA is to find a configuration that maximizes or minimizes a merit function (MF). A merit function, also known as a figure-of-merit function, is a function that measures the agreement between data and the fitting model for a particular choice of the parameters [47]. The solution that provides the best result is considered the best solution. In this case, the MF is equal to the endurance of the vehicle, \(e\), multiplied by three binary functions that depend on the strength of the pressure hulls, the volume margin of the central pressure hull, and the mass margin of the whole AUV. The best design will be the individual that maximizes the value of the MF, that is, the AUV with the longer endurance, the pressure hulls of which can withstand the design operating depth and the arrangement of which complies with the defined volume and mass margins. The MF can be written as  
\[MF=K\cdot V\cdot M\cdot e \tag{10}\]  
where  
\[K= \begin{cases}1,&\text{if all the pressure hulls}\\ &\text{withstand the design depth}\\ 0,&\text{otherwise}\end{cases}  \tag{11}\]\[V= \begin{cases}1,&\text{if }MrgVol\geq MrgVol_{0}\\ 0,&\text{otherwise}\end{cases}  \tag{12}\]  
\[M= \begin{cases}1,&\text{if }MrgMass\geq MrgMass_{0}\\ 0,&\text{otherwise}\end{cases}  \tag{13}\]  
DMFC-AUV\QpDM seeks the vehicle with the higher endurance and discards the designs whose pressure hulls are not suitable for the design navigation depth or do not have sufficient volume or mass margin. The GA is characterized by three parameters, the population size, \(N\), the number of generations, _ngens_, and the mutation rate, \(r\)[33]. These parameters must be carefully adjusted to allow the GA to find solutions efficiently. In this regard, \(N\) must be sufficiently large to assure a proper population diversity, but large values will lead to long calculation times and a high use of memory. A small value of _ngens_ saves calculation time, but a small value will make it difficult for the GA to achieve the best result due to the lack of evolution of the population. Finally, a correct value of \(r\) will prevent convergence to local solutions, but the opposite is the impossibility of the GA to converge. Figure 7 depicts how the GA achieves the solution. First of all, the initial population matrix, A, is randomly set defining \(N\) individuals whose variable values are coded in binary format. Next, these values are decoded into real numbers, and each design is evaluated in accordance with the aforementioned algorithm (see Figure 1) and MF. The subsequent step is the crossover of the individuals, that is, the random exchange of genes between two individuals to produce a new individual (offspring). To select which individual will be crossed with another, their merit values are arranged in a toroidal matrix M and the merit values of the neighbors, immediately above, below, on the left and on the right, are compared to each other. The selected candidate will be the individual with the highest value. The new individuals are stored in a new population matrix B. To maintain the diversity of the population, once the crossover stage is complete, \(r\%\) of the genes of the population B are randomly changed, and the merit matrix of this population is calculated.