evox.algorithms.so.pso_variants.dms_pso_el
¶
Module Contents¶
Classes¶
The DMSPSOEL algorithm. |
API¶
- class evox.algorithms.so.pso_variants.dms_pso_el.DMSPSOEL(lb: torch.Tensor, ub: torch.Tensor, dynamic_sub_swarm_size: int = 10, dynamic_sub_swarms_num: int = 5, following_sub_swarm_size: int = 10, regrouped_iteration_num: int = 50, max_iteration: int = 100, inertia_weight: float = 0.7, pbest_coefficient: float = 1.5, lbest_coefficient: float = 1.5, rbest_coefficient: float = 1.0, gbest_coefficient: float = 1.0, device: torch.device | None = None)[source]¶
Bases:
evox.core.Algorithm
The DMSPSOEL algorithm.
Class Methods
__init__
: Initializes the DMSPSOEL algorithm with given parameters.setup
: Initializes the DMSPSOEL 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 DMSPSOEL, 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 ofProblem.evaluate
set by workflow; therefore, it cannot be used in class methods other thanstep
.Initialization
Initialize the DMSPSOEL algorithm with the given parameters.
- Parameters:
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.
dynamic_sub_swarm_size – The size of the dynamic sub-swarm. Defaults to 10.
dynamic_sub_swarms_num – The number of dynamic sub-swarms. Defaults to 5.
following_sub_swarm_size – The size of the following sub-swarm. Defaults to 10.
regrouped_iteration_num – The number of iterations for regrouping. Defaults to 50.
max_iteration – The maximum number of iterations. Defaults to 100.
inertia_weight – The inertia weight. Defaults to 0.7.
pbest_coefficient – The cognitive weight. Defaults to 1.5.
lbest_coefficient – The social weight. Defaults to 1.5.
rbest_coefficient – The social weight. Defaults to 1.0.
gbest_coefficient – The social weight. Defaults to 1.0.
device – The device to use for the tensors. Defaults to None.
- step()[source]¶
Perform a single step of the DMSPSOEL algorithm.
This function updates the population, velocity, personal best location, and personal best fitness based on the current fitness values. It also updates the local and global best positions and fitness values based on the dynamic sub-swarm and following sub-swarm. Finally, it updates the iteration count.