Differential Evolution (DE) was developed by R. Storn and K. Price in 1995 [Storn95] [Storn97].
This algorithm has been made for continuous problems.
FOREACH generation
$\quad$ FOREACH individual $i$ (a solution vector) of the population (a set)
$\quad\quad$ 1. MUTATION:
$\quad\quad\quad$ 1.1 Randomly choose 3 different individuals $\boldsymbol{x}_{r1}$, $\boldsymbol{x}_{r2}$ and $\boldsymbol{x}_{r3}$
$\quad\quad\quad\quad$ $\boldsymbol{x}_{r2}$ and $\boldsymbol{x}_{r3}$ are used to automatically define the direction and the amplitude of the mutation
$\quad\quad\quad\quad$ (i.e. the search amplitude and direction)
$\quad\quad\quad$ 1.2 Compute mutant $\boldsymbol{v}_{i} \leftarrow \boldsymbol{x}_{r1} + F . (\boldsymbol{x}_{r2} - \boldsymbol{x}_{r3})$
$\quad\quad$ 2. CROSSOVER:
$\quad\quad\quad$ Compute the "test" individual $\boldsymbol{u}_{i}$ randomly taking each of its (vector) components in either $\boldsymbol{x}_i$ or $\boldsymbol{v}_i$
$\quad\quad$ 3. SELECTION:
$\quad\quad\quad$ The test individual $\boldsymbol{u}_{i}$ replace $\boldsymbol{x}_{i}$ in the next generation if it has a better score.
Notations:
Algorithm's parameters: $N$, $Cr$ and $F$
Input:
for all generation $t = 1, \dots, T$ do
$\quad$ for all individuals $i = 1, \dots, N$ do
$\quad\quad$ 1. Mutation:
$\quad\quad\quad$ Randomly choose 3 different individuals $\boldsymbol{x}_{r1,t}$, $\boldsymbol{x}_{r2,t}$ and $\boldsymbol{x}_{r3,t}$ in the population
$\quad\quad\quad$ Make a donor vector $\boldsymbol{v}_{i,t}$ as the following
$\quad\quad\quad \boldsymbol{v}_{i,t} \leftarrow \boldsymbol{x}_{r1,t} + F (\boldsymbol{x}_{r2,t} - \boldsymbol{x}_{r3,t})$
$\quad\quad$ 2. Crossover: make a test individual $\boldsymbol{u}_{i,t}$ from $\boldsymbol{x}_{i,t}$ and $\boldsymbol{v}_{i,t}$
$\quad\quad\quad$ Randomly choose a dimension index $d_{r,i}$.
$\quad\quad\quad$ for all dimension $d = 1, \dots, D$ do
$$ u_{d,i,t} \leftarrow \left\{ \begin{align} v_{d,i,t} \quad & \text{ if } \mathcal{B}(Cr) = 1 \text{ or if } d = d_{r,i}\\ x_{d,i,t} \quad & \text{ otherwise.} \end{align} \right. $$$\quad\quad\quad\quad$ where $\mathcal{B}(Cr)$ is a Bernoulli random variable of parameter $Cr$
$\quad\quad\quad\quad$ and where $u_{d,i,t}$, $v_{d,i,t}$ and $x_{d,i,t}$ are respectively the $d^{th}$ component of $\boldsymbol{u}_{i,t}$, $\boldsymbol{v}_{i,t}$ and $\boldsymbol{x}_{i,t}$
$\quad\quad$ 3. Selection:
$\quad\quad\quad$ If $f(\boldsymbol{u}_{i,t}) < f(\boldsymbol{x}_{i,t})$
$\quad\quad\quad\quad \boldsymbol{x}_{i,t+1} \leftarrow \boldsymbol{u}_{i,t}$
$\quad\quad\quad$ Else
$\quad\quad\quad\quad \boldsymbol{x}_{i,t+1} \leftarrow \boldsymbol{x}_{i,t}$
$\quad$ end for
end for
In [ ]:
# import python packages here...