MyNixOS website logo
Description

General-Purpose Optimisation with the Self-Organising Migrating Algorithm.

An R implementation of the Self-Organising Migrating Algorithm, a general-purpose, stochastic optimisation algorithm. The approach is similar to that of genetic algorithms, although it is based on the idea of a series of ``migrations'' by a fixed set of individuals, rather than the development of successive generations. It can be applied to any cost-minimisation problem with a bounded parameter space, and is robust to local minima.

CRAN version

General-purpose optimisation with SOMA

The soma package provides an R implementation of the Self-Organising Migrating Algorithm, a general-purpose, stochastic optimisation algorithm developed originally by Ivan Zelinka.

The algorithm's approach is similar to that of genetic algorithms, although it is based on the idea of a series of "migrations" by a fixed set of individuals, rather than the development of successive generations. It can be applied to any cost-minimisation problem with a bounded parameter space, and is robust to local minima. Further details of the algorithm, and implementations for other languages, can be found at the SOMA home page.

SOMA migration illustration

Usage

The soma() function provides the R interface to the SOMA algorithm. It is called with a function to minimise, information on the minimum and maximum bounds for each parameter, and an optional list of options. The cost function must take a numeric vector of parameters as its first argument, and return a numeric scalar representing the associated cost value.

As an example, consider the two-dimensional version of Rastrigin's function, which has many local minima, and a global minimum of zero at (0,0).

rastrigin <- function(a) 20 + a[1]^2 + a[2]^2 - 10*(cos(2*pi*a[1])+cos(2*pi*a[2]))

The function surface looks like this (image from Wikimedia Commons):

Rastrigin's function

We can attempt to find the global minimum with the call

library(soma)
r <- soma(rastrigin, bounds(min=c(-5.12,-5.12),max=c(5.12,5.12)))
## Starting SOMA optimisation
## Migration limit (20) reached - stopping
## Final leader is #2, with cost 0.000348

We can see in the informative output what the lowest cost function value found by the algorithm was on this run, and how it compares to the tru minimum of zero. The location in search space of the obtained minimum is

print(r$population[,r$leader])
## [1] -0.0008568434  0.0010108585

Finally, we can plot how the optimisation progressed, showing the best cost function value at each migration:

plot(r, log="y")

plot of chunk unnamed-chunk-5

Note that there is a monotonic decrease in the cost function value of the "leader"—the individual with the lowest value—throughout.

Options

The supported options for the default "All To One" search strategy are as follows. The defaults are as recommended in the reference below.

Option nameDescriptionDefault value
pathLengthThe distance towards the leader that individuals may migrate. A value of 1 corresponds to the leader's position itself, and values greater than one (recommended) allow for some overshoot.3
stepLengthThe granularity at which potential steps are evaluated. It is recommended that the pathLength not be a whole multiple of this value.0.11
perturbationChanceThe probability that individual parameters are changed on any given step.0.1
minAbsoluteSepThe smallest absolute difference between the maximum and minimum cost function values. If the difference falls below this minimum, the algorithm will terminate.0
minRelativeSepThe smallest relative difference between the maximum and minimum cost function values. If the difference falls below this minimum, the algorithm will terminate.0.001
nMigrationsThe maximum number of migrations to complete.20
populationSizeThe number of individuals in the population. It is recommended that this be somewhat larger than the number of parameters being optimised over, and it should not be less than 2.10

Two other strategies are also implemented in the package, with some differences in the options available. These can be found, along with further references, via the ?soma.options help page within R.

Reference

I. Zelinka (2004). SOMA - self-organizing migrating algorithm. In G.C. Onwubolu & B.V. Babu, eds, New optimization techniques in engineering. Volume 141 of "Studies in Fuzziness and Soft Computing", pp. 167-217. Springer.

Metadata

Version

1.2.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows