Skip to main content

SCE-UA: Shuffle Complex Evolution Algorithm for Optimization

PyPi Conda Version CodeCov Python Versions Downloads

CodeFactor Ruff pre-commit Binder CodSpeed Badge

SCE-UA is a lightweight Python package implementing the Shuffled Complex Evolution (SCE-UA) algorithm for global optimization. Designed primarily for hydrological model calibration, it leverages NumPy and SciPy for efficient computation and seamless integration into Python workflows.

Full documentation is available at cheginit.github.io/sceua.

🌟 Features

This implementation of the SCE-UA algorithm incorporates several major improvements from the literature over the original 1994 version. These enhancements include:

  • Adaptive smoothing parameter (θ) that adjusts based on problem scale, improving numerical stability and convergence.
  • Latin Hypercube Sampling (LHS) for initial population generation, ensuring better parameter space coverage compared to uniform random sampling.
  • PCA-based recovery mechanism to detect and restore lost dimensions in the population.
  • Best solution inclusion in every complex to accelerate convergence.
  • Optimized complex evolution strategy with enhanced reflection, contraction, and mutation operations.
  • Automatic parameter determination with sensible defaults based on problem dimensionality.
  • Scale-free stopping rules: a run ends when neither the best value nor the population median improves for a number of iterations, when every parameter's range shrinks below a fraction of its bounds, or at an iteration or evaluation budget.

Additionally, the package offers:

  • Multithreading support for parallel objective function evaluations using threading.
  • Detailed results object providing in-depth insights into the optimization process suitable for further analysis and visualization.
  • Type hinting and modern Python implementation, ensuring maintainability and adherence to best coding practices.

📦 Installation

Choose your preferred installation method:

Using pip

pip install sceua
micromamba install -c conda-forge sceua

Alternatively, you can use conda or mamba.

🚀 Quick Start Guide

The SCE-UA package has one main function called minimize, which is used to optimize a given objective function. The API follows a similar pattern to scipy.optimize.minimize for easy adoption.

Key Parameters

The most important tuning parameters are n_complexes and n_points_complex for all cases, while pca_freq and pca_tol are particularly relevant for problems with highly correlated parameters and/or high dimensionality. Default values are set to reasonable standards, but you can adjust them as needed for your specific problem.

For more details, refer to the API reference.

Example Usage

The signature for the objective function can be either:

def objective(params: FloatArray) -> float:
    """Objective function to minimize."""
    # Your implementation here

or

def objective(params: FloatArray, *args: Any) -> float:
    """Objective function to minimize."""
    # Your implementation here

where params is a NumPy array of parameters to optimize, and args is a tuple of additional arguments to pass to the objective function. The function should return a single floating-point value representing the objective function value.

Here's a simple example of how to use the package:

from typing import Any
import numpy as np
from numpy.typing import NDArray

import sceua

FloatArray = NDArray[np.floating[Any]]


def objective(params: FloatArray, *args: Any) -> float:
    """Objective function to minimize."""
    sim_arg1, sim_arg2, obs = args
    sim = simulation_func(params, sim_arg1, sim_arg2)
    return metric_func(sim, obs)


# Define parameter bounds as a sequence of (min, max) pairs
bounds = [(lower1, upper1), (lower2, upper2), ..., (lowerN, upperN)]

# Run optimization
result = sceua.minimize(objective, bounds, args=(sim_arg1, sim_arg2, obs), seed=42, max_workers=8)

# Access the optimization results
best_params = result.x
best_function_value = result.fun
num_iterations = result.nit
num_function_evaluations = result.nfev

Result Object

The result object contains the following attributes:

  • x (numpy.ndarray): Best parameters found.
  • fun (float): Best function value corresponding to the best parameters.
  • nit (int): Number of iterations.
  • nfev (int): Number of function evaluations.
  • message (str): Message describing the termination reason.
  • success (bool): Whether the optimization was successful.
  • xv (numpy.ndarray): All evaluated parameter sets.
  • funv (numpy.ndarray): Function values for all evaluated parameter sets.

Visualization

The result attributes can be used to create convergence plots and analyze optimization performance:

import matplotlib.pyplot as plt


_, ax1 = plt.subplots()
ax1.plot(np.minimum.accumulate(results.funv))
ax2 = ax1.twinx()
ax2.set_yscale("log")
ax2.plot(np.cumsum(results.funv - true_min), color="r")

Convergence

Check the docs for more examples and API details.

📚 References

This package is based on the following references:

  • Duan, Q., Sorooshian, S., & Gupta, V. K. (1992). Effective and efficient global optimization for conceptual rainfall-runoff models. Water Resources Research, 28(4), 1015-1031. doi:10.1029/91WR02985
  • Duan, Q., Gupta, V. K., & Sorooshian, S. (1994). Optimal use of the SCE-UA global optimization method for calibrating watershed models. Journal of Hydrology, 158(3-4), 265-284. doi:10.1016/0022-1694(94)90057-4
  • Duan, Q., Sorooshian, S., & Gupta, V. K. (1994). A shuffled complex evolution approach for effective and efficient global minimization. Journal of optimization theory and applications, 76(3), 501-521. doi:10.1007/BF00939380
  • Muttil, N., & Jayawardena, A. W. (2008). Shuffled Complex Evolution model calibrating algorithm: enhancing its robustness and efficiency. Hydrological Processes, 22(23), 4628-4638. Portico. doi:10.1002/hyp.7082
  • Chu, W., Gao, X., & Sorooshian, S. (2010). Improving the shuffled complex evolution scheme for optimization of complex nonlinear hydrological systems: Application to the calibration of the Sacramento soil-moisture accounting model. Water Resources Research, 46(9). Portico. doi:10.1029/2010wr009224

Additionally, some ideas were inspired by UQPyL and SAMBO Python packages.

🤝 Contributing

We welcome contributions! Please see the contributing section for guidelines and instructions.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for sceua 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sceua 0.2.0
File Size Uploaded Provenance Actions
sceua-0.2.0.tar.gz 453.0 kB With provenance Details for sceua-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sceua 0.2.0
File Interpreter ABI Platform Actions
sceua-0.2.0-py3-none-any.whl Python 3 none any Details for sceua-0.2.0-py3-none-any.whl

Total release size: 465.7 kB

Release files / sceua-0.2.0.tar.gz

Download URL sceua-0.2.0.tar.gz
Size 453.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d2cda78b6dfd2c0722dfdb0da42831184d37ef79a5087a0e05bdd97253350a4b
BLAKE2b-256 checksum
How to use checksums
c0bf0e45cea02da7b4dbb7e2562bf6babef5bae5d3395ce796832969f7b3a86a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / sceua-0.2.0-py3-none-any.whl

Download URL sceua-0.2.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56a25fa99a91218a733d714ef8a87e15f8c6a30c24eada14c48dd9c346c771d8
BLAKE2b-256 checksum
How to use checksums
7998f68bc9304ded2c3b79ec9832b9ab49659a37b18016b657bfe4599bc243c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for sceua 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sceua-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page