All Projects → jerrytheo → psopy

jerrytheo / psopy

Licence: BSD-3-Clause license
A SciPy compatible super fast Python implementation for Particle Swarm Optimization.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to psopy

zoofs
zoofs is a python library for performing feature selection using a variety of nature-inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics-based to Evolutionary. It's easy to use , flexible and powerful tool to reduce your feature size.
Stars: ✭ 142 (+330.3%)
Mutual labels:  optimization-algorithms, particle-swarm-optimization
rBAS
Implementation of the (beetle antennae search) BAS algorithm and its mutations in R code
Stars: ✭ 25 (-24.24%)
Mutual labels:  constrained-optimization, optimization-algorithms
pdfo
Powell's Derivative-Free Optimization solvers
Stars: ✭ 56 (+69.7%)
Mutual labels:  constrained-optimization, optimization-algorithms
sopt
sopt:A simple python optimization library
Stars: ✭ 42 (+27.27%)
Mutual labels:  optimization-algorithms, particle-swarm-optimization
sdaopt
Simulated Dual Annealing for python and benchmarks
Stars: ✭ 15 (-54.55%)
Mutual labels:  scipy, optimization-algorithms
scipy con 2019
Tutorial Sessions for SciPy Con 2019
Stars: ✭ 262 (+693.94%)
Mutual labels:  scipy
jupyter boilerplate
Adds a customizable menu item to Jupyter (IPython) notebooks to insert boilerplate snippets of code
Stars: ✭ 69 (+109.09%)
Mutual labels:  scipy
open-box
Generalized and Efficient Blackbox Optimization System [SIGKDD'21].
Stars: ✭ 174 (+427.27%)
Mutual labels:  constrained-optimization
Metaheuristics.jl
High-performance metaheuristics for optimization coded purely in Julia.
Stars: ✭ 144 (+336.36%)
Mutual labels:  constrained-optimization
object-detection-with-svm-and-opencv
detect objects using svm and opencv
Stars: ✭ 24 (-27.27%)
Mutual labels:  scipy
cspy
A collection of algorithms for the (Resource) Constrained Shortest Path problem in Python / C++ / C#
Stars: ✭ 64 (+93.94%)
Mutual labels:  optimization-algorithms
TBFIT
Tight-binding parameter fitting package (TBFIT) for Slater-Koster method
Stars: ✭ 18 (-45.45%)
Mutual labels:  particle-swarm-optimization
pycsp3
A Python Library for modeling combinatorial constrained problems
Stars: ✭ 39 (+18.18%)
Mutual labels:  constrained-optimization
pybnb
A parallel branch-and-bound engine for Python. (https://pybnb.readthedocs.io/)
Stars: ✭ 53 (+60.61%)
Mutual labels:  optimization-algorithms
Multiobjective EGO algorithms
The standard and parallel multiobjective EGO algorithms
Stars: ✭ 22 (-33.33%)
Mutual labels:  constrained-optimization
techloop-ml-plus
Archives and Tasks for ML+ sessions
Stars: ✭ 23 (-30.3%)
Mutual labels:  scipy
xkcd-2048
No description or website provided.
Stars: ✭ 12 (-63.64%)
Mutual labels:  scipy
scipy-crash-course
Material for a 24 hours course on Scientific Python
Stars: ✭ 98 (+196.97%)
Mutual labels:  scipy
PyCannyEdge
Educational Python implementation of the Canny Edge Detector
Stars: ✭ 31 (-6.06%)
Mutual labels:  scipy
CNCC-2019
Computational Neuroscience Crash Course (CNCC 2019)
Stars: ✭ 26 (-21.21%)
Mutual labels:  scipy

PSOPy

A python implementation of Particle Swarm Optimization.

Introduction

PSOPy (pronounced "Soapy") is a SciPy compatible super fast Python implementation for Particle Swarm Optimization. The codes are tested for standard optimization test functions (both constrained and unconstrained).

The library provides two implementations, one that mimics the interface to scipy.optimize.minimize and one that directly runs PSO. The SciPy compatible function is a wrapper over the direct implementation, and therefore may be slower in execution time, as the constraint and fitness functions are wrapped.

Installation

GitHub

To install this library from GitHub,

$ git clone https://github.com/jerrytheo/psopy.git
$ cd psopy
$ python setup.py install

In order to run the tests,

$ python setup.py test

PyPI

This library is available on the PyPI as psopy. If you have pip installed run,

$ pip install psopy

Examples

Unconstrained Optimization

Consider the problem of minimizing the Rosenbrock function, implemented as scipy.optimize.rosen using a swarm of 1000 particles.

>>> import numpy as np
>>> from psopy import minimize
>>> from scipy.optimize import rosen
>>> x0 = np.random.uniform(0, 2, (1000, 5))
>>> res = minimize(rosen, x0, options={'stable_iter': 50})
>>> res.x
array([1.00000003, 1.00000017, 1.00000034, 1.0000006 , 1.00000135])

Constrained Optimization

Next, we consider a minimization problem with several constraints. The intial positions for constrained optimization must adhere to the constraints imposed by the problem. This can be ensured using the provided function psopy.init_feasible. Note, there are several caveats regarding the use of this function. Consult its documentation for more information.

>>> # The objective function.
>>> fun = lambda x: (x[0] - 1)**2 + (x[1] - 2.5)**2
>>> # The constraints.
>>> cons = ({'type': 'ineq', 'fun': lambda x:  x[0] - 2 * x[1] + 2},
...         {'type': 'ineq', 'fun': lambda x: -x[0] - 2 * x[1] + 6},
...         {'type': 'ineq', 'fun': lambda x: -x[0] + 2 * x[1] + 2},
...         {'type': 'ineq', 'fun': lambda x: x[0]},
...         {'type': 'ineq', 'fun': lambda x: x[1]})
>>> from psopy import init_feasible
>>> x0 = init_feasible(cons, low=0., high=2., shape=(1000, 2))
>>> res = minimize(fun, x0, constrainsts=cons, options={
...     'g_rate': 1., 'l_rate': 1., 'max_velocity': 4., 'stable_iter': 50})
>>> res.x
array([ 1.39985398,  1.69992748])

Authors

License

Licensed under the BSD 3-Clause License.
Copyright 2018 Abhijit Theophilus, Snehanshu Saha, Suryoday Basak

References

[1]Theophilus, A., Saha, S., Basak, S. and Murthy, J., 2018. A Novel Exoplanetary Habitability Score via Particle Swarm Optimization of CES Production Functions. arXiv preprint arXiv:1805.08858.
[2]Ray, T. and Liew, K.M., 2001. A swarm with an effective information sharing mechanism for unconstrained and constrained single objective optimisation problems. In Evolutionary Computation, 2001. Proceedings of the 2001 Congress on (Vol. 1, pp. 75-80). IEEE.
[3]Eberhart, R. and Kennedy, J., 1995, October. A new optimizer using particle swarm theory. In Micro Machine and Human Science, 1995. MHS'95., Proceedings of the Sixth International Symposium on (pp. 39-43). IEEE.
[4]Shi, Y. and Eberhart, R., 1998, May. A modified particle swarm optimizer. In Evolutionary Computation Proceedings, 1998. IEEE World Congress on Computational Intelligence., The 1998 IEEE International Conference on (pp. 69-73). IEEE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].