Releases: ljvmiranda921/pyswarms
Release v.0.1.9
After three months, we are happy to present our next development release, version v.0.1.9! This release introduces non-breaking changes in the API and minor fixes adopting pylint
's and flake8
's strict conventions. This release would not have been possible without the help of @mamadyonline and our new Collaborator Siobhan K. Cronin! Thank you for all your help and support in maintaining PySwarms!
Release notes
NEW: Ability to set the initial position of the swarm - #93
NEW: Ability to set a tolerance value to break the iteration - #93, #100
FIX: Fix for the Rosenbrock function returning the incorrect shape - #98
Initial Position and Tolerance Value
Before, the swarm particles were generated randomly with respect to a lower and upper bound that we set during initialization. Now, we have the ability to initialize our swarm particles around a particular location, just in case we have applications that require that feature.
Addtionally, we added a tolerance value to decrease optimization time. Usually, we just wait for a given number of iterations until the optimization finishes. We have now improved this and included a ftol
parameter that serves as a threshold whenever the difference in the costs are not as significant anymore.
Fix for the Rosenbrock function
Turns out that there is something wrong with our Rosenbrock function for it does not return a vector of shape (n_particles, )
. Don't worry, we have fixed that!
Release v.0.1.8
Patch v.0.1.7
Release notes
- FIX: Bugfix for
local_best.py
andbinary.py
not returning the best cost they have encountered in the optimization process - #34 - IMPROVED: Git now ignores IPython notebook checkpoints
Release v.0.1.6
Release notes
- NEW: Hyperparameter search tools - #20, #25, #28
- IMPROVED: Updated structure of Base classes for higher extensibility
- IMPROVED: More robust tests for
PlotEnvironment
Hyperparameter Search Tools
PySwarms now implements a native version of GridSearch
and RandomSearch
to help you find the best hyperparameters in your swarm. To use this feature, simply call the RandomSearch
and GridSearch
classes from the pyswarms.utils.search
module.
import numpy as np
import pyswarms as ps
from pyswarms.utils.search import RandomSearch
from pyswarms.utils.functions import single_obj as fx
# Set-up choices for the parameters
options = {
'c1': (1,5),
'c2': (6,10),
'w': (2,5),
'k': (11, 15),
'p': 1
}
# Create a RandomSearch object
# n_selection_iters is the number of iterations to run the searcher
# iters is the number of iterations to run the optimizer
g = RandomSearch(ps.single.LocalBestPSO, n_particles=40,
dimensions=20, options=options, objective_func=fx.sphere_func,
iters=10, n_selection_iters=100)
best_score, best_options = g.search()
This then returns the best score found during optimization and the hyperparameter options that enabled it.
>>> best_score
1.41978545901
>>> best_options['c1']
1.543556887693
>>> best_options['c2']
9.504769054771
Improved Library API
Most of the swarm classes now inherit the base class in order to demonstrate its extensibility. If you are a developer or a swarm researcher planning to implement your own algorithms, simply inherit from these Base Classes and implement the optimize()
method.
Release v.0.1.5
Release notes
Graphics Environment
This new plotting environment makes it easier to plot the costs and swarm movement in 2-d or 3-d planes. The PlotEnvironment
class takes in the optimizer and its parameters as arguments. It then performs a fresh run to plot the cost and to create animations.
An example of usage can be seen below:
import pyswarms as ps
from pyswarms.utils.functions import single_obj as fx
from pyswarms.utils.environments import PlotEnvironment
# Set-up optimizer
options = {'c1':0.5, 'c2':0.3, 'w':0.9}
optimizer = ps.single.GlobalBestPSO(n_particles=10, dimensions=3, options=options)
# Initialize plot environment
plt_env = PlotEnvironment(optimizer, fx.sphere_func, 1000)
# Plot the cost
plt_env.plot_cost(figsize=(8,6));
plt.show()