--- id: pyswarms version: "1.3.0" license: MIT license license_treatment: permissive maintenance: dormant --- # pyswarms — A Python-based Particle Swarm Optimization (PSO) library. License: permissive · Maintenance: dormant · Downloads: 74.8K/mo ## What it is and what it does PySwarms is a research toolkit for particle swarm optimization (PSO) that provides ready-to-use implementations of PSO algorithms alongside utilities for hyperparameter tuning, visualization, and testing. It wraps scipy, numpy, and matplotlib to deliver a declarative interface where you define an objective function, configure swarm parameters, and run the optimizer to find minima or maxima across your problem space. The package targets researchers, students, and practitioners who want to apply PSO without building the algorithm from scratch. It includes built-in test functions, grid and random search tools for hyperparameter optimization, and plotting utilities to visualize cost histories and particle trajectories. The API is extensible, allowing researchers to implement custom PSO variants. Dependencies are standard scientific Python libraries (scipy, numpy, matplotlib, attrs, tqdm, pyyaml, future), making it straightforward to integrate into existing workflows. Use it for: - Solve unconstrained continuous optimization problems where gradient-free metaheuristic search is preferred over calculus-based methods. - Tune hyperparameters of a PSO optimizer using built-in grid or random search to find the best configuration for your objective function. - Visualize swarm behavior and cost convergence over iterations using the plotting module to understand optimizer performance and debug tuning choices. - Implement custom PSO variants or hybrid algorithms by extending the toolkit's base classes for research publications or specialized applications. - Benchmark PSO against other metaheuristics on standard test functions provided in the utils module. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. PySwarms implements particle swarm optimization (PSO) algorithms in Python, providing a high-level interface for solving optimization problems using swarm intelligence techniques. Yes, if you are doing research, education, or prototyping with particle swarm optimization. The low install friction, permissive MIT license, and extensible design make it a solid choice for PSO work. However, be aware that the package is dormant—the latest release is from 2021-01-03, so compatibility with very recent Python or dependency versions is uncertain. Not recommended for production systems requiring active maintenance and support. ## Install pip install pyswarms uv add pyswarms poetry add pyswarms ## Installing pyswarms Before you install: Low install friction with a pure-Python wheel distribution. Maintenance is dormant—the latest release was 2021-01-03, though the repository remains active with a recent commit on 2024-08-06 and 1393 stars. Suitable for research and educational use but not actively developed. License in practice: MIT license (permissive) places no restrictions on use, modification, or distribution. Safe for commercial and open-source projects alike. Quickstart: pip install pyswarms import pyswarms as ps from pyswarms.utils.functions import single_obj as fx options = {'c1': 0.5, 'c2': 0.3, 'w': 0.9} optimizer = ps.single.GlobalBestPSO(n_particles=10, dimensions=2, options=options) best_cost, best_pos = optimizer.optimize(fx.sphere, iters=100) Verify before relying: - Whether the package works reliably with Python versions beyond 3.7 (classifiers list only 3.6 and 3.7 explicitly) - Current compatibility with modern scipy and numpy versions given dormant maintenance status since 2021-01-03 ## Package facts - License: MIT license (permissive) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 74.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags particle swarm optimization, PSO algorithm implementation, swarm intelligence optimization, metaheuristic optimization library, hyperparameter optimization search, optimization algorithm toolkit, numerical optimization python, metaheuristic-optimization, research-toolkit, swarm-intelligence [View on SkillFed](https://skillfed.io/packages/pyswarms) · [View on PyPI](https://pypi.org/project/pyswarms/)