Optimisation test functions
EvoLP includes some test functions to benchmark your algorithms. Unless otherwise specified, every function is of the form $f(x)$.
Pseudo-Boolean functions
EvoLP.onemax — Function
The OneMax function returns the sum of the individual. For an individual of length $n$, maximum is achieved with $n$ ones.
\[\text{OneMax}(\boldsymbol{x}) = \sum_{i=1}^n x_i\]
EvoLP.leadingones — Function
The LeadingOnes function returns the number of uninterrupted ones from the start of the chromosome. The maximum is achieved with $n$ ones, but the landscape is a bit more difficult to traverse.
\[\text{LO}(\boldsymbol{x}) = \sum_{i=1}^n \prod_j^i x_j\]
EvoLP.peakedLO — Function
peakedLO(x; m = length(x) - 1)The PeakedLO function is a deceptive benchmark function, with a peak with fitness m (by default $m = n - 1$ at the start and leadingones otherwise. Originally introduced in Self-adaptation of Mutation Rates in Non-elitist Populations (Dang & Lehre, 2016).
\[\text{PeakedLO}(\mathbf{x}) = \begin{cases} & m & \text{if } x = 0^n \\ & \sum_{i=1}^n \prod_{j=1}^i x_j & \text{otherwise}. \end{cases}\]
EvoLP.jumpk — Function
jumpk(x; k=6)The JumpK function is a modification of the onemax function, with a valley of size $k$ right before the maximum. The only way for a hill climber to reach the maximum is with a perfect flip of $k$ bits, which is considered extremely difficult.
\[\text{JUMP}_k(x) = \begin{cases} \lVert{x}\rVert_1 & \quad \text{if } \lVert x \rVert_1 \in [0..n-k] \cup \{n\},\\ -\lVert x \rVert_1 & \quad \text{otherwise} \end{cases}\]
where $\lVert x \rVert_1 = \sum_{i=1}^n x_i$ is the number of 1-bits in $x \in \{0, 1\}^n$.
EvoLP.trailingzeros — Function
An inverse version of leadingones. TrailingZeros returns the length of the longest suffix that consists only of 0-bits. The optimum is achieved by an individual with $n$ zeros.
\[\text{TZ}(\boldsymbol{x}) = \sum_{i=1}^n \prod_{j=i}^n (1 - x_i)\]
EvoLP.triangle — Function
triangle(x, m, s)The triangular positive wave, or Triangle, is a synthetic test function introduced in Estimating the Number of Local Optima in Multimodal Pseudo-Boolean Functions: Validation via Landscapes of Triangles (Sánchez-Díaz & Mengshoel, 2024).
Triangle uses two parameters, m and s, which modify the number of optima in the search space. The fitness depends on the number of ones in a bitstring, $\boldsymbol{x}$ (an individual x):
\[\text{Triangle}(\boldsymbol{x}, m, s) = \begin{cases} g(\boldsymbol{x}), \; \text{ if } \; \left\lceil \frac{\Vert\boldsymbol{x}\Vert}{s} \right\rceil \mod 2 = 1 \\ m\left(\left\lceil \frac{\Vert\boldsymbol{x}\Vert}{s} \right\rceil \cdot s - \Vert\boldsymbol{x}\Vert\right) \; \text{otherwise} \end{cases}\]
where
\[g(\boldsymbol{x}) = \begin{cases} m \cdot s, \; \text{ if } \; \Vert\boldsymbol{x}\Vert \mod s = 0 \\ m (\Vert\boldsymbol{x}\Vert \mod s) \; \text{otherwise.} \end{cases} \]
EvoLP.twomax — Function
twomax(x)Two modal version of onemax function, where optima are at either full ones or full zeros.
\[\text{TwoMax}(\boldsymbol{x}) = \max\left\{\sum_{i=1}^n x_i, n-\sum_{i=1}^n x_i\right\}\]
EvoLP.zeromax — Function
An inverse version of onemax, where the optimum is achieved by an individual with $n$ zeros.
\[\text{ZeroMax}(\boldsymbol{x}) = n - \sum_{i=1}^n x_i\]
Continuous functions
Continuous functions implementations were taken from Kochenderfer, M.J. and Wheeler, T.A. (2019). Most of these can be visualised in Surjanovic, S. & Bingham, D. (2013).
EvoLP.ackley — Function
ackley(x; a=20, b=0.2, c=2π)Ackley's benchmark function. Global minimum is at the origin, with value of 0. Parameters are typically $a=20$, $b=0.2$, and $c=2\pi$.
\[f(x) = -a \exp\left(-b\sqrt{\frac{1}{d} \sum_{i=1}^d x_i^2}\right) - \exp\left(\frac{1}{d} \sum_{i=1}{d} \cos (cx_i) \right) + a + \exp(1)\]
EvoLP.booth — Function
The Booth function is a 2-dimensional quadratic function with global minimum $x^* = [1, 3]$ and optimal value $f(x^*) = 0$.
\[f(x) = (x_1 + 2x_2 - 7)^2 + (2 x_1 + x_2 - 5)^2\]
EvoLP.branin — Function
branin(x; a=1, b=5.1/(4π^2), c=5/π, r=6, s=10, t=1/(8π))The Branin (a.k.a. Branin-Hoo) function has six optional parameters, and features multiple global minima. Some of them are at $x^* = [-\pi, 12.275]$, $x^* = [\pi, 2.275]$, $x^* = [3\pi, 2.475]$ and $x^* = [5\pi, 12.875]$, with $f(x^*) \approx 0.397887$.
\[f(x) = a(x_2 - bx_1^2 + cx_1 - r)^2 + s(1 - t)\cos(x_1) + s\]
EvoLP.circle — Function
circle(x)The circle function is a multiobjective test function, given by
\[f(x) = \begin{bmatrix} 1 - r\cos(\theta) \\ 1 - r\sin(\theta) \end{bmatrix}\]
where $\theta=x_1$ and $r$ is obtained by
\[r = \frac{1}{2} + \frac{1}{2} \left(\frac{2x_2}{1+x_2^2}\right)\]
EvoLP.eggholder — Function
eggholder(x::Vector{T} where {T<:Real})A $d$-dimensional function which draws its name due to its highly rugged landscape. For the 2-dimensional version, the optimum $f(\boldsymbol{x}^*)\approx-959.64066$ with optimiser $\boldsymbol{x}^* = (512, 404.231805)$.
EvoLP.flower — Function
flower(x; a=1, b=1, c=4)The flower function is a two-dimensional test function with flower-like contour lines coming out from the origin. Typically, optional parameters are set at $a=1$, $b=1$ and $c=4$. The function is minimised near the origin, although it does not have a global minimum due to atan bein undefined at $[0, 0]$.
\[f(x) = a\lVert\mathbb{x}\rVert + b \sin(c\arctan(x_2, x_1))\]
EvoLP.michalewicz — Function
michalewicz(x; m=10)The Michalewicz function is a $d$-dimensional function with several steep valleys, where m controls the steepness. m is usually set at 10. For 2 dimensions, $x^* = [2.20, 1.57]$, with $f(x^*) = -1.8011$.
\[f(x) = -\sum_{i=1}^{d}\sin(x_i) \sin^{2m}\left(\frac{ix_i^2}{\pi}\right)\]
EvoLP.rana — Function
rana(x::Vector{T} where {T<:Real})A $d$-dimensional function which is highly rugged and symmetrical. For $d=2$, the global minimum $f(\boldsymbol{x}^*)\approx -511.73288$ with optimiser $\boldsymbol{x}^* = (-488.632577, 512)$.
EvoLP.rosenbrock — Function
rosenbrock(x; b=100)This is the $d$-dimensional Rosenbrock function. In previous releases, it was 2d only and had an additional keyword argument a.
Update your workflow accordingly.
The $d$-dimensional Rosenbrock banana benchmark function. With $b=100$, minimum is at $f([1, \dots, 1]) = 0$
\[f(x) = \sum_{i=1}^{d-1} \left[b(x_{i+1} - x_i^2)^2 + (x_i - 1)^2 \right]\]
EvoLP.wheeler — Function
wheeler(x, a=1.5)The Wheeler's ridge is a 2-d function with a single global minimum in a curved peak. With $a$ (by default at 1.5) $x^* = [1, 1.5]$, with $f(x^*) = -1$.
\[f(x) = - \exp(- (x_1 x_2 - a)^2 - (x_2 - a)^2 )\]