piglot.optimisers.pso.GlobalBestPSOMod
- class GlobalBestPSOMod(**kwargs)[source]
Bases:
Missing_pyswarmsMethods
Evaluate particles using the objective function
Optimize the swarm for a number of iterations
Attributes
namepackage- compute_objective_function(swarm, objective_func, pool=None, **kwargs)[source]
Evaluate particles using the objective function
This method evaluates each particle in the swarm according to the objective function passed.
If a pool is passed, then the evaluation of the particles is done in parallel using multiple processes.
Parameters
- swarmpyswarms.backend.swarms.Swarm
a Swarm instance
- objective_funcfunction
objective function to be evaluated
- pool: multiprocessing.Pool
multiprocessing.Pool to be used for parallel particle evaluation
- kwargsdict
arguments for the objective function
Returns
- numpy.ndarray
Cost-matrix for the given swarm
- optimize(optimiser, objective_func, iters, n_processes=None, verbose=False, **kwargs)[source]
Optimize the swarm for a number of iterations
Performs the optimization to evaluate the objective function
ffor a number of iterationsiter.Parameters
- objective_funccallable
objective function to be evaluated
- itersint
number of iterations
- n_processesint
number of processes to use for parallel particle evaluation (default: None = no parallelization)
- verbosebool
enable or disable the logs and progress bar (default: True = enable logs)
- kwargsdict
arguments for the objective function
Returns
- tuple
the global best cost and the global best position.