Stopping criteria
You can apply any of these criteria by passing them as keywords to the minimise
routine.
Energy threshold
energy_threshold::Real = -Inf
sets a stopping threshold for the value of f(v)
, where v
is the current consensus point. For each ensemble, if f(v) < energy_threshold
, the minimisation stops.
Full example
using ConsensusBasedX
f(x) = ConsensusBasedX.Ackley(x, shift = 1)
config = (; D = 2, energy_threshold = 1e-2)
minimise(f, config) # should be close to [1, 1]
Energy tolerance
energy_tolerance::Real = 1e-8
dictates a tolerance for the change in f(v)
, where v
is the current consensus point. For each ensemble, if abs(f(v) - f(v_prev)) < energy_tolerance
, where v_prev
is the previous consensus point, the minimisation stops.
Full example
using ConsensusBasedX
f(x) = ConsensusBasedX.Ackley(x, shift = 1)
config = (; D = 2, energy_tolerance = 1e-4)
minimise(f, config) # should be close to [1, 1]
Max evaluations
max_evaluations::Real = Inf
determines the maximum number of times f
may be evaluated by the minimisation. If the value is exceeded, the minimisation stops.
Full example
using ConsensusBasedX
f(x) = ConsensusBasedX.Ackley(x, shift = 1)
config = (; D = 2, max_evaluations = 1000)
minimise(f, config) # should be close to [1, 1]
Max iterations
max_iterations::Real = 1000
specifies the maximal number of iterations that the time integrator can perform. If the number is reached, the minimisation stops.
Full example
using ConsensusBasedX
f(x) = ConsensusBasedX.Ackley(x, shift = 1)
config = (; D = 2, max_iterations = 80)
minimise(f, config) # should be close to [1, 1]
Max time
max_time::Real = Inf
determines the maximal solution time (the corresponding SDE is solved from time 0
until time max_time
). If the number of iterations times Δt
surpasses this value, the minimisation stops.
Full example
using ConsensusBasedX
f(x) = ConsensusBasedX.Ackley(x, shift = 1)
config = (; D = 2, max_time = 5)
minimise(f, config) # should be close to [1, 1]