Sine Cosine Algorithm.

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

A SCA class, inherited from Optimizer.

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


S. Mirjalili. SCA: A Sine Cosine Algorithm for solving optimization problems. Knowledge-Based Systems (2016).

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

Initialization method.

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

Minimum function range.


Maximum function range.


Loudness parameter.

_update_position(agent_position: numpy.ndarray, best_position: numpy.ndarray, r1: float, r2: float, r3: float, r4: float) → numpy.ndarray

Updates a single particle position over a single variable (eq. 3.3).

  • agent_position – Agent’s current position.
  • best_position – Global best position.
  • r1 – Controls the next position’s region.
  • r2 – Defines how far the movement should be.
  • r3 – Random weight for emphasizing or deemphasizing the movement.
  • r4 – Random number to decide whether sine or cosine should be used.

A new position.

Return type:


update(space: opytimizer.core.space.Space, iteration: int, n_iterations: int) → None

Wraps Sine Cosine Algorithm over all agents and variables.

  • space – Space containing agents and update-related information.
  • iteration – Current iteration.
  • n_iterations – Maximum number of iterations.