Skip to main content

Simple Particle Swarm Optimization

Project description

Optimus-Beez

This is a Particle Swarm Optimization (PSO) package. The PSO used is the simplest version presented by Maurice Clarc in "Particle Swarm Optimization".

Installation

Run the following command: pip install optimusbeez

How to use Optimus-Beez

Choosing the function to evaluate

The default function to evaluate is Rosenbrock. To change this, first check out evaluate.py. This file contains evaluate() that evaluates points for different functions. If the function you wish to use is not defined, then go ahead and add it to evaluate(). Then go to function_info.txt and change

  • fn_name to the name of one of the functions in evaluate()
  • true_position to the x,y-coordinates of the global minimum of your function

Optimizing the parameters of the PSO

The optimization algorithm itself contains 5 parameters that need to be set by the user. These are set in the file optimal_constants.txt. In the code, these parameters are referred to as 'constants' so as not to confuse them with the x,y-coordinates. It is a good idea to optimize these constants using optimize_constants.py. Run optimize_constants.py on your command line. This is just good old random search optimization. You will be prompted several times for input. Use a value of 'time steps' similar to what you want to use with PSO. When the random search is completed, you will be asked if you want to overwrite the file optimal_constants.txt. Do this if you would like to use these constants in PSO.py.

Using PSO

The main script is PSO.py. Run this in the command line. You will be asked if you want to change the number of evaluations. If the value you wish to set is much larger or smaller than the default value, it is advised you run optimize_constants.py again. Set the value, or use the default value and wait for the PSO to finish. You will see an animation of your swarm at the end.

Testing

Nose is used to test the code. All tests are located in the 'tests' folder.To run the tests, execute:

nosetests

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

optimusbeez-0.1.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

optimusbeez-0.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file optimusbeez-0.1.0.tar.gz.

File metadata

  • Download URL: optimusbeez-0.1.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for optimusbeez-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a56ea7c1b533ed973aed33d59921387bd3bf0ba6e915e45bbba47ea62eabfe5f
MD5 c4965e9b368eb8a3d61cdd18806b3fe3
BLAKE2b-256 4475b7193f2ed791383334c4070c5445d5d4c875d5fddb758ab216420aa54bb0

See more details on using hashes here.

File details

Details for the file optimusbeez-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: optimusbeez-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for optimusbeez-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41553d20ef486eac5e50870e9d77819e1748e8ebcc78551e5613fa3f6c2a2af7
MD5 f0d9d13c77d9e2a3d7f1c48f6b6c52e9
BLAKE2b-256 98e558ff6e197370e5b61f05a8cb3503752482cb26dfef55dba3b0df1a21d540

See more details on using hashes here.

Supported by

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