Skip to main content

pyticle

A Python Library for Particle Swarm Intelligence

Build Status

This package implements the Particle Swarm Optimization (PSO) algorithm in pure python. The only thing you need to is installing the package and call it with the right parameters!

PSO is an interactive meta-heuristic algorithm that uses "particles" as a candidates for solutions. The goal is to move the particles towards the global/local minimum in each iteration.

Installation

Simply install this package by running the following command:  ```bash pip install pyticle


## Usage

To minimize the 2D function `my_func` in range [-15, 10] using 100 particles via 80 iterations:
```python
from pyticle.swarm_optimization import SwarmOptimization
optimizer = SwarmOptimization(cost_func=my_func, particle_num=100, omega_start=1, omega_end=0.0,
 coef=[2.0, 2.0], low_bound=-15.0, high_bound=10,
 boundary_strategy='random', var_size=2, max_iter_num=80, elite_rate=0.1)
optimizer.optimize()

Demo

In this section, you can see the results of using this package for two simple 2D benchmarks. To run the benchmarks, run:

from pyticle.demo_run import demo_run
demo_run()

The Sphere Function

Here is the evolution of 100 particles in 100 iterations to find the minimum of the Sphere function:

Here is the changes in the minimum, average, and maximum values of the cost function of all particles over time:

The Ackley Function

Same as the previous example, this is the evolution of 100 particles in 100 iterations to find the minimum of the Ackley function:

Here is the changes in the minimum, average, and maximum values of the cost function of all particles over time:

Contribution

You are very welcome to contribute to this project with your code (as pull-requests), mention the bugs or ask for new features (as GitHub Issues), or just tell your friends about it!

You can also directly contact me by email.  

Metadata

Release files for pyticle 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyticle 0.0.1
File Size Uploaded Provenance Actions
pyticle-0.0.1.tar.gz 7.5 kB Without provenance Details for pyticle-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyticle 0.0.1
File Interpreter ABI Platform Actions
pyticle-0.0.1-py3-none-any.whl Python 3 none any Details for pyticle-0.0.1-py3-none-any.whl

Total release size: 16.2 kB

Release files / pyticle-0.0.1.tar.gz

Download URL pyticle-0.0.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5d6d8fa0c952e520e5203329dd030f544a4f7628481fa63de0c258296cffa48a
BLAKE2b-256 checksum
How to use checksums
4f372c554acbfb24654f5fb4f4ad605f35e7b87aaf2286eca6d79a05e3442601
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Release files / pyticle-0.0.1-py3-none-any.whl

Download URL pyticle-0.0.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15b5bcd9c2c8fc75f75b6e396a9147c75f4d9293d31de454d36a3d4b5f9784c9
BLAKE2b-256 checksum
How to use checksums
6df14f7384bb738d2ae5a34912052ee3c2a17f903b50a44700857c75b7036c56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

Security for pyticle 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page