class_docstr: A CS class, inherited from Optimizer.
  
  This is the designed class to define CS-related
  variables and methods.
  
  References:
      X.-S. Yang and D. Suash. Cuckoo search via Lévy flights.
      World Congress on Nature & Biologically Inspired Computing (2009).
class_docstr_tok: ["A","CS","class",",","inherited","from","Optimizer",".","This","is","the","designed","class","to","define","CS-related","variables","and","methods",".","References",":","X.-S.","Yang","and","D.","Suash",".","Cuckoo","search","via","L\u00e9vy","flights",".","World","Congress","on","Nature","&","Biologically","Inspired","Computing","(","2009",")","."]
docstr: Generate a fraction of nests to be replaced.
  
  Args:
      agents: List of agents.
      prob: Probability of replacing worst nests.
  
  Returns:
      (List[Agent]): A new list of agents which can be seen as the new nests to be replaced.
docstr_tok: ["Generate","a","fraction","of","nests","to","be","replaced",".","Args",":","agents",":","List","of","agents",".","prob",":","Probability","of","replacing","worst","nests",".","Returns",":","(","List","[","Agent","]",")",":","A","new","list","of","agents","which","can","be","seen","as","the","new","nests","to","be","replaced","."]
code: def _generate_abandoned_nests(
      self, agents: List[Agent], prob: float
  ) -> List[Agent]:
      """Generate a fraction of nests to be replaced.
  
      Args:
          agents: List of agents.
          prob: Probability of replacing worst nests.
  
      Returns:
          (List[Agent]): A new list of agents which can be seen as the new nests to be replaced.
  
      """
  
      new_agents = copy.deepcopy(agents)
  
      # It will be used to replace or not a certain nest
      b = d.generate_bernoulli_distribution(1 - prob, len(agents))
  
      for j, new_agent in enumerate(new_agents):
          r1 = r.generate_uniform_random_number()
  
          k = r.generate_integer_random_number(0, len(agents) - 1)
          l = r.generate_integer_random_number(
              0, len(agents) - 1, exclude_value=k
          )
  
          step_size = r1 * (agents[k].position - agents[l].position)
          new_agent.position += step_size * b[j]
  
      return new_agents
  
imports: import copy
  from typing import Any, Dict, List, Optional
  import numpy
  import opytimizer.math.distribution
  import opytimizer.math.random
  import opytimizer.utils.exception
  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 logging
label_desc: Use image node_id 9 for calling the CS obj's underlying member method code with example usage: obj._generate_abandoned_nests(agents, prob) and returns: new_agents