docstr: Initialize the swarm
  
  Attributes
  ----------
  n_particles : int
      number of particles in the swarm.
  dimensions : int
      number of dimensions in the space.
  bounds : tuple of numpy.ndarray
      a tuple of size 2 where the first entry is the minimum bound
      while the second entry is the maximum bound. Each array must
      be of shape :code:`(dimensions,)`.
  oh_strategy : dict, optional, default=None(constant options)
      a dict of update strategies for each option.
  bh_strategy : str
      a strategy for the handling of out-of-bounds particles.
  velocity_clamp : tuple (default is :code:`(0,1)`)
      a tuple of size 2 where the first entry is the minimum velocity
      and the second entry is the maximum velocity. It
      sets the limits for velocity clamping.
  vh_strategy : str
      a strategy for the handling of the velocity of out-of-bounds particles.
  center : list, optional
      an array of size :code:`dimensions`
  ftol : float
      relative error in objective_func(best_pos) acceptable for
      convergence. Default is :code:`-np.inf`
  ftol_iter : int
      number of iterations over which the relative error in
      objective_func(best_pos) is acceptable for convergence.
      Default is :code:`1`
  options : dict with keys :code:`{'c1', 'c2', 'w', 'k', 'p'}`
      a dictionary containing the parameters for the specific
      optimization technique
          * c1 : float
              cognitive parameter
          * c2 : float
              social parameter
          * w : float
              inertia parameter
          * k : int
              number of neighbors to be considered. Must be a
              positive integer less than :code:`n_particles`
          * p: int {1,2}
              the Minkowski p-norm to use. 1 is the
              sum-of-absolute values (or L1 distance) while 2 is
              the Euclidean (or L2) distance.
  init_pos : numpy.ndarray, optional
      option to explicitly set the particles' initial positions. Set to
      :code:`None` if you wish to generate the particles randomly.
  static: bool
      a boolean that decides whether the Ring topology
      used is static or dynamic. Default is `False`
