evox.algorithms.so.pso_variants.cso

Module Contents

Classes

CSO

The basic CSO algorithm.

API

class evox.algorithms.so.pso_variants.cso.CSO(pop_size: int, lb: torch.Tensor, ub: torch.Tensor, phi: float = 0.0, mean: torch.Tensor | None = None, stdev: torch.Tensor | None = None, device: torch.device | None = None)[source]

Bases: evox.core.Algorithm

The basic CSO algorithm.

Class Methods

  • __init__: Initializes the CSO algorithm with given parameters.

  • setup: Initializes the CSO algorithm with given lower and upper bounds for particle positions, and sets up initial population, velocity, and buffers for tracking best local and global positions and fitness values.

  • step: Performs a single optimization step using CSO, updating local best positions and fitness values, and adjusting velocity and positions based on inertia, cognitive, and social components.

Note that the evaluate method is not defined in this class, it is a proxy function of Problem.evaluate set by workflow; therefore, it cannot be used in class methods other than step.

Initialization

Initialize the CSO algorithm with the given parameters.

Parameters:
  • pop_size – The size of the population.

  • lb – The lower bounds of the particle positions. Must be a 1D tensor.

  • ub – The upper bounds of the particle positions. Must be a 1D tensor.

  • phi – The inertia weight. Defaults to 0.0.

  • mean – The mean of the normal distribution. Defaults to None.

  • stdev – The standard deviation of the normal distribution. Defaults to None.

  • device – The device to use for the tensors. Defaults to None.

init_step()[source]
step()[source]

Perform a single optimization step using CSO.

This function updates the position and velocity of each particle in the population using the CSO algorithm. The CSO algorithm is an optimization algorithm that uses a combination of both the PSO and the DE algorithms to search for the optimal solution.