Shuffled Complex Evolution (SCE) optimisation. Designed to have a similar interface to the standard optim function.

SCEoptim(FUN, par, ..., lower = -Inf, upper = Inf, control = list())

Arguments

FUN

function to optimise (to minimise by default), or the name of one. This should return a scalar numeric value.

par

a numeric vector of initial parameter values.

...

further arguments passed to FUN.

lower, upper

lower and upper bounds on the parameters. Should be the same length as par, or length 1 if a bound applies to all parameters.

control

a list of options as in optim(), see Details.

Value

a list of class "SCEoptim".

par

optimal parameter set.

value

value of objective function at optimal point.

convergence

code, where 0 indicates successful covergence.

message

(non-)convergence message.

counts

number of function evaluations.

iterations

number of iterations of the CCE algorithm.

time

number of seconds taken.

POP.FIT.ALL

objective function values from each iteration in a matrix.

BESTMEM.ALL

best parameter set from each iteration in a matrix.

POP.ALL

if (control$returnpop = TRUE), the parameter sets from each iteration are returned in a three dimensional array.

control

the list of options settings in effect.

Details

This is an evolutionary algorithm combined with a simplex algorithm.

Options can be given in the list control, in the same way as with optim:

list("ncomplex")

number of complexes. Defaults to 5.

list("cce.iter")

number of iteration in inner loop (CCE algorithm). Defaults to NA, in which case it is taken as 2 * NDIM + 1, as recommended by Duan et al (1994).

list("fnscale")

function scaling factor (set to -1 for a maximisation problem). By default it is a minimisation problem.

list("elitism")

influences sampling of parents from each complex. Duan et al (1992) describe a 'trapezoidal' (i.e. linear weighting) scheme, which corresponds to elitism = 1. Higher values give more weight towards the better parameter sets. Defaults to 1.

list("initsample")

sampling scheme for initial values: "latin" (hypercube) or "random". Defaults to "latin".

list("reltol")

reltol is the convergence threshold: relative improvement factor required in an SCE iteration (in same sense as optim), and defaults to 1e-5.

tolsteps is the number of iterations where the improvement is within reltol required to confirm convergence. This defaults to 7.

,

reltol is the convergence threshold: relative improvement factor required in an SCE iteration (in same sense as optim), and defaults to 1e-5.

tolsteps is the number of iterations where the improvement is within reltol required to confirm convergence. This defaults to 7.

list("tolsteps")

reltol is the convergence threshold: relative improvement factor required in an SCE iteration (in same sense as optim), and defaults to 1e-5.

tolsteps is the number of iterations where the improvement is within reltol required to confirm convergence. This defaults to 7.

list("maxit")

maximum number of iterations. Defaults to 10000.

list("maxeval")

maximum number of function evaluations. Defaults to Inf.

list("maxtime")

maximum duration of optimization in seconds. Defaults to Inf.

list("returnpop")

whether to return populations (parameter sets) from all iterations. Defaults to FALSE.

list("trace")

an integer specifying the level of user feedback. Defaults to 0.

list("REPORT")

number of iterations between reports when trace >= 1. Defaults to 1.

References

Qingyun Duan, Soroosh Sorooshian and Vijai Gupta (1992). Effective and Efficient Global Optimization for Conceptual Rainfall-Runoff Models, Water Resources Research 28(4), pp. 1015-1031.

Qingyun Duan, Soroosh Sorooshian and Vijai Gupta (1994). Optimal use of the SCE-UA global optimization method for calibrating watershed models, Journal of Hydrology 158, pp. 265-284.

See also

optim, DEoptim package, rgenoud package

Author

Felix Andrews felix@nfrac.org

This was adapted, and substantially revised, from Brecht Donckels' MATLAB code, which was in turn adapted from Qingyun Duan's MATLAB code:

http://biomath.ugent.be/~brecht/downloads.html

Examples


## reproduced from help("optim")

