opytimizer.optimizers.science.bh

Black Hole.

class opytimizer.optimizers.science.bh.BH(params: Optional[Dict[str, Any]] = None)

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

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

Initialization method.

Parameters:params – Contains key-value parameters to the meta-heuristics.
_update_position(agents: List[opytimizer.core.agent.Agent], best_agent: opytimizer.core.agent.Agent, function: opytimizer.core.function.Function) → float

It updates every star position and calculates their event’s horizon cost (eq. 3).

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

The cost of the event horizon.

Return type:

(float)

_event_horizon(agents: List[opytimizer.core.agent.Agent], best_agent: opytimizer.core.agent.Agent, cost: float) → None

It calculates the stars’ crossing an event horizon (eq. 4).

Parameters:
  • agents – List of agents.
  • best_agent – Global best agent.
  • cost – The event’s horizon cost.
update(space: opytimizer.core.space.Space, function: opytimizer.core.function.Function) → None

Wraps Black Hole 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.