particle_swarm
particle_swarm(fun, lb, ub, n_particles=100, max_iter=100, momentum=0.9, phi=0.1, verbose=False, topology='full')
Particle swarm optimization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fun |
callable
|
Function to minimize |
required |
lb |
(n,) numpy double array
|
Vector of lower bounds |
required |
ub |
(n,) numpy double array
|
Vector of upper bounds |
required |
n_particles |
int, optional (default: 100)
|
Number of particles |
100
|
max_iter |
int, optional (default: 1000)
|
Maximum number of iterations |
100
|
topology |
str, optional (default: 'full')
|
Connectivity of the swarm. Either 'full' or 'ring'. |
'full'
|
verbose |
bool, optional (default: False)
|
Print progress to stdout |
False
|
Returns:
Name | Type | Description |
---|---|---|
x |
(n,) numpy double array
|
Best solution |
f |
double
|
Best objective value |
Source code in src/gpytoolbox/particle_swarm.py
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|