% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sceua.R
\name{sceua}
\alias{sceua}
\title{Minimize a function with SCE-UA}
\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{
\item{fn}{Function to minimize. Must accept a single numeric vector of
parameters and return a scalar numeric value.}

\item{lower}{Numeric vector of lower bounds. Must have the same length as
\code{upper}.}

\item{upper}{Numeric vector of upper bounds. Must have the same length as
\code{lower}.}

\item{initial}{Optional initial parameter vector. If provided, it is
included in the initial population.}

\item{max_evaluations}{Maximum number of function evaluations.}

\item{kstop}{Number of shuffling loops over which the objective value must
change by \code{pcento} before convergence.}

\item{pcento}{Objective convergence threshold.}

\item{complexes}{Number of complexes in the initial population.}

\item{points_per_complex}{Number of points in each complex. Defaults to
\code{2 * n + 1} where \code{n} is the number of parameters.}

\item{simplex_size}{Number of points in each sub-complex. Defaults to
\code{n + 1}.}

\item{evolution_steps}{Number of evolution steps allowed for each complex
before shuffling. Defaults to \code{points_per_complex}.}

\item{min_complexes}{Minimum number of complexes required. Defaults to
\code{complexes}.}

\item{parameter_epsilon}{Parameter convergence threshold.}

\item{...}{Additional arguments passed to \code{fn}.}
}
\value{
An object of class \code{sceua}: a list with components:
\itemize{
\item \code{par}: best parameter vector.
\item \code{value}: objective value at \code{par}.
\item \code{counts}: number of function evaluations.
\item \code{iterations}: number of shuffling loops.
\item \code{termination}: reason for termination.
\item \code{history}: a \code{data.frame} with one row per shuffling loop.
}
}
\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).
}
\details{
The R wrapper draws the internal SCE-UA seed from R's global random number
generator. Call \code{set.seed()} before \code{sceua()} for reproducible results.
}
\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
}
\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.
}
