metaheuristic_designer.strategies.swarm package

Submodules

metaheuristic_designer.strategies.swarm.PSO module

Particle Swarm Optimization strategy.

class PSO(initializer: Initializer, lower_bound: float = -100, upper_bound: float = 100, name: str = 'PSO', w=0.7, c1=1.5, c2=1.5, encoding: ParameterExtendingEncoding | None = None, random_state: int | Generator | None = None, **kwargs)[source]

Bases: StaticPopulation

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:
  • initializer (Initializer) – Initializer for the solution part. An ExtendedInitializer is automatically created to handle the velocity parameter.

  • lower_bound (float, optional) – Lower bound of the search space (default -100).

  • upper_bound (float, optional) – Upper bound of the search space (default 100).

  • name (str, optional) – Display name (default "PSO").

  • w (float, optional) – Inertia weight (default 0.7).

  • c1 (float, optional) – Cognitive acceleration coefficient (default 1.5).

  • c2 (float, optional) – Social acceleration coefficient (default 1.5).

  • encoding (ParameterExtendingEncoding, optional) – Encoding that includes a "speed" parameter. If None, a PSOEncoding is used.

  • random_state (RNGLike, optional) – Random number generator.

  • **kwargs – Forwarded to StaticPopulation.

initialize(objfunc: ObjectiveFunc)[source]

Set up the initial population and attach velocity constraints.

Parameters:
  • objfunc (ObjectiveFunc) – The objective function. Its constraint handler is extended with a BounceBoundConstraint for the velocity so that speeds stay within the feasible range.

  • warning:: (..)

  • bug (There is a known)

  • after (automatically remove the extended constraint handler)

  • function (a PSO run finishes. Reusing the same objective)

  • unexpected (instance for other algorithms may cause)

  • release. (behaviour. This will be resolved in a future)

Returns:

The initialised and evaluated population.

Return type:

Population

Module contents

Swarm intelligence strategies.

class PSO(initializer: Initializer, lower_bound: float = -100, upper_bound: float = 100, name: str = 'PSO', w=0.7, c1=1.5, c2=1.5, encoding: ParameterExtendingEncoding | None = None, random_state: int | Generator | None = None, **kwargs)[source]

Bases: StaticPopulation

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:
  • initializer (Initializer) – Initializer for the solution part. An ExtendedInitializer is automatically created to handle the velocity parameter.

  • lower_bound (float, optional) – Lower bound of the search space (default -100).

  • upper_bound (float, optional) – Upper bound of the search space (default 100).

  • name (str, optional) – Display name (default "PSO").

  • w (float, optional) – Inertia weight (default 0.7).

  • c1 (float, optional) – Cognitive acceleration coefficient (default 1.5).

  • c2 (float, optional) – Social acceleration coefficient (default 1.5).

  • encoding (ParameterExtendingEncoding, optional) – Encoding that includes a "speed" parameter. If None, a PSOEncoding is used.

  • random_state (RNGLike, optional) – Random number generator.

  • **kwargs – Forwarded to StaticPopulation.

initialize(objfunc: ObjectiveFunc)[source]

Set up the initial population and attach velocity constraints.

Parameters:
  • objfunc (ObjectiveFunc) – The objective function. Its constraint handler is extended with a BounceBoundConstraint for the velocity so that speeds stay within the feasible range.

  • warning:: (..)

  • bug (There is a known)

  • after (automatically remove the extended constraint handler)

  • function (a PSO run finishes. Reusing the same objective)

  • unexpected (instance for other algorithms may cause)

  • release. (behaviour. This will be resolved in a future)

Returns:

The initialised and evaluated population.

Return type:

Population