docstr_tok: ["Initialize","the","swarm","Attributes","--","--","--","--","--","n_particles",":","int","number","of","particles","in","the","swarm",".","dimensions",":","int","number","of","dimensions","in","the","space",".","bounds",":","tuple","of","numpy.ndarray","a","tuple","of","size","2","where","the","first","entry","is","the","minimum","bound","while","the","second","entry","is","the","maximum","bound",".","Each","array","must","be","of","shape",":","code",":","`","(","dimensions",",",")","`",".","oh_strategy",":","dict",",","optional",",","default=None","(","constant","options",")","a","dict","of","update","strategies","for","each","option",".","bh_strategy",":","str","a","strategy","for","the","handling","of","out-of-bounds","particles",".","velocity_clamp",":","tuple","(","default","is",":","code",":","`","(","0,1",")","`",")","a","tuple","of","size","2","where","the","first","entry","is","the","minimum","velocity","and","the","second","entry","is","the","maximum","velocity",".","It","sets","the","limits","for","velocity","clamping",".","vh_strategy",":","str","a","strategy","for","the","handling","of","the","velocity","of","out-of-bounds","particles",".","center",":","list",",","optional","an","array","of","size",":","code",":","`","dimensions","`","ftol",":","float","relative","error","in","objective_func","(","best_pos",")","acceptable","for","convergence",".","Default","is",":","code",":","`","-np.inf","`","ftol_iter",":","int","number","of","iterations","over","which","the","relative","error","in","objective_func","(","best_pos",")","is","acceptable","for","convergence",".","Default","is",":","code",":","`","1","`","options",":","dict","with","keys",":","code",":","`","{","'c1","'",",","'c2","'",",","'","w","'",",","'","k","'",",","'","p","'","}","`","a","dictionary","containing","the","parameters","for","the","specific","optimization","technique","*","c1",":","float","cognitive","parameter","*","c2",":","float","social","parameter","*","w",":","float","inertia","parameter","*","k",":","int","number","of","neighbors","to","be","considered",".","Must","be","a","positive","integer","less","than",":","code",":","`","n_particles","`","*","p",":","int","{","1,2","}","the","Minkowski","p-norm","to","use",".","1","is","the","sum-of-absolute","values","(","or","L1","distance",")","while","2","is","the","Euclidean","(","or","L2",")","distance",".","init_pos",":","numpy.ndarray",",","optional","option","to","explicitly","set","the","particles","'","initial","positions",".","Set","to",":","code",":","`","None","`","if","you","wish","to","generate","the","particles","randomly",".","static",":","bool","a","boolean","that","decides","whether","the","Ring","topology","used","is","static","or","dynamic",".","Default","is","`","False","`"]
code: def __init__(
      self,
      n_particles,
      dimensions,
      options,
      bounds=None,
      oh_strategy=None,
      bh_strategy="periodic",
      velocity_clamp=None,
      vh_strategy="unmodified",
      center=1.00,
      ftol=-np.inf,
      ftol_iter=1,
      init_pos=None,
      static=False,
  ):
      """Initialize the swarm
  
      Attributes
      ----------
      n_particles : int
          number of particles in the swarm.
      dimensions : int
          number of dimensions in the space.
      bounds : tuple of numpy.ndarray
          a tuple of size 2 where the first entry is the minimum bound
          while the second entry is the maximum bound. Each array must
          be of shape :code:`(dimensions,)`.
      oh_strategy : dict, optional, default=None(constant options)
          a dict of update strategies for each option.
      bh_strategy : str
          a strategy for the handling of out-of-bounds particles.
      velocity_clamp : tuple (default is :code:`(0,1)`)
          a tuple of size 2 where the first entry is the minimum velocity
          and the second entry is the maximum velocity. It
          sets the limits for velocity clamping.
      vh_strategy : str
          a strategy for the handling of the velocity of out-of-bounds particles.
      center : list, optional
          an array of size :code:`dimensions`
      ftol : float
          relative error in objective_func(best_pos) acceptable for
          convergence. Default is :code:`-np.inf`
      ftol_iter : int
          number of iterations over which the relative error in
          objective_func(best_pos) is acceptable for convergence.
          Default is :code:`1`
      options : dict with keys :code:`{'c1', 'c2', 'w', 'k', 'p'}`
          a dictionary containing the parameters for the specific
          optimization technique
              * c1 : float
                  cognitive parameter
              * c2 : float
                  social parameter
              * w : float
                  inertia parameter
              * k : int
                  number of neighbors to be considered. Must be a
                  positive integer less than :code:`n_particles`
              * p: int {1,2}
                  the Minkowski p-norm to use. 1 is the
                  sum-of-absolute values (or L1 distance) while 2 is
                  the Euclidean (or L2) distance.
      init_pos : numpy.ndarray, optional
          option to explicitly set the particles' initial positions. Set to
          :code:`None` if you wish to generate the particles randomly.
      static: bool
          a boolean that decides whether the Ring topology
          used is static or dynamic. Default is `False`
      """
      if oh_strategy is None:
          oh_strategy = {}
      # Initialize logger
      self.logger = logging.getLogger(__name__)
      # Assign k-neighbors and p-value as attributes
      self.k, self.p = options["k"], options["p"]
      # Initialize parent class
      super(LocalBestPSO, self).__init__(
          n_particles=n_particles,
          dimensions=dimensions,
          options=options,
          bounds=bounds,
          velocity_clamp=velocity_clamp,
          center=center,
          ftol=ftol,
          ftol_iter=ftol_iter,
          init_pos=init_pos,
      )
      # Initialize logger
      self.rep = Reporter(logger=logging.getLogger(__name__))
      # Initialize the resettable attributes
      self.reset()
      # Initialize the topology
      self.top = Ring(static=static)
      self.bh = BoundaryHandler(strategy=bh_strategy)
      self.vh = VelocityHandler(strategy=vh_strategy)
      self.oh = OptionsHandler(strategy=oh_strategy)
      self.name = __name__
  
file_path: pyswarms/pyswarms/single/local_best.py
imports: import logging
  import numpy
  import multiprocessing
  from collections import deque
  from ..backend.operators import compute_pbest, compute_objective_function
  from ..backend.topology import Ring
  from ..backend.handlers import BoundaryHandler, VelocityHandler, OptionsHandler
  from ..base import SwarmOptimizer
  from ..utils.reporter import Reporter
label_desc: Use image node_id 1 to create a new LocalBestPSO object from inherited base classes: SwarmOptimizer with example: obj = LocalBestPSO(n_particles, dimensions, options, bounds, oh_strategy, bh_strategy, velocity_clamp, vh_strategy, center, ftol, ftol_iter, init_pos, static)