## Rosenbrock Banana function
Rosenbrock <- function(x) {
  x1 <- x[1]
  x2 <- x[2]
  100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
# lower <- c(-10,-10)
# upper <- -lower
ans <- SCEoptim(Rosenbrock, c(-1.2, 1), control = list(trace = 1))
#>  Nr Iter  Nr Fun Eval    Current best function    Current worst function
#>      1        76                  12.7189               5.90572e+06
#>      2       130                0.0790716                   91938.6
#>      3       180                0.0790716                   11519.4
#>      4       238                0.0790716                   7756.29
#>      5       299                0.0790716                   4938.58
#>      6       357                0.0383434                   583.981
#>      7       411                0.0202285                   459.469
#>      8       463               0.00640054                   72.8587
#>      9       512              0.000512332                   13.8056
#>     10       567              0.000512332                   6.78692
#>     11       618              0.000289162                  0.359706
#>     12       671              2.64181e-05                  0.359706
#>     13       720              1.22006e-05                 0.0497167
#>     14       768              9.39611e-06                 0.0497167
#>     15       821              2.92256e-06                 0.0398932
#>     16       874              1.08368e-06                0.00634343
#>     17       928              7.97997e-07                0.00231506
#>     18       984              3.93934e-07                0.00231506
#>     19      1040              1.60248e-08                0.00231506
#>     20      1091              1.21385e-08               0.000466116
#>     21      1144              7.68396e-10               0.000466116
#>     22      1197              4.94091e-10               3.03208e-05
#>     23      1244              2.25976e-10               3.03208e-05
#>     24      1296              2.25976e-10                1.7887e-06
#>     25      1352              5.63513e-11                1.7887e-06
#>     26      1404              5.26145e-12                1.7887e-06
#>     27      1456              3.45141e-12               4.32406e-07
#>     28      1505              3.45141e-12               4.32406e-07
#>     29      1555              7.13553e-13               1.09271e-07
#>     30      1606              4.89783e-13               1.09271e-07
#>     31      1658              9.58268e-14               2.69055e-08
#> Change in solution over [tolsteps] less than specified tolerance (reltol).
str(ans)
#> List of 11
#>  $ call       : language SCEoptim(FUN = Rosenbrock, par = c(-1.2, 1), control = list(trace = 1))
#>  $ control    :List of 13
#>   ..$ ncomplex  : num 5
#>   ..$ cce.iter  : logi NA
#>   ..$ fnscale   : num 1
#>   ..$ elitism   : num 1
#>   ..$ initsample: chr "latin"
#>   ..$ reltol    : num 1e-05
#>   ..$ tolsteps  : num 7
#>   ..$ maxit     : num 10000
#>   ..$ maxeval   : num Inf
#>   ..$ maxtime   : num Inf
#>   ..$ returnpop : logi FALSE
#>   ..$ trace     : num 1
#>   ..$ REPORT    : num 1
#>  $ par        : num [1:2] 1 1
#>  $ value      : num 9.58e-14
#>  $ convergence: num 0
#>  $ message    : chr "Change in solution over [tolsteps] less than specified tolerance (reltol)."
#>  $ counts     : num 1658
#>  $ iterations : num 31
#>  $ time       : num 0.224
#>  $ POP.FIT.ALL: num [1:31, 1:25] 12.7189 0.0791 0.0791 0.0791 0.0791 ...
#>  $ BESTMEM.ALL: num [1:31, 1:2] -2.56 1.06 1.06 1.06 1.06 ...
#>  - attr(*, "class")= chr [1:2] "SCEoptim" "list"

## 'Wild' function, global minimum at about -15.81515
Wild <- function(x) {
  10 * sin(0.3 * x) * sin(1.3 * x^2) + 0.00001 * x^4 + 0.2 * x + 80
}
ans <- SCEoptim(Wild, 0,
  lower = -50, upper = 50,
  control = list(trace = 1)
)
#>  Nr Iter  Nr Fun Eval    Current best function    Current worst function
#>      1        60                  70.2357                   159.001
#>      2       104                  67.7087                   137.391
#>      3       154                  67.7087                   137.391
#>      4       196                  67.7087                   85.5385
#>      5       242                  67.7087                   85.5385
#>      6       288                  67.5218                   86.4444
#>      7       336                  67.5218                   87.4622
#>      8       374                  67.5218                    87.271
#>      9       422                  67.5218                   87.3583
#>     10       462                  67.5218                   86.3995
#>     11       502                  67.5218                    84.989
#>     12       542                  67.4761                   87.3014
#>     13       588                  67.4761                   87.4661
#>     14       628                  67.4761                   87.4661
#>     15       662                  67.4761                    87.244
#>     16       708                  67.4761                   87.4532
#>     17       742                  67.4761                   87.1166
#>     18       786                  67.4761                   87.1166
#> Change in solution over [tolsteps] less than specified tolerance (reltol).
ans$par
#> [1] -15.66244