saealib.PSO#
- class saealib.PSO(w=0.7, c1=1.5, c2=1.5, v_max=None)[source]#
Bases:
AskTellAlgorithmParticle Swarm Optimization (PSO) for single-objective problems.
The global best (leader) is selected from the personal bests of all particles using
ctx.comparator, so the ranking adapts automatically to any single-objective Comparator.Multi-objective PSO (MOPSO) requires a dedicated subclass with a separate Pareto archive for leader selection.
- Parameters:
w (float)
c1 (float)
c2 (float)
v_max (float | None)
- w#
Inertia weight.
- Type:
float
- c1#
Cognitive coefficient (personal best attraction).
- Type:
float
- c2#
Social coefficient (global best attraction).
- Type:
float
- v_max#
Maximum velocity magnitude per dimension.
Nonedisables clamping.- Type:
float or None
References
[38]: Kennedy, J., & Eberhart, R. (1995). Particle swarm optimization. Proceedings of the IEEE International Conference on Neural Networks (ICNN), 4, 1942-1948.
[39]: Shi, Y., & Eberhart, R. (1998). A modified particle swarm optimizer. Proceedings of the IEEE International Conference on Evolutionary Computation (ICEC), 69-73. (Introduces the inertia weight
wused here.)
Methods
Initialize PSO. |
|
Update particle velocities and positions. |
|
Return the PSO contract with comparator-backed feedback. |
|
Create a ParetoArchive with the correct direction for the problem. |
|
Return PSO-specific attributes required by the Population. |
|
Update the population and personal bests from evaluated offspring. |
Method Details
- PSO.__init__(w=0.7, c1=1.5, c2=1.5, v_max=None)[source]#
Initialize PSO.
- Parameters:
w (float, optional) – Inertia weight. Defaults to 0.7.
c1 (float, optional) – Cognitive coefficient. Defaults to 1.5.
c2 (float, optional) – Social coefficient. Defaults to 1.5.
v_max (float or None, optional) – Maximum velocity per dimension. Defaults to
None(no clamping).
- PSO.ask(request, state)[source]#
Update particle velocities and positions.
- Parameters:
request (ProposalRequest) – Request-specific offspring count; PSO uses its population size.
state (StateView) – Read-only algorithm state view.
- Returns:
Candidates with updated
xandvelocity.- Return type:
- PSO.create_pareto_archive(attrs, init_capacity, problem)#
Create a ParetoArchive with the correct direction for the problem.
- Parameters:
attrs (list[PopulationAttribute])
init_capacity (int)
problem (Problem)
- Return type:
- PSO.get_required_attrs(problem)[source]#
Return PSO-specific attributes required by the Population.
- Parameters:
problem (Problem) – The Problem object being referenced.
- Returns:
velocity, pbest_x, pbest_f, and pbest_cv attributes.
- Return type:
list[PopulationAttribute]
- PSO.tell(feedback, state)[source]#
Update the population and personal bests from evaluated offspring.
- Parameters:
feedback (FeedbackBatch) – Feedback delivered for the current proposal.
state (StateView) – Read-only algorithm state view.
- Return type: