# Differential evolution

In evolutionary computation, differential evolution (DE) is a method that optimizes a problem by iteratively trying to improve a candidate solution with regard to a given measure of quality. Such methods are commonly known as metaheuristics as they make few or no assumptions about the problem being optimized and can search very large spaces of candidate solutions. However, metaheuristics such as DE do not guarantee an optimal solution is ever found.

DE is used for multidimensional real-valued functions but does not use the gradient of the problem being optimized, which means DE does not require the optimization problem to be differentiable, as is required by classic optimization methods such as gradient descent and quasi-newton methods. DE can therefore also be used on optimization problems that are not even continuous, are noisy, change over time, etc.

DE optimizes a problem by maintaining a population of candidate solutions and creating new candidate solutions by combining existing ones according to its simple formulae, and then keeping whichever candidate solution has the best score or fitness on the optimization problem at hand. In this way, the optimization problem is treated as a black box that merely provides a measure of quality given a candidate solution and the gradient is therefore not needed.

DE was introduced by Storn and Price in the 1990s. Books have been published on theoretical and practical aspects of using DE in parallel computing, multiobjective optimization, constrained optimization, and the books also contain surveys of application areas. Surveys on the multi-faceted research aspects of DE can be found in journal articles .

## Algorithm

A basic variant of the DE algorithm works by having a population of candidate solutions (called agents). These agents are moved around in the search-space by using simple mathematical formulae to combine the positions of existing agents from the population. If the new position of an agent is an improvement then it is accepted and forms part of the population, otherwise the new position is simply discarded. The process is repeated and by doing so it is hoped, but not guaranteed, that a satisfactory solution will eventually be discovered.

Formally, let $\displaystyle{ f: \mathbb{R}^n \to \mathbb{R} }$ be the fitness function which must be minimized (note that maximization can be performed by considering the function $\displaystyle{ h := -f }$ instead). The function takes a candidate solution as argument in the form of a vector of real numbers and produces a real number as output which indicates the fitness of the given candidate solution. The gradient of $\displaystyle{ f }$ is not known. The goal is to find a solution $\displaystyle{ \mathbf{m} }$ for which $\displaystyle{ f(\mathbf{m}) \leq f(\mathbf{p}) }$ for all $\displaystyle{ \mathbf{p} }$ in the search-space, which means that $\displaystyle{ \mathbf{m} }$ is the global minimum.

Let $\displaystyle{ \mathbf{x} \in \mathbb{R}^n }$ designate a candidate solution (agent) in the population. The basic DE algorithm can then be described as follows:

• Choose the parameters $\displaystyle{ \text{NP} \geq 4 }$, $\displaystyle{ \text{CR} \in [0,1] }$, and $\displaystyle{ F \in [0,2] }$.
• $\displaystyle{ \text{NP} }$ is the population size, i.e. the number of candidate agents or "parents"; a typical setting is 10$\displaystyle{ n }$.
• The parameter $\displaystyle{ \text{CR} \in [0,1] }$ is called the crossover probability and the parameter $\displaystyle{ F \in [0,2] }$ is called the differential weight. Typical settings are $\displaystyle{ CR = 0.9 }$ and $\displaystyle{ F = 0.8 }$.
• Optimization performance may be greatly impacted by these choices; see below.
• Initialize all agents $\displaystyle{ \mathbf{x} }$ with random positions in the search-space.
• Until a termination criterion is met (e.g. number of iterations performed, or adequate fitness reached), repeat the following:
• For each agent $\displaystyle{ \mathbf{x} }$ in the population do:
• Pick three agents $\displaystyle{ \mathbf{a},\mathbf{b} }$, and $\displaystyle{ \mathbf{c} }$ from the population at random, they must be distinct from each other as well as from agent $\displaystyle{ \mathbf{x} }$. ($\displaystyle{ \mathbf{a} }$ is called the "base" vector.)
• Pick a random index $\displaystyle{ R \in \{1, \ldots, n\} }$ where $\displaystyle{ n }$ is the dimensionality of the problem being optimized.
• Compute the agent's potentially new position $\displaystyle{ \mathbf{y} = [y_1, \ldots, y_n] }$ as follows:
• For each $\displaystyle{ i \in \{1,\ldots,n\} }$, pick a uniformly distributed random number $\displaystyle{ r_i \sim U(0,1) }$
• If $\displaystyle{ r_i \lt CR }$ or $\displaystyle{ i = R }$ then set $\displaystyle{ y_i = a_i + F \times (b_i-c_i) }$ otherwise set $\displaystyle{ y_i = x_i }$. (Index position $\displaystyle{ R }$ is replaced for certain.)
• If $\displaystyle{ f(\mathbf{y}) \leq f(\mathbf{x}) }$ then replace the agent $\displaystyle{ \mathbf{x} }$ in the population with the improved or equal candidate solution $\displaystyle{ \mathbf{y} }$.
• Pick the agent from the population that has the best fitness and return it as the best found candidate solution.

## Parameter selection Performance landscape showing how the basic DE performs in aggregate on the Sphere and Rosenbrock benchmark problems when varying the two DE parameters $\displaystyle{ \text{NP} }$ and $\displaystyle{ \text{F} }$, and keeping fixed $\displaystyle{ \text{CR} }$=0.9.

The choice of DE parameters $\displaystyle{ \text{NP} }$, $\displaystyle{ \text{CR} }$ and $\displaystyle{ F }$ can have a large impact on optimization performance. Selecting the DE parameters that yield good performance has therefore been the subject of much research. Rules of thumb for parameter selection were devised by Storn et al. and Liu and Lampinen. Mathematical convergence analysis regarding parameter selection was done by Zaharie.

## Variants

Variants of the DE algorithm are continually being developed in an effort to improve optimization performance. Many different schemes for performing crossover and mutation of agents are possible in the basic algorithm given above, see e.g.