Shuffled Complex Evolution in MATLAB
Implement Shuffled Complex Evolution in MATLAB with ranked complexes, competitive local search, periodic shuffling, and a Sphere test problem.

On this page
Shuffled Complex Evolution (SCE-UA) is a metaheuristic for global optimization, proposed by Duan, Sorooshian and Gupta in 1992 (paper (opens in a new tab)). The abbreviation SCE is used for other methods in science, so “UA” was added because the creators were members of the University of Arizona. The method was first developed to calibrate conceptual rainfall and runoff models in hydrology.
How SCE-UA works
SCE-UA divides the population into sub-populations called complexes. At every iteration, an internal optimization mechanism called Competitive Complex Evolution (CCE) evolves each complex. After a CCE cycle on all complexes, they are combined to recreate the main population. The population is then partitioned again into new complexes, which shuffles the population and the complexes.
The Shuffled Frog Leaping Algorithm is a closely related metaheuristic and shares many properties with SCE-UA.
Forming the complexes
All members are sorted from best to worst and dealt to the complexes in turn: member 1 goes to complex 1, member 2 to complex 2, and so on. In this way, every complex holds both good and poor solutions.
Competitive Complex Evolution
CCE works like a few steps of the Nelder-Mead simplex method on a small random subset of the complex. In each CCE step:
- Choose parents from the complex at random, with a higher probability for better members. For a complex of size sorted from best () to worst, the code uses the probability .
- Sort the parents, and compute the centroid of all parents except the worst one, .
- Reflection. Try . If is outside the bounds, a random point in the smallest box that contains the complex is used instead. If is better than , it replaces .
- Contraction. Otherwise, try . If it is better, it replaces .
- Random point. Otherwise, replace with a random point in the smallest box that contains the complex.
The new parents go back into the complex, and the step repeats.
MATLAB implementation
This post shares an open-source, structured MATLAB implementation of SCE-UA. If you know MATLAB, you should find the code easy to use in your research projects.
The SCE-UA folder holds these files:
sce.m: the main script, with the problem definition, the parameters and the main loop.RunCCE.m: one CCE run on a complex.Sphere.m: the sample cost function, .SortPopulation.m,RandSample.mandIsInRange.m: helpers for sorting, weighted random selection and the bound check.main.m: a one line entry point that runssce.m.
To run the code, open the SCE-UA folder in MATLAB and run main.m. The program prints the best cost in every iteration and plots the best cost against the iteration on a logarithmic scale. The code uses unifrnd and randsample, functions of the Statistics and Machine Learning Toolbox, so it probably needs that toolbox.
Parameters in the code
| Parameter | Meaning | Value |
|---|---|---|
nVar |
Number of decision variables | 10 |
VarMin, VarMax |
Bounds of the variables | , |
MaxIt |
Maximum number of iterations | 500 |
nPopComplex |
Complex size | max(10, nVar+1), so 11 |
nComplex |
Number of complexes | 5 |
cce_params.q |
Number of parents in each CCE step | max(round(0.5*nPopComplex), 2) |
cce_params.alpha |
Number of offspring per selection | 3 |
cce_params.beta |
Number of CCE iterations per complex | 5 |
The complex size is at least nVar+1, the number of points of a simplex in nVar dimensions. To solve your own problem, write a cost function that takes a row vector and returns a number, and set CostFunction, nVar, VarMin and VarMax at the top of sce.m.
Check the result
The supplied Sphere problem has its minimum at the origin with cost 0. Inspect the best point as well as the cost curve, and compare repeated runs. Review complex size and the number of parents together when changing the dimension, since the local step builds a centroid from the selected parents. An outer iteration includes several local evaluations in each complex, so use evaluation counts for fair comparisons with other optimizers.
Downloads
How to cite
If you use this code or tutorial in your work, articles or publications, please cite it.
Mostapha Kalami Heris, Shuffled Complex Evolution in MATLAB (YPEA110), Yarpiz, 2015. https://yarpiz.com/shuffled-complex-evolution-ypea110@misc{yarpiz-ypea110,
author = {{Mostapha Kalami Heris}},
title = {{Shuffled Complex Evolution in MATLAB}},
howpublished = {Yarpiz},
year = {2015},
note = {Code YPEA110},
url = {https://yarpiz.com/shuffled-complex-evolution-ypea110}
}Published Updated
Comments