docstr: A BoundaryHandler class
  
  This class offers a way to handle boundary conditions. It contains
  methods to repair particle positions outside of the defined boundaries.
  Following strategies are available for the handling:
  
  * Nearest:
      Reposition the particle to the nearest bound.
  * Random:
      Reposition the particle randomly in between the bounds.
  * Shrink:
      Shrink the velocity of the particle such that it lands on the
      bounds.
  * Reflective:
      Mirror the particle position from outside the bounds to inside the
      bounds.
  * Intermediate:
      Reposition the particle to the midpoint between its current
      position on the bound surpassing axis and the bound itself.  This
      only adjusts the axes that surpass the boundaries.
  
  The BoundaryHandler can be called as a function to use the strategy
  that is passed at initialization to repair boundary issues. An example
  for the usage:
  
  .. code-block :: python
  
      from pyswarms.backend import operators as op
      from pyswarms.backend.handlers import BoundaryHandler
  
      bh = BoundaryHandler(strategy="reflective")
      ops.compute_position(swarm, bounds, handler=bh)
  
  By passing the handler, the :func:`compute_position()` function now has
  the ability to reset the particles by calling the :code:`BoundaryHandler`
  inside.
  
  Attributes
  ----------
  strategy : str
      The strategy to use. To see all available strategies,
      call :code:`BoundaryHandler.strategies`
docstr_tok: ["A","BoundaryHandler","class","This","class","offers","a","way","to","handle","boundary","conditions",".","It","contains","methods","to","repair","particle","positions","outside","of","the","defined","boundaries",".","Following","strategies","are","available","for","the","handling",":","*","Nearest",":","Reposition","the","particle","to","the","nearest","bound",".","*","Random",":","Reposition","the","particle","randomly","in","between","the","bounds",".","*","Shrink",":","Shrink","the","velocity","of","the","particle","such","that","it","lands","on","the","bounds",".","*","Reflective",":","Mirror","the","particle","position","from","outside","the","bounds","to","inside","the","bounds",".","*","Intermediate",":","Reposition","the","particle","to","the","midpoint","between","its","current","position","on","the","bound","surpassing","axis","and","the","bound","itself",".","This","only","adjusts","the","axes","that","surpass","the","boundaries",".","The","BoundaryHandler","can","be","called","as","a","function","to","use","the","strategy","that","is","passed","at","initialization","to","repair","boundary","issues",".","An","example","for","the","usage",":","..","code-block",":",":","python","from","pyswarms.backend","import","operators","as","op","from","pyswarms.backend.handlers","import","BoundaryHandler","bh","=","BoundaryHandler","(","strategy=","''","reflective","''",")","ops.compute_position","(","swarm",",","bounds",",","handler=bh",")","By","passing","the","handler",",","the",":","func",":","`","compute_position","(",")","`","function","now","has","the","ability","to","reset","the","particles","by","calling","the",":","code",":","`","BoundaryHandler","`","inside",".","Attributes","--","--","--","--","--","strategy",":","str","The","strategy","to","use",".","To","see","all","available","strategies",",","call",":","code",":","`","BoundaryHandler.strategies","`"]
code: def __init__(self, strategy):
      """A BoundaryHandler class
  
      This class offers a way to handle boundary conditions. It contains
      methods to repair particle positions outside of the defined boundaries.
      Following strategies are available for the handling:
  
      * Nearest:
          Reposition the particle to the nearest bound.
      * Random:
          Reposition the particle randomly in between the bounds.
      * Shrink:
          Shrink the velocity of the particle such that it lands on the
          bounds.
      * Reflective:
          Mirror the particle position from outside the bounds to inside the
          bounds.
      * Intermediate:
          Reposition the particle to the midpoint between its current
          position on the bound surpassing axis and the bound itself.  This
          only adjusts the axes that surpass the boundaries.
  
      The BoundaryHandler can be called as a function to use the strategy
      that is passed at initialization to repair boundary issues. An example
      for the usage:
  
      .. code-block :: python
  
          from pyswarms.backend import operators as op
          from pyswarms.backend.handlers import BoundaryHandler
  
          bh = BoundaryHandler(strategy="reflective")
          ops.compute_position(swarm, bounds, handler=bh)
  
      By passing the handler, the :func:`compute_position()` function now has
      the ability to reset the particles by calling the :code:`BoundaryHandler`
      inside.
  
      Attributes
      ----------
      strategy : str
          The strategy to use. To see all available strategies,
          call :code:`BoundaryHandler.strategies`
      """
      self.strategy = strategy
      self.strategies = self._get_all_strategies()
      self.rep = Reporter(logger=logging.getLogger(__name__))
      self.memory = None
  
imports: import inspect
  import logging
  import numpy
  import math
  from copy import copy
  from ..utils.reporter import Reporter
label_desc: Use image node_id 1 to create a new BoundaryHandler object from inherited base classes: HandlerMixin with example: obj = BoundaryHandler(strategy)