Shuffled Complex Evolution (SCE-UA), a global optimizer for box constrained problems.
The method keeps a population of points sampled from the bounds. In every loop the population is sorted, divided into complexes and every complex is evolved independently by the competitive complex evolution: a few points are drawn from the complex, with a probability higher for better points, and the worst of them is replaced by a reflection or a contraction of the centroid of the others, or by a random point when both fail. Then the complexes are merged and shuffled again. The shuffling spreads the information found by every complex over the whole population. Optionally the number of complexes shrinks during the run, and the population is repaired when it collapses into a subspace (see the option :pca-recovery? of sceua).
The optimizer is a function of the objective and an options map, (sceua f opts). A call keeps its state to itself, so the function can be called from many threads.
The algorithm is described in Duan, Sorooshian and Gupta (1992), Effective and efficient global optimization for conceptual rainfall-runoff models, Water Resources Research 28(4), 1015-1031, and in Duan, Sorooshian and Gupta (1994), A shuffled complex evolution approach for effective and efficient global minimization, Journal of Optimization Theory and Applications 76(3), 501-521. The repair of a collapsed population follows the idea of Chu, Gao and Sorooshian (2010), Water Resources Research 46(9).
Functions:
sceua - the optimizer.Shuffled Complex Evolution (SCE-UA), a global optimizer for box constrained problems. The method keeps a population of points sampled from the bounds. In every loop the population is sorted, divided into complexes and every complex is evolved independently by the competitive complex evolution: a few points are drawn from the complex, with a probability higher for better points, and the worst of them is replaced by a reflection or a contraction of the centroid of the others, or by a random point when both fail. Then the complexes are merged and shuffled again. The shuffling spreads the information found by every complex over the whole population. Optionally the number of complexes shrinks during the run, and the population is repaired when it collapses into a subspace (see the option `:pca-recovery?` of [[sceua]]). The optimizer is a function of the objective and an options map, `(sceua f opts)`. A call keeps its state to itself, so the function can be called from many threads. The algorithm is described in Duan, Sorooshian and Gupta (1992), Effective and efficient global optimization for conceptual rainfall-runoff models, Water Resources Research 28(4), 1015-1031, and in Duan, Sorooshian and Gupta (1994), A shuffled complex evolution approach for effective and efficient global minimization, Journal of Optimization Theory and Applications 76(3), 501-521. The repair of a collapsed population follows the idea of Chu, Gao and Sorooshian (2010), Water Resources Research 46(9). Functions: - [[sceua]] - the optimizer.
(sceua f opts)Finds a minimum or a maximum of a function in a box with the Shuffled Complex Evolution method.
The method is stochastic: use :rng with a seeded generator for reproducible results. It needs many evaluations of the objective, so it fits cheap functions with many local extrema, or a problem where a derivative is not available.
Parameters:
f (function): the objective. It receives the point as one sequence of numbers (a double array which it must not change), or as separate arguments when :vector-arg? is false, and returns a number. NaN is treated as the worst value.opts (map):
:bounds (required) - sequence of [lo hi] pairs, one for each dimension ([lo hi] for one dimension). The bounds are finite and lo < hi, up to 1000 dimensions.:initial - a point within the bounds which joins the initial population, default: none.:goal - :minimize (default) or :maximize.:vector-arg? - how f receives the point, default: true.:complexes - number of complexes, default: 5.:complex-size - number of points in a complex, default: 2n+1 for n dimensions. The population has :complexes times :complex-size points.:subcomplex-size - number of points drawn from a complex in an evolution step, from 2 to :complex-size, default: n+1, but not more than :complex-size.:evolution-steps - number of evolution steps of a complex in one loop, default: :complex-size.:min-complexes - the number of complexes drops by one after every loop, with the worst points removed, down to this number. Default: :complexes, so the number of complexes stays constant.:stop-loops, :stop-improvement - the run ends when the best value, :stop-loops loops back, differs from the current one by not more than :stop-improvement relative to the current value (absolute near zero), defaults: 40 and 1.0e-5. A shorter patience stops runs on flat parts of the objective before the minimum is reached.:stop-range - the run ends when the range of the population is not greater than this fraction of the range of the bounds in every dimension, default: 1.0e-3. Every tenfold decrease makes the result about a hundred times more accurate and needs about 20% more evaluations.:max-evals - the maximum number of evaluations of f, default: 10000. Exceeding it throws ex-info.:max-iters - the maximum number of loops, default: 10000. The run ends and returns the best point found.:rng - random number generator (see fastmath.random/rng), default: a new JDKRandomGenerator. It draws the jitter of the initial population and the random choices of the evolution. A :mersenne generator, for example (r/rng :mersenne 1), draws numbers about 2.5 times faster than the default one, which pays off with a cheap objective. It is not thread safe, which does not matter with :parallel?, where every complex gets its own generator.:jitter - jitter of the sequence which samples the initial population, from 0.0 to 1.0, default: 0.25. See fastmath.random/jittered-sequence-generator.:parallel? - evolve the complexes in parallel, default: false. The function f has to be thread safe. Every complex gets its own generator created from :rng (see fastmath.random/child-rngs), so the result can differ from the sequential one, a generator made by fastmath.random/synced-rng gives children of the default type.:pca-recovery? - repair a population which collapsed into a subspace, default: false. When the best value did not improve in a loop, the covariance matrix of the population in the unit cube is decomposed. Some points are moved along the directions with almost no variance (eigenvalue below 1.0e-3 of the largest one) and evaluated. With the default sizes the population rarely collapses and the option changes little. It helped, with the cost of 4% to 25% more evaluations, when the population is small for the problem (for example :complexes 2 or 3 for ten and more dimensions).:stats? - return a map with additional information, default: false.Returns [point value], where point is a vector and value the value of f there, also when maximizing. With :stats? returns a map with:
:point, :value - the same,:evaluations - number of evaluations of f,:iterations - number of loops,:status - why the run ended: :converged-range, :converged-improvement or :max-iterations,:complexes - number of complexes in the last loop.The population is evaluated and the first loop is always done, so at least :complexes times :complex-size evaluations are made, and :max-evals below that number throws.
Throws ex-info for invalid bounds, options or :initial, and when :max-evals is exceeded.
See also fastmath.optimization/minimize, fastmath.optimization/scan-and-minimize, fastmath.optimization.acm/cmaes.
Finds a minimum or a maximum of a function in a box with the Shuffled Complex Evolution method. The method is stochastic: use `:rng` with a seeded generator for reproducible results. It needs many evaluations of the objective, so it fits cheap functions with many local extrema, or a problem where a derivative is not available. Parameters: - `f` (function): the objective. It receives the point as one sequence of numbers (a `double` array which it must not change), or as separate arguments when `:vector-arg?` is `false`, and returns a number. `NaN` is treated as the worst value. - `opts` (map): - `:bounds` (required) - sequence of `[lo hi]` pairs, one for each dimension (`[lo hi]` for one dimension). The bounds are finite and `lo < hi`, up to 1000 dimensions. - `:initial` - a point within the bounds which joins the initial population, default: none. - `:goal` - `:minimize` (default) or `:maximize`. - `:vector-arg?` - how `f` receives the point, default: `true`. - `:complexes` - number of complexes, default: `5`. - `:complex-size` - number of points in a complex, default: `2n+1` for `n` dimensions. The population has `:complexes` times `:complex-size` points. - `:subcomplex-size` - number of points drawn from a complex in an evolution step, from `2` to `:complex-size`, default: `n+1`, but not more than `:complex-size`. - `:evolution-steps` - number of evolution steps of a complex in one loop, default: `:complex-size`. - `:min-complexes` - the number of complexes drops by one after every loop, with the worst points removed, down to this number. Default: `:complexes`, so the number of complexes stays constant. - `:stop-loops`, `:stop-improvement` - the run ends when the best value, `:stop-loops` loops back, differs from the current one by not more than `:stop-improvement` relative to the current value (absolute near zero), defaults: `40` and `1.0e-5`. A shorter patience stops runs on flat parts of the objective before the minimum is reached. - `:stop-range` - the run ends when the range of the population is not greater than this fraction of the range of the bounds in every dimension, default: `1.0e-3`. Every tenfold decrease makes the result about a hundred times more accurate and needs about 20% more evaluations. - `:max-evals` - the maximum number of evaluations of `f`, default: `10000`. Exceeding it throws `ex-info`. - `:max-iters` - the maximum number of loops, default: `10000`. The run ends and returns the best point found. - `:rng` - random number generator (see [[fastmath.random/rng]]), default: a new `JDKRandomGenerator`. It draws the jitter of the initial population and the random choices of the evolution. A `:mersenne` generator, for example `(r/rng :mersenne 1)`, draws numbers about 2.5 times faster than the default one, which pays off with a cheap objective. It is not thread safe, which does not matter with `:parallel?`, where every complex gets its own generator. - `:jitter` - jitter of the sequence which samples the initial population, from `0.0` to `1.0`, default: `0.25`. See [[fastmath.random/jittered-sequence-generator]]. - `:parallel?` - evolve the complexes in parallel, default: `false`. The function `f` has to be thread safe. Every complex gets its own generator created from `:rng` (see [[fastmath.random/child-rngs]]), so the result can differ from the sequential one, a generator made by [[fastmath.random/synced-rng]] gives children of the default type. - `:pca-recovery?` - repair a population which collapsed into a subspace, default: `false`. When the best value did not improve in a loop, the covariance matrix of the population in the unit cube is decomposed. Some points are moved along the directions with almost no variance (eigenvalue below `1.0e-3` of the largest one) and evaluated. With the default sizes the population rarely collapses and the option changes little. It helped, with the cost of 4% to 25% more evaluations, when the population is small for the problem (for example `:complexes` 2 or 3 for ten and more dimensions). - `:stats?` - return a map with additional information, default: `false`. Returns `[point value]`, where `point` is a vector and `value` the value of `f` there, also when maximizing. With `:stats?` returns a map with: - `:point`, `:value` - the same, - `:evaluations` - number of evaluations of `f`, - `:iterations` - number of loops, - `:status` - why the run ended: `:converged-range`, `:converged-improvement` or `:max-iterations`, - `:complexes` - number of complexes in the last loop. The population is evaluated and the first loop is always done, so at least `:complexes` times `:complex-size` evaluations are made, and `:max-evals` below that number throws. Throws `ex-info` for invalid bounds, options or `:initial`, and when `:max-evals` is exceeded. See also [[fastmath.optimization/minimize]], [[fastmath.optimization/scan-and-minimize]], [[fastmath.optimization.acm/cmaes]].
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |