metaheuristic_designer.strategies.swarm.PSO#

class PSO(initializer, lower_bound=-100, upper_bound=100, name='PSO', w=0.7, c1=1.5, c2=1.5, encoding=None, rng=None, **kwargs)[source]#

Particle Swarm Optimization (PSO).

Each individual (particle) has a position and a velocity. The velocity is updated using personal and global bests, and the position is moved accordingly. This requires a ParameterExtendingEncoding that stores a speed vector; if not supplied, a default PSOEncoding is created.

Parameters:
initializerInitializer

Initializer for the solution part. An ExtendedInitializer is automatically created to handle the velocity parameter.

lower_boundfloat, optional

Lower bound of the search space (default -100).

upper_boundfloat, optional

Upper bound of the search space (default 100).

namestr, optional

Display name (default "PSO").

wfloat, optional

Inertia weight (default 0.7).

c1float, optional

Cognitive acceleration coefficient (default 1.5).

c2float, optional

Social acceleration coefficient (default 1.5).

encodingParameterExtendingEncoding, optional

Encoding that includes a "speed" parameter. If None, a PSOEncoding is used.

rngRNGLike, optional

Random number generator.

**kwargs

Forwarded to StaticPopulationStrategy.

Attributes:
params

Access parameter values by attribute-style lookup.

population_size

Gets the amount of individuals in the population.

Parameters:

Methods

reset

__init__(initializer, lower_bound=-100, upper_bound=100, name='PSO', w=0.7, c1=1.5, c2=1.5, encoding=None, rng=None, **kwargs)[source]#
Parameters:

Methods

__init__(initializer[, lower_bound, ...])

extra_report()

Hook called at the end of the optimization (intended for subclasses).

extra_step_info()

Hook called after each generation (intended for subclasses).

gather_parameters()

Collect the current parameters from all sub-components.

get_params()

Return a copy of the current parameter dictionary.

get_state()

Gets the current state of the search strategy as a dictionary.

initialize(objfunc)

Set up the initial population and attach velocity constraints.

reset(objfunc)

step(prev_population, objfunc)

Performs a single iteration of the algorithm on a given population.

store_kwargs([progress])

Store keyword arguments and evaluate them at the given progress.

update(progress)

Advances the state of the search by one iteration.

update_kwargs([progress])

Add or replace parameters and immediately evaluate them.