Skip to main content

Particle Swarm Optimization (PSO) for Python

Project description

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

import numpy as np
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]

xopt, fopt = pso(objective, lb, ub)

print("Optimal solution:", xopt)
print("Function value:", fopt)

Installation

pip install pyswarm

Requires Python 3.10+. No external runtime dependencies. See the full installation guide for uv, poetry, and source builds.

Documentation

License

BSD-3-Clause — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyswarm-0.8.0.tar.gz (100.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyswarm-0.8.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pyswarm-0.8.0.tar.gz.

File metadata

  • Download URL: pyswarm-0.8.0.tar.gz
  • Upload date:
  • Size: 100.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyswarm-0.8.0.tar.gz
Algorithm Hash digest
SHA256 c61e9a7cb5c37746893885f05fdb17cd66140d0a4269e7aee8a75388f684fc91
MD5 43db3e99314046e58d74a8387f010b66
BLAKE2b-256 65437df739763e5cad18671f7db6d8401d6fad74fcb6ef3fedf4d189f2b0357a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyswarm-0.8.0.tar.gz:

Publisher: publish_dist.yml on eggzec/pyswarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyswarm-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: pyswarm-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyswarm-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd23ec7fc4a7c1f5ed99b01ac06f3012cc201a6e4f9cd7a9651590d7bd0c51f5
MD5 4ec753a50e9b16d4bd31c5eed56b309c
BLAKE2b-256 c0ddb617da5adb6a1c42224b9eedd7e00843dcc2e286cda50f20b0835b79d2c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyswarm-0.8.0-py3-none-any.whl:

Publisher: publish_dist.yml on eggzec/pyswarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page