Skip to content

Commit

Permalink
Add BoundaryHandler and VelocityHandler (#238)
Browse files Browse the repository at this point in the history
Implements the new `BoundaryHandler` and `VelocityHandler` classes that deal with the issue of particles that don't move in optimisations with boundary conditions. This is achieved by using different strategies that have been described in [Hel10](https://opus4.kobv.de/opus4-fau/frontdoor/index/index/year/2010/docId/1328) (P. 28). These strategies include:
- Nearest bound: Reset particle to the nearest boundary
- Random: Reset the particle to a random position within the bounds
- Shrink: Shrink the velocity such that the particle touches the boundary instead of surpassing it
- Intermediate: Reset the particle to a value between its former location and the bound
- Resample: Calculate new velocities until the next particle position is within the bounds
- Periodic: Tile the space with the same search space over and over
- Reflective: Mirror the position of the particle at the surpassed boundary

Resolves #237
  • Loading branch information
whzup authored and ljvmiranda921 committed Feb 9, 2019
1 parent 0adef1a commit 50f6e15
Show file tree
Hide file tree
Showing 21 changed files with 1,033 additions and 116 deletions.
1 change: 1 addition & 0 deletions docs/api/_pyswarms.backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ as GlobalBestPSO and LocalBestPSO were built using the backend module.
.. toctree::

pyswarms.backend
pyswarms.handlers
pyswarms.topology
pyswarms.swarms

15 changes: 11 additions & 4 deletions docs/api/pyswarms.backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@ You can import all the native helper methods in this package
using the command:

.. code-block:: python
import pyswarms.backend as P
import pyswarms.backend as P
Then call the methods found in each module. Note that these methods interface
with the Swarm class provided in the :mod:`pyswarms.backend.swarms` module.

pyswarms.backend.generators module
-----------------------------------
----------------------------------

.. automodule:: pyswarms.backend.generators
:members:

pyswarms.backend.handlers module
--------------------------------

.. automodule:: pyswarms.backend.handlers
:members:

pyswarms.backend.operators module
----------------------------------

.. automodule:: pyswarms.backend.operators
:members:
:members:

17 changes: 17 additions & 0 deletions docs/api/pyswarms.handlers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pyswarms.handlers package
=========================

This package implements different handling strategies for the optimiziation
using boundary conditions. The strategies help avoiding that particles
leave the defined search space. There are two :code:`Handler` classes
that provide these functionalities, the :class:`BoundaryHandler` and the
:class:`VelocityHandler`.

pyswarms.handlers class
-----------------------

.. automodule:: pyswarms.backend.handlers
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__, __call__
3 changes: 2 additions & 1 deletion pyswarms/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"""

from .generators import *
from .handlers import *
from .operators import *
from .swarms import *

__all__ = ["generators", "operators", "swarms"]
__all__ = ["generators", "handlers", "operators", "swarms"]

0 comments on commit 50f6e15

Please sign in to comment.