opytimizer.optimizers.swarm.cs

Cuckoo Search.

class opytimizer.optimizers.swarm.cs.CS(params: Optional[Dict[str, Any]] = None)

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).

__init__(params: Optional[Dict[str, Any]] = None) → None

Initialization method.

Parameters:params – Contains key-value parameters to the meta-heuristics.
alpha

Step size.

beta

Lévy distribution parameter.

p

Probability of replacing worst nests.

_generate_new_nests(agents: List[opytimizer.core.agent.Agent], best_agent: opytimizer.core.agent.Agent) → List[opytimizer.core.agent.Agent]

Generate new nests (eq. 1).

Parameters:
  • agents – List of agents.
  • best_agent – Global best agent.
Returns:

A new list of agents which can be seen as new nests.

Return type:

(List[Agent])

_generate_abandoned_nests(agents: List[opytimizer.core.agent.Agent], prob: float) → List[opytimizer.core.agent.Agent]

Generate a fraction of nests to be replaced.

Parameters:
  • agents – List of agents.
  • prob – Probability of replacing worst nests.
Returns:

A new list of agents which can be seen as the new nests to be replaced.

Return type:

(List[Agent])

_evaluate_nests(agents: List[opytimizer.core.agent.Agent], new_agents: List[opytimizer.core.agent.Agent], function: opytimizer.core.function.Function) → None

Evaluate new nests according to a fitness function.

Parameters:
  • agents – List of current agents.
  • new_agents – List of new agents to be evaluated.
  • function – Fitness function used to evaluate.
update(space: opytimizer.core.space.Space, function: opytimizer.core.function.Function) → None

Wraps Cuckoo Search over all agents and variables.

Parameters:
  • space – Space containing agents and update-related information.
  • function – A Function object that will be used as the objective function.