{"library":"pyswarms","title":"PySwarms","description":"PySwarms is a Python library for Particle Swarm Optimization (PSO). It provides a simple and intuitive API for implementing PSO algorithms, including global best (gbest), local best (lbest), and binary PSO, as well as tools for visualization and hyperparameter tuning. The current version is 1.3.0, released in 2021. The project is in maintenance mode with quarterly release cadence.","language":"python","status":"maintenance","last_verified":"Fri May 01","install":{"commands":["pip install pyswarms"],"cli":null},"imports":["from pyswarms.single import GlobalBestPSO","from pyswarms.single import LocalBestPSO","from pyswarms.discrete import BinaryPSO","from pyswarms.utils.plotters import plot_cost_history"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom pyswarms.single import GlobalBestPSO\n\ndef sphere(x):\n    return np.sum(x**2, axis=1)\n\noptimizer = GlobalBestPSO(n_particles=10, dimensions=2, options={'c1': 0.5, 'c2': 0.3, 'w':0.9})\ncost, pos = optimizer.optimize(sphere, iters=100)\nprint(\"Best cost:\", cost)\nprint(\"Best position:\", pos)","lang":"python","description":"Minimal example optimizing the sphere function with global best PSO.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}