docstr: Compute the velocity matrix
  
  This method updates the velocity matrix using the best and current
  positions of the swarm. The velocity matrix is computed using the
  cognitive and social terms of the swarm.
  
  A sample usage can be seen with the following:
  
  .. code-block :: python
  
      import pyswarms.backend as P
      from pyswarms.backend.swarm import Swarm
      from pyswarms.backend.handlers import VelocityHandler
      from pyswarms.backend.topology import Ring
  
      my_swarm = P.create_swarm(n_particles, dimensions)
      my_topology = Ring(static=False)
      my_vh = VelocityHandler(strategy="invert")
  
      for i in range(iters):
          # Inside the for-loop
          my_swarm.velocity = my_topology.update_velocity(my_swarm, clamp, my_vh,
          bounds)
  
  Parameters
  ----------
  swarm : pyswarms.backend.swarms.Swarm
      a Swarm instance
  clamp : tuple of floats (default is :code:`None`)
      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 : pyswarms.backend.handlers.VelocityHandler
      a VelocityHandler instance
  bounds : tuple of :code:`np.ndarray` or list (default is :code:`None`)
      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,)`.
  
  Returns
  -------
  numpy.ndarray
      Updated velocity matrix
docstr_tok: ["Compute","the","velocity","matrix","This","method","updates","the","velocity","matrix","using","the","best","and","current","positions","of","the","swarm",".","The","velocity","matrix","is","computed","using","the","cognitive","and","social","terms","of","the","swarm",".","A","sample","usage","can","be","seen","with","the","following",":","..","code-block",":",":","python","import","pyswarms.backend","as","P","from","pyswarms.backend.swarm","import","Swarm","from","pyswarms.backend.handlers","import","VelocityHandler","from","pyswarms.backend.topology","import","Ring","my_swarm","=","P.create_swarm","(","n_particles",",","dimensions",")","my_topology","=","Ring","(","static=False",")","my_vh","=","VelocityHandler","(","strategy=","''","invert","''",")","for","i","in","range","(","iters",")",":","#","Inside","the","for-loop","my_swarm.velocity","=","my_topology.update_velocity","(","my_swarm",",","clamp",",","my_vh",",","bounds",")","Parameters","--","--","--","--","--","swarm",":","pyswarms.backend.swarms.Swarm","a","Swarm","instance","clamp",":","tuple","of","floats","(","default","is",":","code",":","`","None","`",")","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",":","pyswarms.backend.handlers.VelocityHandler","a","VelocityHandler","instance","bounds",":","tuple","of",":","code",":","`","np.ndarray","`","or","list","(","default","is",":","code",":","`","None","`",")","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",",",")","`",".","Returns","--","--","--","-","numpy.ndarray","Updated","velocity","matrix"]
code: def compute_velocity(
      self,
      swarm,
      clamp=None,
      vh=VelocityHandler(strategy="unmodified"),
      bounds=None,
  ):
      """Compute the velocity matrix
  
      This method updates the velocity matrix using the best and current
      positions of the swarm. The velocity matrix is computed using the
      cognitive and social terms of the swarm.
  
      A sample usage can be seen with the following:
  
      .. code-block :: python
  
          import pyswarms.backend as P
          from pyswarms.backend.swarm import Swarm
          from pyswarms.backend.handlers import VelocityHandler
          from pyswarms.backend.topology import Ring
  
          my_swarm = P.create_swarm(n_particles, dimensions)
          my_topology = Ring(static=False)
          my_vh = VelocityHandler(strategy="invert")
  
          for i in range(iters):
              # Inside the for-loop
              my_swarm.velocity = my_topology.update_velocity(my_swarm, clamp, my_vh,
              bounds)
  
      Parameters
      ----------
      swarm : pyswarms.backend.swarms.Swarm
          a Swarm instance
      clamp : tuple of floats (default is :code:`None`)
          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 : pyswarms.backend.handlers.VelocityHandler
          a VelocityHandler instance
      bounds : tuple of :code:`np.ndarray` or list (default is :code:`None`)
          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,)`.
  
      Returns
      -------
      numpy.ndarray
          Updated velocity matrix
      """
      return ops.compute_velocity(swarm, clamp, vh, bounds)
  
file_path: pyswarms/pyswarms/backend/topology/ring.py
imports: import logging
  import numpy
  from scipy.spatial import cKDTree
  from ..None import operators
  from ..handlers import BoundaryHandler, VelocityHandler
  from ...utils.reporter import Reporter
  from .base import Topology
label_desc: Use image node_id 3 for calling the Ring obj's underlying member method code with example usage: obj.compute_velocity(swarm, clamp, vh, bounds) and returns: ops