autopso:基于 PyTorch 与 EvoX 的自动粒子群优化项目

Automated particle swarm optimization: an outer optimizer searches PSO component configurations while batched inner solvers tackle the target problem. Includes JAX and PyTorch implementations.

Branch1Tags0

EvoX Logo


🌟 AutoPSO: A Meta-Framework for Automated Particle Swarm Optimization 🌟

AutoPSO Paper AutoPSO on arXiv


PyTorch backend EvoX platform CEC2022 benchmark

AutoPSO is an online framework for automatically constructing PSO variants. Traditional PSO research has produced many useful mechanisms, such as different parameter schedules, exemplar choices, and swarm topologies. In practice, however, turning those mechanisms into a strong optimizer often still depends on manual trial-and-error: a researcher selects components, tunes coefficients, runs a benchmark, then repeats the process for the next problem.

AutoPSO turns this hand-crafted design loop into a black-box optimization problem. An outer PSO searches over a compact configuration space of PSO components, while many inner generalized PSO solvers are instantiated in parallel to solve the target problem and report feedback. With EvoX and PyTorch, those inner runs are tensorized and mapped naturally to modern GPUs, making it practical to adapt PSO designs online under a fixed wall-clock budget.

AutoPSO dynamically maps adaptive PSO modules to an exemplar pool

Method

AutoPSO framework

Each outer particle encodes one candidate PSO variant:

  • weight: the inertia coefficient shared by two update policies.
  • k1, k2, k3, k4: acceleration coefficients for the two policies.
  • type1, type2, type3, type4: exemplar choices selected from a nine-candidate pool.
  • percent: the population split ratio for two sub-swarms.

The inner solver is a generalized PSO. At every step, it partitions the swarm into two groups, assigns each group a different update policy, and selects exemplars from a shared pool including current position, personal best, global best, population center, random individuals, random personal bests, random elites, and newly sampled candidates.

Main Result

CEC2022 20D convergence curves

The paper evaluates AutoPSO against six classical PSO variants on CEC2022 under equal wall-clock time. For 20D functions, each run is limited to 120 seconds and reported curves are averaged over 31 independent runs. The main CEC2022 setting implemented in this repository uses:

outer optimizer: PSO
outer population: 100
inner optimizer: AutoPSO / generalized PSO
inner population: 100
inner iterations per outer evaluation: 800
time budget: 60s for CEC2022 10D, 120s for CEC2022 20D

Reproduction note: the paper reports wall-clock experiments on an RTX 3090 GPU. If PyTorch is running on CPU, the same 120-second budget will perform far fewer outer iterations and the results may be noticeably worse. Check your backend with python -c "import torch; print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU')".

Repository Layout

assets/                         Logos and paper figures used by the README
examples/pytorch/example_cec2022.py  PyTorch CEC2022 example entry point
scripts/summarize_json_results.py Result summarizer for JSON outputs
src/autopso/                     AutoPSO package source
show_env.py                      Environment and dependency checker

Installation

The GitLab main branch contains source version 0.1.0, with both JAX and PyTorch implementations. The CEC2022 commands below use the PyTorch runner. Use Python 3.10 or newer for this runner (its source uses modern type annotations).

git clone --branch main https://gitlab.com/emi-lab/autopso.git
cd autopso

Create a separate Python environment, then install the checkout:

python -m pip install -e ".[pytorch]"

The package metadata also installs EvoX, JAX and NumPy. The PyTorch runner uses the repository's TorchAutoPSO and TorchOuterPSO implementations; its CEC2022 problem uses evox.core.Problem when available and falls back to torch.nn.Module.

For GPU execution, first install a CUDA-enabled PyTorch build appropriate for your driver using the PyTorch installation guide, then install this checkout as above. Check the selected device safely on either CPU-only or GPU hosts:

python show_env.py
python -c "import torch; print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU')"

Quick Start

Start with a small CPU smoke test:

python examples/pytorch/example_cec2022.py --dims 10 --functions 1 --runs 1 --outer-iter 2 --outer-popsize 4 --inner-popsize 8 --inner-iter 3 --max-time 30 --device cpu --output outputs/smoke

This only checks that the runner works; it does not reproduce the paper results. For the full CEC2022 experiment:

python examples/pytorch/example_cec2022.py \
  --dims 20 \
  --functions 1 2 3 4 5 6 7 8 9 10 11 12 \
  --runs 31 \
  --max-time 120 \
  --device cuda \
  --output outputs/cec2022_20d_31runs_pytorch

Summarize results:

python scripts/summarize_json_results.py outputs/cec2022_20d_31runs_pytorch/autopso_cec2022_20D.json

The runner prints progress during each run. Use --progress-interval 1 for more frequent updates, or --progress-interval 0 to disable progress output.

The PyTorch runner uses the AutoPSO encoding and CEC2022 data packaged in this repository. Its CEC2022 problem class follows the EvoX PyTorch Problem style when evox.core.Problem is available, with a torch.nn.Module fallback otherwise.

The repository also retains a JAX runner in examples/jax/example_cec2022.py. The JAX and PyTorch implementations have separate APIs; do not interchange their imports.

Citation

If you use this code, please cite the corresponding paper:

@article{yu2026autopso,
  title   = {AutoPSO: A Meta-Framework for Automated Particle Swarm Optimization},
  author  = {Yu, Xinmeng and Gao, Jiaxin and Zhang, Jianguo and Jiang, Dongmei and Cheng, Ran},
  journal = {IEEE Transactions on Evolutionary Computation},
  year    = {2026},
  doi     = {10.1109/TEVC.2026.3718908}
}

Acknowledgements

AutoPSO is implemented with the EvoX framework for vectorized evolutionary computation and hardware acceleration.

Introduction

Automated particle swarm optimization: an outer optimizer searches PSO component configurations while batched inner solvers tackle the target problem. Includes JAX and PyTorch implementations.

Customize your domain