| soma | R Documentation | 
The Self-Organising Migrating Algorithm (SOMA) is 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.
soma(costFunction, bounds, options = list(), init = NULL, ...) bounds(min, max) ## S3 method for class 'soma' plot(x, y = NULL, add = FALSE, ...)
| costFunction | A cost function which takes a numeric vector of parameters as its first argument, and returns a numeric scalar representing the associated cost value. | 
| bounds | A list with elements  | 
| options | A list of options for the SOMA algorithm itself, usually
generated by functions like  | 
| init | An optional matrix giving the starting population's positions in parameter space, one per column. If omitted, initialisation is random (as is usual for SOMA), but specifying a starting state can be helpful when running the algorithm in stages or investigating the consistency of solutions. | 
| ... | Additional parameters to  | 
| min, max | Vectors of minimum and maximum bound values for each
parameter to the  | 
| x | An object of class  | 
| y | Ignored. | 
| add | If  | 
A list of class "soma", containing the following elements.
The index of the “leader”, the individual in the population with the lowest cost.
A matrix whose columns give the parameter values for each individual in the population at convergence.
A vector giving the cost function values for each individual at convergence.
A vector giving the cost of the leader for each migration during the optimisation. This should be nonincreasing.
The number of migrations completed.
The number of times the costFunction was
evaluated.
A plot method is available for this class, which shows the history
of leader cost values during the optimisation.
R implementation by Jon Clayden <code@clayden.org>.
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.
soma.options for setting options. optim
implements other general-purpose optimisation methods.
# Rastrigin's function, which contains many local minima rastrigin <- function (x) 10 * length(x) + sum(x^2 - 10 * cos(2*pi*x)) # Find the global minimum over the range -5 to 5 in each parameter x <- soma(rastrigin, bounds(c(-5,-5), c(5,5))) # Find the location of the leader - should be near the true minimum of c(0,0) print(x$population[,x$leader]) # Plot the cost history of the leaders plot(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.