## 3 Controller Design and Genetic Algorithm Optimization Approach
### Genetic Algorithm
Selecting this expression as the fitness function aims to choose control parameters with smaller voltage mutations during transient processes when operating conditions change, to better control the voltage stability of the DC bus;
3. **Selection**--Based on the fitness values, select some individuals as \"parents\", with the selection probability proportional to their fitness. In the selection operation, this paper adopts the elitism strategy. Elitism is a strategy that preserves the best individuals, passing the most excellent ones directly to the next generation in each population, ensuring the retention of excellent solutions [30]. This prevents the GA from losing the optimal solution during the optimization process. The individuals in the population are sorted from high to low based on the fitness values obtained in the previous step. The top few individuals with the highest fitness are selected as elite individuals and directly passed on to the next generation population;
4. **Crossover**--Perform crossover operations on the selected parent individuals to generate new individuals (offspring) in the hope of obtaining better characteristics. This paper uses a random discrete crossover algorithm called crossoverscattered. It ran  
Figure 7: The flowchart of the Genetic Algorithm. domly selects two parent individuals and randomly chooses some gene positions for crossover. Then, it exchanges the selected genes at those positions between the two parent individuals, resulting in two offspring individuals [31];
5. **Mutation**--Perform mutation operations on the offspring individuals, introducing random perturbations to maintain population diversity and explore new solution spaces [31]. This paper uses a uniform mutation algorithm called mutationuniform, which evaluates each gene in the individual based on the specified mutation probability. If the mutation probability requirement is met, the value of that gene is randomly perturbed within its range;
6. **Update Population**--Combine the generated offspring individuals with the parent individuals to form a new population;
7. **Termination Criteria**--Repeat the above steps until the predetermined termination criteria are met, such as reaching the maximum number of iterations or finding satisfactory solutions. ```
Input: DAB parameters  GA parameters  GA options  Output: the best control parameters of DAB // Initialize population using the \"initializePopulation\" function with population size \"options.populationSize\". 1 population = initializePopulation(options.populationSize, numVars, lb, ub) // Evaluate fitness for each individual in the population using the \"evaluateFitness\" function. 2 evaluateFitness(population) // Sort the population based on fitness values. 3 sortPopulationByFitness(population) // Iterate over each generation. 4 FOR generation = 1 TO options.numGenerations // Initialize a new population to store the next generation. 5 newPopulation = [] // Iterate over each individual. 6 FOR \(i\) = 1 TO options.populationSize // Select parents using the \"selectParent\" function from the current population. 7 parent1 = selectParent(population)
8 parent2 = selectParent(population) // Generate offspring through crossover and mutation using the \"crossover AndMutate\" function, based on parents' genes and within the bounds defined by \"lb\" and \"ub\". 9 child = crossoverAndMutate(parent1, parent2, lb, ub) // Append the offspring to the new population. 10 newPopulation.append(child)
11 END FOR // Update the population. 12 population = newPopulation // Reevaluate fitness and sort the population based on the updated fitness values. 13 evaluateFitness(population)
14 sortPopulationByFitness(population) // Retrieve the best individual. 15 bestIndividual = population [1]
16 END FOR
17 RETURN bestIndividual
```  
**Algorithm 1**Genetic Algorithm