FUNCTION REFERENCE
particleswarm
Find a global minimum with particle swarm optimization.
Find a global minimum with particle swarm optimization.
Syntax
[x, fval, exitflag, output] = particleswarm(fun, nvars, lb, ub, options)fun receives a 1-by-nvars row. A stochastic method: rng(seed) before the call
makes a run repeatable (it draws from the rand stream).
Algorithm: Kennedy & Eberhart (1995) particle swarm with an inertia weight
(Shi & Eberhart 1998) adapted between 0.1 and 1.1 by a stall counter: an
improving iteration lowers the counter and doubles the inertia while the
counter is below 2; above 5 the inertia is halved. The social term uses the best particle
of a random neighbourhood that grows by a quarter of the swarm after each
iteration without improvement. Self and social weights 1.49. SwarmSize
min(100, 10*nvars). Initial positions are uniform within the bounds, or a span
of 2000 where a bound is infinite; positions are clamped to the bounds (the
velocity component is set to 0). Stops with exitflag 1 when the best value
changes less than FunctionTolerance (1e-6, relative to max(1,|f|)) over
MaxStallIterations (20) iterations; exitflag 0 after MaxIterations
(200*nvars) or MaxFunctionEvaluations. output has iterations, funccount and
message. Differences from MATLAB: swarms and results differ for the same seed
(different internals); no hybrid, output or plot functions.
Example
rng(1); [x,f]=particleswarm(@(x)sum((x-[1 2]).^2),2,[-5 -5],[5 5])These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.