piglot.optimisers.pso.PSO
- class PSO(objective: Objective, n_part, options, oh_strategy=None, bh_strategy='periodic', velocity_clamp=None, vh_strategy='unmodified', center=1.0, ftol_iter=1, n_processes=None)[source]
Bases:
ScalarOptimiserPSO optimiser. Documentation: https://pyswarms.readthedocs.io/en/latest/_modules/pyswarms/single/global_best.html#GlobalBestPSO
Attributes
- n_partint
number of particles in the swarm.
options : dict with keys
{'c1', 'c2', 'w'}a dictionary containing the parameters for the specific optimization technique.- c1float
cognitive parameter
- c2float
social parameter
- wfloat
inertia parameter
- oh_strategydict, optional, default=None(constant options)
a dict of update strategies for each option.
- bh_strategystr
a strategy for the handling of out-of-bounds particles.
- velocity_clamptuple, optional
a tuple of size 2 where the first entry is the minimum velocity and the second entry is the maximum velocity. It sets the limits for velocity clamping.
- vh_strategystr
a strategy for the handling of the velocity of out-of-bounds particles.
- centerlist (default is
None) an array of size
dimensions- ftol_iterint
number of iterations over which the relative error in objective_func(best_pos) is acceptable for convergence. Default is
1- n_processesint
number of processes to use for parallel particle evaluation (default: None = no parallelization)
Methods
- _optimise(self, func, n_dim, n_iter, bound, init_shot):
Solves the optimization problem
Methods
Optimiser for the outside world.
- optimise(n_iter: int, parameters: ~piglot.parameter.ParameterSet, output_dir: str, stop_criteria: ~piglot.optimiser.StoppingCriteria = <piglot.optimiser.StoppingCriteria object>, verbose: bool = True) Tuple[float, ndarray]
Optimiser for the outside world.
Parameters
- objectiveObjective
Objective function to optimise.
- n_iterint
Maximum number of iterations.
- parametersParameterSet
Set of parameters to optimise.
- output_dirstr
Whether to write output to the output directory, by default None.
- stop_criteriaStoppingCriteria
List of stopping criteria, by default none attributed.
- verbosebool
Whether to output progress status, by default True.
Returns
- float
Best observed objective value.
- np.ndarray
Observed optimum of the objective.