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.9.0.tar.gz (103.2 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.9.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyswarm-0.9.0.tar.gz
Algorithm Hash digest
SHA256 13ca14b54cd664e908bc00ebdbcdbe490b03c0239eb517c05a83c465fef9324d
MD5 4e79ddfda72198c085dc4f713f82ba0a
BLAKE2b-256 847432b00332cc952394c4b78fdd22739ecacb3db5a12924762fb47f3be3df23

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyswarm-0.9.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.9.0-py3-none-any.whl.

File metadata

  • Download URL: pyswarm-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 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.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 581518e9f48169ba20848169cdfbd1bb01eeb755b561fc474464c1b90036aea4
MD5 5e7b7584ce55ef7a5470590f676b4a7e
BLAKE2b-256 6c6d6150767a302e7b9d1acaf9605c3a93c94adfaf0eaa20c2d9f256f1ec961d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyswarm-0.9.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