This solver is an implementation of the slime mould algorithm. It belongs to the family of swarm-intelligence solvers. The method doesn't require first or second order derivatives. The original paper on the algorithm is called: " Slime mould algorithm: A new method for stochastic optmimization "
each Objective function passed to SlimeMoldOptim has to comply with the following simple parameter convention f( x; kwargs ) where f is the objective function to be minimized. This convention ensures SlimeMoldOptim can be used with time-series-problems, classification-problems, regression-problems. Univariate as well as multivariate target sets are admissible.
SlimeMoldOptim uses several cores, to make best use of your sytem, set Threads.nthreads() to the max. number.
using SlimeMoldOptim
using Test
Easom(x;kwargs) = -cos( x[1] ) * cos( x[2] ) *
exp( -( (x[1]-π)^2 + (x[2]-π)^2 ) )
lower = [ -10.0f0, -10.0f0 ];
upper = [ 10.0f0, 10.0f0 ];
sma( objFunction ) = slimeMoldAlgo( 30, 1000, ();
lower = lower,
upper = upper,
objFunction = objFunction,
maxiter = 1000,
ϵ_conv = 1f-20,
z = 0.03f0 )
solutionFWA = sma( Easom );
@test isapprox( solutionFWA.x_b[1], π; atol=0.01 )
@test isapprox( solutionFWA.x_b[2], π; atol=0.01 )
#
SlimeMoldOptim.slimeMoldAlgo
— Function.
slimeMoldAlgo( nMolds::Int,
n_vc::Int,
kwargs...;
lower::Vector{Float32},
upper::Vector{Float32},
objFunction::Function,
maxiter::Int,
ϵ_conv::Float32,
z::Float32=0.03f0 )
minimize objective function objFunction, the solution space is limited by lower and upper bound.
- The optimization algorithm utilized is the slime mold algorithm.
- The nMolds parameter governs the number of molds being modeled.
- n_vc is the number of steps learning parameter vb needs to reach 0.0.
- maxiter denotes the overall number of algo iteraions, it has to be >= n_vc.
the number of sparks per firework, in remains constant foreach firework.
- ϵ_A is the smoothing parameter controlling the variance of amplitudes computed foreach fw.
- C_a ist the upscaling parameter for explosion amplitudes.
- C_r is the downscaling parameter for explosion amplitudes.
- maxiter is the maximum number iteraions.
- ϵ_conv denotes the convergence parameter.
SlimeMolds struct
Parameter | Description | Type |
---|---|---|
S | each column denotes a mold position | Matrix{Float32} |
fitnessS | fitness of each mold | Vector{Float32} |
xbglobal | best found solution | Vector{ Float32 } |
minFGlobal | best found function value | Float32 |
xwglobal | worst found solution | Vector{ Float32 } |
maxFGlobal | worst found function value | Float32 |
iter | number of iterations executed | Int |