class_docstr: A BH class, inherited from Optimizer.
  
  This is the designed class to define BH-related
  variables and methods.
  
  References:
      A. Hatamlou. Black hole: A new heuristic optimization approach for data clustering.
      Information Sciences (2013).
docstr: It updates every star position and calculates their event's horizon cost (eq. 3).
  
  Args:
      agents: List of agents.
      best_agent: Global best agent.
      function: A function object.
  
  Returns:
      (float): The cost of the event horizon.
docstr_tok: ["It","updates","every","star","position","and","calculates","their","event","'s","horizon","cost","(","eq",".","3",")",".","Args",":","agents",":","List","of","agents",".","best_agent",":","Global","best","agent",".","function",":","A","function","object",".","Returns",":","(","float",")",":","The","cost","of","the","event","horizon","."]
code: def _update_position(
      self, agents: List[Agent], best_agent: Agent, function: Function
  ) -> float:
      """It updates every star position and calculates their event's horizon cost (eq. 3).
  
      Args:
          agents: List of agents.
          best_agent: Global best agent.
          function: A function object.
  
      Returns:
          (float): The cost of the event horizon.
  
      """
  
      cost = 0
  
      for agent in agents:
          r1 = r.generate_uniform_random_number()
          agent.position += r1 * (best_agent.position - agent.position)
          agent.clip_by_bound()
  
          agent.fit = function(agent.position)
          if agent.fit < best_agent.fit:
              agent.position, best_agent.position = (
                  best_agent.position,
                  agent.position,
              )
              agent.fit, best_agent.fit = best_agent.fit, agent.fit
  
          cost += agent.fit
  
      return cost
  
file_path: opytimizer/opytimizer/optimizers/science/bh.py
imports: from typing import Any, Dict, List, Optional
  import numpy
  import opytimizer.math.random
  from opytimizer.core import Optimizer
  from opytimizer.core.agent import Agent
  from opytimizer.core.function import Function
  from opytimizer.core.space import Space
  from opytimizer.utils import constant, logging
label_desc: Use image node_id 2 for calling the BH obj's underlying member method code with example usage: obj._update_position(agents, best_agent, function) and returns: cost