Package {sceua}


Title: Shuffled Complex Evolution Algorithm for Optimization
Version: 0.1.0
Description: Provides an 'R' interface to a 'Rust' implementation of the Shuffled Complex Evolution - University of Arizona (SCE-UA) global optimization algorithm (Duan et al., 1992). SCE-UA combines simplex search, competitive evolution, and complex shuffling to solve nonlinear, non-convex, continuous parameter estimation problems. The method is commonly used for calibrating hydrological and environmental models and follows the algorithm proposed by Duan et al. (1992) <doi:10.1029/91WR02985>.
License: MIT + file LICENSE
URL: https://github.com/atsyplenkov/sceua/, https://atsyplenkov.github.io/sceua/
BugReports: https://github.com/atsyplenkov/sceua/issues/
Encoding: UTF-8
Language: en
Config/rextendr/version: 0.3.1.9001
Config/build/bootstrap: TRUE
Config/Needs/website: altdoc, quarto, bench, rtop, SoilHyP, knitr, rmarkdown, rextendr, tomledit
SystemRequirements: Cargo (Rust's package manager), rustc (>= 1.91.1)
Imports: checkmate
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0
NeedsCompilation: yes
Packaged: 2026-06-22 07:43:44 UTC; ats
Author: Anatoly Tsyplenkov ORCID iD [aut, cre, cph]
Maintainer: Anatoly Tsyplenkov <atsyplenkov@fastmail.com>
Repository: CRAN
Date/Publication: 2026-06-26 09:20:08 UTC

Minimize a function with SCE-UA

Description

Find the parameter set that minimizes an objective function using the Shuffled Complex Evolution - University of Arizona (SCE-UA) algorithm (Duan et al., 1992).

Usage

sceua(
  fn,
  lower,
  upper,
  initial = NULL,
  max_evaluations = 10000L,
  kstop = 5L,
  pcento = 0.01,
  complexes = 2L,
  points_per_complex = NULL,
  simplex_size = NULL,
  evolution_steps = NULL,
  min_complexes = NULL,
  parameter_epsilon = 0.001,
  ...
)

Arguments

fn

Function to minimize. Must accept a single numeric vector of parameters and return a scalar numeric value.

lower

Numeric vector of lower bounds. Must have the same length as upper.

upper

Numeric vector of upper bounds. Must have the same length as lower.

initial

Optional initial parameter vector. If provided, it is included in the initial population.

max_evaluations

Maximum number of function evaluations.

kstop

Number of shuffling loops over which the objective value must change by pcento before convergence.

pcento

Objective convergence threshold.

complexes

Number of complexes in the initial population.

points_per_complex

Number of points in each complex. Defaults to 2 * n + 1 where n is the number of parameters.

simplex_size

Number of points in each sub-complex. Defaults to n + 1.

evolution_steps

Number of evolution steps allowed for each complex before shuffling. Defaults to points_per_complex.

min_complexes

Minimum number of complexes required. Defaults to complexes.

parameter_epsilon

Parameter convergence threshold.

...

Additional arguments passed to fn.

Details

The R wrapper draws the internal SCE-UA seed from R's global random number generator. Call set.seed() before sceua() for reproducible results.

Value

An object of class sceua: a list with components:

References

Duan, Q., Sorooshian, S., and Gupta, V.K., 1992. Effective and efficient global optimization for conceptual rainfall-runoff models. Water Resour. Res. 28 (4), 1015-1031.

Examples

set.seed(1234)
# Two-dimensional sphere
result <- sceua(
  fn = function(x) sum(x^2),
  lower = c(-5, -5),
  upper = c(5, 5),
  max_evaluations = 5000,
  kstop = 5,
  pcento = 1e-8,
  complexes = 5
)
result