src.baseline.bbo.sahlpso¶
Module Contents¶
Classes¶
Introduction¶Self-Adaptive two roles hybrid learn-ing strategies-based particle swarm optimization.It uses exploration-role and exploitation-role learning strategies with self-adaptively updating parameters manner. |
API¶
- class src.baseline.bbo.sahlpso.SAHLPSO(config)[source]¶
Bases:
src.environment.optimizer.basic_optimizer.Basic_OptimizerIntroduction¶
Self-Adaptive two roles hybrid learn-ing strategies-based particle swarm optimization.It uses exploration-role and exploitation-role learning strategies with self-adaptively updating parameters manner.
Original paper¶
“Self-Adaptive two roles hybrid learning strategies-based particle swarm optimization.” Information Sciences 578 (2021): 457-481.
Initialization
Introduction¶
Initializes the SAHLPSO (Self-Adaptive Hybrid Learning Particle Swarm Optimization) algorithm with the provided configuration parameters.
Args:¶
- config (object): Configuration object containing algorithm parameters. - The Attributes needed for the SAHLPSO optimizer in config are the following: - maxFEs (int): Maximum number of function evaluations allowed.Default value depends on the type of the problem. - n_logpoint (int): Number of log points for tracking progress. Default is 50. - log_interval (int): Interval at which logs are recorded. Default is maxFEs // n_logpoint. - full_meta_data (bool): Flag indicating whether to store complete solution history. Default is False. - seed (int): Random seed for reproducibility. Used for initializing positions and velocities.
Attributes:¶
NP (int): Number of particles in the swarm (default: 40).
lb (float): Lower bound for particle positions (default: -5).
ub (float): Upper bound for particle positions (default: 5).
v_max (float): Maximum velocity for particles (default: 1).
H_cr (int): Number of crossover rates (default: 5).
M_cr (list of float): List of crossover rates.
H_ls (int): Number of local search strategies (default: 15).
M_ls (range): Range of local search strategies.
LP (int): Learning period (default: 5).
Lg (float): Learning gain (default: 0.2).
p (float): Probability parameter (default: 0.2).
c1 (float): Cognitive acceleration coefficient (default: 1.49445).
log_interval (int): Logging interval, taken from
config.full_meta_data (bool): Flag indicating whether to store full meta data, taken from
config.
- __str__()[source]¶
Introduction¶
Returns the string representation of the SAHLPSO class.
Returns:¶
str: The string ‘SAHLPSO’.
- run_episode(problem)[source]¶
Introduction¶
Executes a single optimization episode using the Self-Adaptive History Learning Particle Swarm Optimization (SAHLPSO) algorithm on the provided problem instance. The method manages the population, velocity, and adaptive parameters, and logs the optimization progress.
Args:¶
problem (object): An optimization problem instance that must provide the following attributes and methods:
dim(int): Dimensionality of the problem.lb(array-like): Lower bounds for each dimension.ub(array-like): Upper bounds for each dimension.optimum(float or None): Known optimum value for the problem (optional).eval(X)(callable): Function to evaluate the fitness of a populationX.
Returns:¶
dict: A dictionary containing:
‘cost’ (list): The best cost (fitness) found at each logging interval.
‘fes’ (int): The total number of function evaluations performed.
‘metadata’ (dict, optional): If
self.full_meta_datais True, includes:‘X’ (list): History of population positions.
‘Cost’ (list): History of population costs.
Notes:¶
The method adapts crossover and learning strategies based on historical success rates.
Population size is dynamically reduced during the run.
Logging intervals and meta-data collection are controlled by the class configuration.