ConsensusBasedX.ConsensusBasedOptimisation
— TypeConsensusBasedOptimisation
Fields:
f
, the objective function.correction<:CBXCorrection
, a correction term.noise<:Noises
, a noise mode.α::Float64
, the exponential weight parameter.λ::Float64
, the drift strengh.σ::Float64
, the noise strengh.
ConsensusBasedX.ConsensusBasedOptimisationCache
— TypeConsensusBasedOptimisationCache{T}
It is strongly recommended that you do not construct ConsensusBasedOptimisationCache
by hand. Instead, use ConsensusBasedX.construct_method_cache
.
Fields:
consensus::Vector{Vector{T}}
, the consensus point of each ensemble.consensus_energy::Vector{T}
, the energy (value of the objective function) of each consensus point.consensus_energy_previous::Vector{T}
, the previous energy.distance::Vector{Vector{T}}
, the distance of each particle to the consensus point.energy::Vector{Vector{T}}
, the energy of each particle.exponents::Vector{Vector{T}}
, an exponent used to computelogsums
.logsums::Vector{T}
, a normalisation factor forweights
.weights::Vector{Vector{T}}
, the exponential weight of each particle.energy_threshold::Float64
, the energy threshold.energy_tolerance::Float64
, the energy tolerance.max_evaluations::Float64
, the maximum number off
evaluations.evaluations::Vector{Int}
, the current number off
evaluations.
ConsensusBasedX.ConsensusBasedSampling
— TypeConsensusBasedSampling
Fields:
f
, the objective function.root<:Roots
, a mode for the square toor of the covariance.α::Float64
, the exponential weight parameter.λ::Float64
, the mode parameter.λ = 1 / (1 + α)
corresponds toCBS_mode = :sampling
, andλ = 1
corresponds toCBS_mode = :minimise
.
ConsensusBasedX.ConsensusBasedSamplingCache
— TypeConsensusBasedSamplingCache{T}
It is strongly recommended that you do not construct ConsensusBasedSamplingCache
by hand. Instead, use ConsensusBasedX.construct_method_cache
.
Fields:
consensus::Vector{Vector{T}}
, the consensus point of each ensemble.consensus_energy::Vector{T}
, the energy (value of the objective function) of each consensus point.consensus_energy_previous::Vector{T}
, the previous energy.energy::Vector{Vector{T}}
, the energy of each particle.exponents::Vector{Vector{T}}
, an exponent used to computelogsums
.logsums::Vector{T}
, a normalisation factor forweights
.noise::Vector{Vector{T}}
, a vector to contain the noise of one iteration.root_covariance::Vector{Matrix{T}}
, the matrix square root of the weighted covariance of the particles.weights::Vector{Vector{T}}
, the exponential weight of each particle.energy_threshold::Float64
, the energy threshold.energy_tolerance::Float64
, the energy tolerance.max_evaluations::Float64
, the maximum number off
evaluations.evaluations::Vector{Int}
, the current number off
evaluations.exp_minus_Δt::Float64
, the time-stepping parameter.noise_factor::Float64
, the noise multiplier.
ConsensusBasedX.ParticleDynamic
— TypeParticleDynamic
Fields:
method<:CBXMethod
, the optimisation method.Δt::Float64
, the time step.
ConsensusBasedX.ParticleDynamicCache
— TypeParticleDynamicCache
It is strongly recommended that you do not construct ParticleDynamicCache
by hand. Instead, use ConsensusBasedX.construct_particle_dynamic_cache
.
Fields:
mode
should be set toParticleMode
.parallelisation<:Parallelisations
, the parallelisation mode.method_cache<:CBXMethodCache
, a cache for themethod
field ofParticleDynamic
.D::Int
, the dimension of the problem.N::Int
, the number of particles per ensemble.M::Int
, the number of ensembles.X
, the particle array.dX
, the time derivative array.Δt::Float64
, the time step.root_Δt::Float64
, the square root of the time step.root_2Δt::Float64
, the square root of twice the time step.max_iterations::Float64
, the maximum number of iterations.max_time::Float64
, the maximal time.iteration::Vector{Int}
, the vector containing the iteration count per ensemble.
ConsensusBasedX.Ackley
— MethodAckley(x::AbstractVector; a = 20, b = 0.2, c = 2π, shift = 0)
The Ackley function in dimension D = length(x)
with global minimum at the point $x = (\textrm{shift}, \textrm{shift}, \cdots, \textrm{shift})$:
\[f(x) = a \left[ 1 - \exp \left( -b \sqrt{ \frac{1}{D} \sum_{d=1}^{D} (x_d - \textrm{shift})^2 } \right) \right] + \left[ \exp(1) - \exp \left( \frac{1}{D} \sum_{d=1}^{D} \cos( c (x_d - \textrm{shift}) ) \right) \right] .\]
See also the Wikipedia article.
ConsensusBasedX.Quadratic
— MethodQuadratic(x::AbstractVector; shift = 0)
A quadratic function in dimension D = length(x)
with global minimum at the point $x = (\textrm{shift}, \textrm{shift}, \cdots, \textrm{shift})$:
\[f(x) = \frac{1}{D} \sum_{d=1}^{D} (x_d - \textrm{shift})^2 .\]
ConsensusBasedX.Rastrigin
— MethodRastrigin(x::AbstractVector; a = 10, c = 2π, shift = 0)
The Rastrigin function in dimension D = length(x)
with global minimum at the point $x = (\textrm{shift}, \textrm{shift}, \cdots, \textrm{shift})$:
\[f(x) = \frac{1}{D} \sum_{d=1}^{D} (x_d - \textrm{shift})^2 + a \left( 1 - \frac{1}{D} \sum_{d=1}^{D} \cos( c (x_d - \textrm{shift}) ) \right) .\]
See also the Wikipedia article.
ConsensusBasedX.construct_method_cache
— Functionconstruct_method_cache(
config::NamedTuple,
X₀::AbstractArray,
method::CBXMethod,
particle_dynamic::ParticleDynamic,
)
A constructor helper for CBXMethodCache
.
ConsensusBasedX.construct_particle_dynamic_cache
— Functionconstruct_particle_dynamic_cache(
config::NamedTuple,
X₀::AbstractArray,
particle_dynamic::ParticleDynamic,
)
A constructor helper for ParticleDynamicCache
. Calls ConsensusBasedX.construct_method_cache
to construct the corresponding CBXMethodCache
.
ConsensusBasedX.maximise
— Methodmaximise(f; keywords...)
maximise(f, config::NamedTuple)
Maximise the function f
using Consensus-Based Optimisation.
Attempts to define x -> -f(x)
and calls the minimise
routine. This might be better handled directly by the user (see Maximisation).
See also minimise
.
ConsensusBasedX.minimise
— Methodminimise(f; keywords...)
minimise(f, config::NamedTuple)
Minimise the function f
using Consensus-Based Optimisation (see Function minimisation).
You must specify the dimension D
of the problem. Other parameters (e.g. the number of particles N
or the number of ensembles M
) can also be specified; see Summary of options.
Examples
minimise(f, D = 2)
config = (; D = 2);
minimise(f, config)
minimise(f, D = 2, N = 20)
config = (; D = 2, N = 20);
minimise(f, config)
ConsensusBasedX.sample
— Methodsample(f; keywords...)
sample(f, config::NamedTuple)
Sample the distribution exp(-αf)
using Consensus-Based Sampling (see Distribution sampling).
You must specify the dimension D
of the problem. Other paramters (e.g. the number of particles N
or the number of ensembles M
) can also be specified; see Summary of options.
Examples
out = sample(f, D = 2, extended_output = true);
out.sample
config = (; D = 2, extended_output = true);
out = sample(f, config);
out.sample
out = sample(f, D = 2, N = 20, extended_output = true);
out.sample
config = (; D = 2, N = 20, extended_output = true);
out = sample(f, config);
out.sample