docstr: Initialize the swarm
  
  Creates a Swarm class depending on the values initialized
  
  Attributes
  ----------
  n_particles : int
      number of particles in the swarm.
  dimensions : int
      number of dimensions in the space.
  options : dict with keys :code:`{'c1', 'c2', 'w'}`
      a dictionary containing the parameters for the specific
      optimization technique
          * c1 : float
              cognitive parameter
          * c2 : float
              social parameter
          * w : float
              inertia parameter
  bounds : tuple of numpy.ndarray, optional
      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,)`.
  velocity_clamp : tuple, optional
      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.
  center : list, optional
      an array of size :code:`dimensions`
  ftol : float, optional
      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`
code: def __init__(
      self,
      n_particles,
      dimensions,
      options,
      bounds=None,
      velocity_clamp=None,
      center=1.0,
      ftol=-np.inf,
      ftol_iter=1,
      init_pos=None,
  ):
      """Initialize the swarm
  
      Creates a Swarm class depending on the values initialized
  
      Attributes
      ----------
      n_particles : int
          number of particles in the swarm.
      dimensions : int
          number of dimensions in the space.
      options : dict with keys :code:`{'c1', 'c2', 'w'}`
          a dictionary containing the parameters for the specific
          optimization technique
              * c1 : float
                  cognitive parameter
              * c2 : float
                  social parameter
              * w : float
                  inertia parameter
      bounds : tuple of numpy.ndarray, optional
          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,)`.
      velocity_clamp : tuple, optional
          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.
      center : list, optional
          an array of size :code:`dimensions`
      ftol : float, optional
          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`
      """
      # Initialize primary swarm attributes
      self.n_particles = n_particles
      self.dimensions = dimensions
      self.bounds = bounds
      self.velocity_clamp = velocity_clamp
      self.swarm_size = (n_particles, dimensions)
      self.options = options
      self.center = center
      self.ftol = ftol
  
      try:
          assert ftol_iter > 0 and isinstance(ftol_iter, int)
      except AssertionError:
          raise AssertionError(
              "ftol_iter expects an integer value greater than 0"
          )
  
      self.ftol_iter = ftol_iter
      self.init_pos = init_pos
      # Initialize named tuple for populating the history list
      self.ToHistory = namedtuple(
          "ToHistory",
          [
              "best_cost",
              "mean_pbest_cost",
              "mean_neighbor_cost",
              "position",
              "velocity",
          ],
      )
      # Initialize resettable attributes
      self.reset()
  
file_path: pyswarms/pyswarms/base/base_single.py
imports: import abc
  from collections import namedtuple
  import numpy
  from ..backend import create_swarm
label_desc: Use image node_id 1 to create a new SwarmOptimizer object from inherited base classes: abc with example: obj = SwarmOptimizer(n_particles, dimensions, options, bounds, velocity_clamp, center, ftol, ftol_iter, init_pos)