Parallelisation

Consensus-based optimisation is often used to tackle minimisation problems where f(x) is expensive to evaluate (for instance, parameter estimation in a partial differential equation model). Therefore, ConsensusBasedX.jl does not use parallelisation by default, as it assumes the implementation of f will be parallelised if possible.

However, you can enable parallelisation by passing the option parallelisation=:EnsembleParallelisation. With this option, ConsensusBasedX.jl will run each of the M particle ensembles in parallel, using multithreading.

Warning

Parallelisation leads to memory allocations which cannot be avoided, as there is overhead associated with distributing the tasks. If you activate parallelisation, and then run minimise in benchmark mode (see Performance and benchmarking), you will detect some allocations, and this is expected.

Full example
using ConsensusBasedX
f(x) = ConsensusBasedX.Ackley(x, shift = 1)
config = (; D = 2, M = 5, parallelisation = :EnsembleParallelisation)
minimise(f, config)