Algorithms

EvoLP provides some basic built-in algorithms to get you started. All algorithms are built for minimisation.

Evolutionary Algorithms (EA)

The basic 1+1 EA starts with a vector individual and slowly finds its way to an optimum by only using mutation.

EvoLP.oneplusone — Function
oneplusone(f, ind, k_max, M)
oneplusone(logger::Logbook, f, ind, k_max, M)

1+1 Evolutionary Algorithm.

Arguments

  • f::Function: objective function to minimise.
  • ind::AbstractVector: individual to start the evolution.
  • k_max::Integer: number of iterations.
  • M::Mutator: one of the available Mutator.

Returns a Result.

source

Population-based extensions to the 1+1-EA include the comma selection and the plus selection variants.

EvoLP.mucommalambda! — Function
mucommalambda!(L, popset, f, μ, λ, M; kmax=1000, rng=Random.GLOBAL_RNG)
mucommalambda!(popset, f, μ, λ, M; kmax=1000, rng=Random.GLOBAL_RNG)

Execute an in-place (μ, λ)-Evolutionary Strategy.

In this comma-selection algorithm, a parent population of size μ generates an offspring pool of size λ through uniform selection and mutation. The survival phase selects the μ fittest individuals strictly from the newly generated offspring to form the next generation.

This function modifies popset and the logbook L in place.

Arguments:

  • L::Logbook: an EvoLP Logbook to record statistics per generation.
  • popset::AbstractVector: The initial population of μ individuals. Modified in place
  • f::Function: The objective function to minimise.
  • μ::Int: Parent population size.
  • λ::Int: Offspring population size. Must be λ ≥ μ.
  • M::EvoLP.Mutator: The mutation operator applied to generate offspring.

Keyword Arguments

  • kmax::Int: The maximum number of generations (iterations). Defaults to 1000.
  • rng::AbstractRNG: The random number generator for reproducibility.

Returns

  • A Result object containing the optimum, optimiser, and other execution statistics.
source
EvoLP.mupluslambda! — Function
mupluslambda!(L, popset, f, μ, λ, M; kmax=1000, rng=Random.GLOBAL_RNG)
mupluslambda!(popset, f, μ, λ, M; kmax=1000, rng=Random.GLOBAL_RNG)

Execute an in-place (μ + λ) Evolutionary Strategy.

In this plus-selection algorithm, a parent population of size μ generates an offspring pool of size λ. The survival phase selects the μ fittest individuals from the combined pool of both parents and offspring (size μ + λ), guaranteeing elitism.

This function modifies popset and the logbook L in place.

Arguments

  • L::Logbook: The logbook used to record fitness statistics per generation.
  • f::Function: The objective function to minimize.
  • popset::AbstractVector: The initial population of μ individuals. Modified in place.
  • μ::Int: The parent population size.
  • λ::Int: The offspring population size.
  • M::Mutator: The mutation operator applied to generate offspring.

Keyword Arguments

  • kmax::Int: The maximum number of generations (iterations). Defaults to 1000.
  • rng::AbstractRNG: The random number generator for reproducibility.

Returns

  • A Result object containing the optimum, optimiser, and execution statistics.
source

Genetic Algorithms (GA)

In a GA a population of vector solutions is simulated, where individuals get selected, recombined, and mutated. The built-in implementation in EvoLP is a generational GA taken from Kochenderfer, M.J. and Wheeler, T.A. 2019, which means the whole population is replaced by its offspring at every iteration.

EvoLP.GA — Function
GA(f, pop, k_max, S, C, M)
GA(logbook::Logbook, f, population, k_max, S, C, M)
GA(notebooks::Vector{Logbook}, f, population, k_max, S, C, M)

Generational Genetic Algorithm.

Arguments

  • f::Function: objective function to minimise.
  • population::AbstractVector: a list of vector individuals.
  • k_max::Integer: number of iterations.
  • S::ParentSelector: one of the available ParentSelector.
  • C::Recombinator: one of the available Recombinator.
  • M::Mutator: one of the available Mutator.

Returns a Result.

source

Particle Swarm Optimisation (PSO)

In PSO, individuals are particles with velocity and memory. At each iteration, a particle changes its velocity considering the neighbouring particles as well as the best position of the whole swarm.

The built-in implementation in EvoLP is taken from Kochenderfer, M.J. and Wheeler, T.A. 2019.

EvoLP.PSO — Function
PSO(f, population, k_max; w=1, c1=1, c2=1)
PSO(logger::Logbook, f, population, k_max; w=1, c1=1, c2=1)

Arguments

  • f::Function: Objective function to minimise.
  • population::Vector{Particle}: a list of Particle individuals.
  • k_max::Integer: number of iterations.

Keywords

  • w: inertia weight. Optional, by default 1.
  • c1: cognitive coefficient (own's position). Optional, by default 1.
  • c2: social coefficient (others' position). Optional, by default 1.

Returns a Result.

source