MCPcopy Index your code
hub / github.com/eggzec/pyswarm

github.com/eggzec/pyswarm @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
41 symbols 129 edges 11 files 3 documented · 7% updated 18d agov1.0.0 · 2026-05-24★ 347
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

PySwarm

Particle Swarm Optimization (PSO) for Python

Tests Documentation Ruff

codecov Quality Gate Status License: BSD-3

PyPI Downloads Python versions

pyswarm is a gradient-free, evolutionary optimization library for Python that implements Particle Swarm Optimization (PSO) with built-in support for constraints. It is lightweight, easy to use, and suitable for a wide range of optimization problems where gradient information is unavailable or impractical to compute.

Quick example

from pyswarm import pso


def objective(x):
    x1, x2 = x
    return x1**4 - 2 * x2 * x1**2 + x2**2 + x1**2 - 2 * x1 + 5


lb = [-3, -1]
ub = [2, 6]

result = pso(objective, lb, ub)

print("Optimal solution:", result.x)  # → [1.0, 1.0]
print("Function value:", result.fun)  # → 4.0
print("Converged:", result.success)
print("Reason:", result.message)
print("Iterations:", result.nit)
print("Evaluations:", result.nfev)

pso returns an OptimizeResult — a dict subclass with attribute access, compatible with scipy.optimize.OptimizeResult.

Installation

pip install pyswarm

Requires Python 3.10+ and NumPy. See the full installation guide for uv, poetry, and source builds.

Documentation

License

BSD-3-Clause — see LICENSE.

Core symbols most depended-on inside this repo

pso
called by 12
pyswarm/__init__.py
run_command
called by 3
bin/build.py
install
called by 1
bin/build.py
wheel
called by 1
bin/build.py
clean
called by 1
bin/build.py
main
called by 1
bin/build.py
main
called by 1
bin/get_version.py
_obj_wrapper
called by 0
pyswarm/__init__.py

Shape

Function 36
Method 4
Class 1

Languages

Python100%

Modules by API surface

pyswarm/__init__.py12 symbols
tests/test_twobar_truss.py6 symbols
bin/build.py5 symbols
tests/test_init.py3 symbols
tests/test_convergence.py3 symbols
tests/test_banana_with_constraints.py3 symbols
tests/test_pool.py2 symbols
tests/test_intvar.py2 symbols
tests/test_bounds.py2 symbols
tests/test_banana_no_constraints.py2 symbols
bin/get_version.py1 symbols

For agents

$ claude mcp add pyswarm \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact