## 3 Iterative Search Algorithms
### Population-Based Algorithms
#### 3.3.4 Differential Evolution (DE)  
Differential evolution (DE) is another type of metaheuristic that we have considered including in our library. [PERSON] and [PERSON] in 1995 [46; 47] originally designed this PB metaheuristic for solving continuous optimization problems in 1995. The algorithm shares many similar features with GA, as it involves maintaining a population of candidate solutions, which are exposed to iterative selection and variation (also known as _recombination_). Nevertheless, DE differs substantially from GA in how the selection and the variation are performed. The parent selection is performed at random, meaning that all the chromosomes have an equal probability of being selected for mating, regardless of their fitness. The variation consists of two steps: mutation and crossover. Numerous different operators were proposed so far [48; 49]; however, in this release, we have considered including their original versions [46]. For each parent member (called the _target_ vector), the mutation creates a mutant based on the scaled difference between two randomly selected parents, added to a third (random) population member. The scaling factor \(F\), which controls the amplification of the differential variation, usually lies in \([0.4,\ 1]\) as reported in [50]. In binomial crossover, the type of crossover we have included in the library, the elementsof the resulting _mutant_ (called the _donor_) are exchanged, with probability \(C_{r}\), with the elements of one of the previously selected parents (called the _target_). That is, the crossover is performed on each of the \(D\) indexes of the donor with a probability \(C_{r}\) by exchanging its values with the target vector. The resulting vector, frequently called the _trial_ vector, is then compared with the respective target and the best solution passes to the next iteration.  
Following the above-presented rationale, we have conceptualized a class called _DifferentialEvolution_, a subclass of _PopulationBased_, characterized by the following instance attributes:  
* _pi_, _initializer_, _best_sol_, _pop_size_, _pop_, _mutator_, _seed_, and _device_ are inherited from the _PopulationBased;_
* _selector_ is an operator that selects parents for the sake of mutation;
* _crossover_: crossover operator.  
At this point, it becomes necessary to clarify some aspects of the nomenclature. Although, in the scope of the original nomenclature, _selection_ stands for the procedure that decides whether trial vectors should become members of the next generation, in this library, _selection_ represents the process of selecting parents for the sake of mutation. This process can be conducted at random, as in the original definition of DE, or can be a function of a solution's fitness. The _selection_, as understood by the DE, is implemented in a private method called _replacement_: it compares each trial vector with its respective target and returns the most fit solution.  
Figure 7 presents the main steps that the **solve** method of _DifferentialEvolution_ class implements.  
It is worth highlighting the high flexibility of the implementation: because of the parents' selection operator, the mutation and crossover functions are provided as parameters of DifferentialEvolution, and one can easily personalize this PB metaheuristic.  
Appendix B.6 demonstrates how to create an instance of _DifferentialEvolution_ and apply it in different problem solving.