opytimizer.optimizers.swarm.boa

Butterfly Optimization Algorithm.

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

A BOA class, inherited from Optimizer.

This is the designed class to define BOA-related variables and methods.

References

S. Arora and S. Singh. Butterfly optimization algorithm: a novel approach for global optimization. Soft Computing (2019).

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

Initialization method.

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

Sensor modality.

a

Power exponent.

p

Switch probability.

fragrance

Array of fragrances.

compile(space: opytimizer.core.space.Space) → None

Compiles additional information that is used by this optimizer.

Parameters:space – A Space object containing meta-information.
_best_movement(agent_position: numpy.ndarray, best_position: numpy.ndarray, fragrance: numpy.ndarray, random: float) → numpy.ndarray

Updates the agent’s position towards the best butterfly (eq. 2).

Parameters:
  • agent_positio – Agent’s current position.
  • best_positio – Best agent’s current position.
  • fragrance – Agent’s current fragrance value.
  • random – A random number between 0 and 1.
Returns:

A new position based on best movement.

Return type:

(np.ndarray)

_local_movement(agent_position: numpy.ndarray, j_position: numpy.ndarray, k_position: numpy.ndarray, fragrance: numpy.ndarray, random: float) → numpy.ndarray

Updates the agent’s position using a local movement (eq. 3).

Parameters:
  • agent_positio – Agent’s current position.
  • j_positio – Agent j current position.
  • k_positio – Agent k current position.
  • fragrance – Agent’s current fragrance value.
  • random – A random number between 0 and 1.
Returns:

A new position based on local movement.

Return type:

(np.ndarray)

update(space: opytimizer.core.space.Space) → None

Wraps Butterfly Optimization Algorithm over all agents and variables.

Parameters:space – Space containing agents and update-related information.