tidy3d.plugins.design.MethodParticleSwarm#
- class MethodParticleSwarm[source]#
Bases:
MethodOptimize,ABCA standard method for performing particle swarm search, build around the PySwarms package. The fitness function is maximising by default.
- Parameters:
name (Optional[str] = None) – Optional name for the sweep method.
seed (Optional[PositiveInt] = None) – Set the seed used by the optimizers to ensure consistant random number generation.
n_particles (PositiveInt) – The number of particles to be used in the swarm for the optimization.
n_iter (PositiveInt) – The maxmium number of iterations to run the optimization.
cognitive_coeff (PositiveFloat = 1.5) – The cognitive parameter decides how attracted the particle is to its previous best position.
social_coeff (PositiveFloat = 1.5) – The social parameter decides how attracted the particle is to the global best position found by the swarm.
weight (PositiveFloat = 0.9) – The weight or inertia of particles in the optimization.
ftol (Union[float, Literal[-inf]] = -inf) – Relative error in
objective_func(best_solution)acceptable for convergence. See the PySwarms docs for details. Off by default.ftol_iter (PositiveInt = 1) – Number of iterations over which the relative error in the objective_func is acceptable for convergence.
init_pos (Optional[ndarray] = None) – Set the initial positions of the swarm using a numpy array of appropriate size.
Example
>>> import tidy3d.plugins.design as tdd >>> method = tdd.MethodParticleSwarm(n_particles=5, n_iter=3)
Attributes
- n_particles#
- n_iter#
- cognitive_coeff#
- social_coeff#
- weight#
- ftol#
- ftol_iter#
- init_pos#