Sie sind auf Seite 1von 17

PSO Lecture

PARTICLE SWARM OPTIMIZATION

PSO

PSO Lecture Outline

Outline
Hystorical note Recapitulation and terminology PSO
Origin Basics Terminology Flowchart and code Numerical experiments

The missing details Conclusions

PSO Lecture Hystorical note

Hystorical note
1995, IEEE Spectrum

Codenamed P6, the Intel Pentium Pro was released by Intel in November 1995 and contained 5.5 million transistors, was available in clock speeds of 150MHz to 200MHz, and was the first Intel processor that utilized the i686 architecture.

PSO Lecture Recapitulation and terminology

Recapitulation and terminology


Optimization (minimization, optimal design, inverse pb.,) Variables (degrees of freedom, parameters, (derivatives?)) Objectives (objective functions, quality, fitness, ) Constraints (equality, inequality, feasible, unfeasible, ) Minimum (local, global, sensitivity, robustness, ) Analysis (forward problem, cheap/expensive)

Did I forget something ?

PSO Lecture Recapitulation and terminology

Recapitulation and terminology


Curse of dimensionality
2 D.O.F. 3 D.O.F. 10 D.O.F.

?
32=9 (9 sec.)! ! 102=100 (ca. 1,5 min) 33=27 (ca. 0,5 min)! ! 103=1.000 (ca. 15 min) 310=59.049 (ca. 16,5 hrs.)! ! 1010=... (ca. 317 yrs.)

No-free-lunch theorem
D. H. Wolpert and W.G. Macready, "No Free Lunch Theorems for Optimization," IEEE Transactions on Evolutionary Computation 1, pp. 67, 1997. any two optimization algorithms are equivalent when their performance is averaged across all possible problems BUT: we do not try to solve ALL possible problems, only a domain-specific subset !
5

PSO Lecture PSO Origins

Origins
J. Kennedy and R. Eberhart, "Particle Swarm Optimization, Proc. of IEEE International Conf. on Neural Networks IV, pp. 19421948, 1995.
Russel Ebenhart (Electrical Engineer) and James Kennedy (Social Psychologist) in 1995 (both U. Indiana, Purdue). Categories: Swarm Intelligence techniques and Evolutionary Algorithms for optimization. Inspired by the social behavior of birds, studied by Craig Reynolds (a biologist) in late 80s and early 90s. He derived a formula for representation of the flocking behavior of birds. This was later used in computer simulations of virtual birds, known as Boids. Ebenhart and Kennedy recognized the suitability of this technique for optimization

In ES population members derive from each other but do not exchange information, in PSO they do!
6

PSO Lecture PSO Basics

Basics
Main idea: Mimic bird flocking or fish schooling
Nature Birds or fish Explore the environment (3d) in search for food Exchange information by acoustical or optical means Algorithm Particles Explore objective space (Nd) in search for good function values Exchange information by sharing positions of promising locations

Basic models of flocking behavior are controlled by three simple rules: Separation - avoid crowding neighbors (short range repulsion) Alignment - steer towards average heading of neighbors Cohesion - steer towards average position of neighbors (long range attraction)
7

PSO Lecture PSO Terminology

Terminology
Particles Velocities Personal best Global best

5 4 3 2 1

50 45 40 35 30

0 25 1 2 3 4 5 5 20 15 10 5

Particles: x i Velocities: v i Personal best positions ever: p i Global best position ever: g best

PSO Lecture PSO Flowchart

Flowchart
Alg. params.:
n w, c1, c2

Initialize population of n particles ! with random ! positions xi and velocities vi

For each particle:! 1) Evaluate tness f(xi)! 2) If new personal best set pi=xi ! For the whole population:! 1) Identify global best pg

Velocity and position update:

Inertial component ! Cognitive component Social component

v i ( t + 1) = w" v i (t ) + c1 " ud " [pi (t ) # x i ( t )] + c 2 " Ud " [pg (t ) # x i ( t )]


!x ( t + 1) = x (t ) + "t # v (t + 1) !
i i i

! !
Convergence ?

Random numbers in [0,1]

PSO Lecture PSO Code

Code
Matlab

1 clear all; close all; clc 2 %Function to be minimized 3 D=2; 4 objf=inline(4*x1^22.1*x1^4+(x1^6)/3+x1*x24*x2^2+4*x2^4,x1,x2); 5 objf=vectorize(objf); 6 %Initialization of PSO parameters 7 N=20; %population size (total function evaluations will be itmax*N) 8 itmax=30; 9 c1=1.05; c2=1.05; 10 wmax=1; wmin=0.3; %set to same value for constant w 11 w=linspace(wmax,wmin,itmax); %linear variation of w 12 %Problem and velocity bounds 13 a(1:N,1)=1.9; b(1:N,1)=1.9; %bounds on variable x1 14 a(1:N,2)=1.1; b(1:N,2)=1.1; %bounds on variable x2 15 d=(ba); 16 m=a; n=b; 17 q=(nm)/4; %initial velocities are 1/4 of parameter space size 18 %Random initialization of positions and velocities 19 x=a+d.*rand(N,D); 20 v=q.*rand(N,D); 21 %Evaluate objective for all particles 22 f=objf(x(:,1),x(:,2)); 23 %Find gbest and pbest (in this case coincides with x) 24 [fgbest,igbest]=min(f); 25 gbest=x(igbest,:); 26 pbest=x; fpbest=f; 27 %Iterate 28 for it=1:itmax; 29 %Update velocities and positions 30 v(1:N,1:D)=w(it)*v(1:N,1:D)+c1*rand*(pbest(1:N,1:D)x(1:N,1:D)) +c2*rand*(repmat(gbest,N,1)x(1:N,1:D)); 31 x(1:N,1:D)=x(1:N,1:D)+v(1:N,1:D); 32 %Evaluate objectives 33 f=objf(x(:,1),x(:,2)); 34 %Find gbest and pbest 35 [minf,iminf]=min(f); 36 if minf<= fgbest 37 fgbest=minf; gbest=x(iminf,:); 38 end 39 inewpb=find(f<=fpbest); 40 pbest(inewpb,:)=x(inewpb,:); fpbest(inewpb)=f(inewpb); 41 end %end loop on iterations 42 [gbest,fgbest]

Please note that this code actually works !

10

PSO Lecture PSO Numerical experiments

Benchmark
Six hump camel back
160 140 200 150 120 100

5 6 5 4
f(x1,x2)

f(x1,x2)

100 50 0 50 2 1 0 1 x2 2 4 2 x1 2 0 4

3 2 1

80 60 40 20 0

0 1 2 1 0 1 x2
1 0.8 0.6 0.4 4

1 2 1 0 1 2 2 x1

f(x1,x2)=4x12-2.1x14+x16/3+x1x2-4x22+4x24 x1*=-0.089842, x2*=0.712656 x1*=0.089842, x2*=-0.712656 f*=-1.031628453 Global Local

0.2 0 0.2 0.4

1 0.6 0.8 1 1.5 1 0.5 0 0.5 1 1.5 0

11

PSO Lecture PSO Numerical experiments


1
1 0.8 0.6 0.4 0.2 0 0.2 0.4

What happens if
Inertia (1000 runs, |fopt-f*| )
w 1) 2) 3) 4) 5) 6) 7) 0,1 0,5 1,0 2,0 N. 20 20 20 20 Iter. Tot. Max. 30 30 30 30 30 30 30 600 8,4 E-01 600 8,2 E-02 600 2,4 E-01 600 1,0 E-00 600 1.5 E-02 600 6,9 E-04 600 5,0 E-03

0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1

a)
1.5 1 0.5 0 0.5 1 1.5

0.6 0.8 1

b)
1.5 1 0.5 0 0.5 1 1.5

Avg.

Min.

Std. Dev. 8,6 E-02 (b) 4,5 E-02 1,2 E-02 1,6 E-01 8,7 E-04 3,3 E-05 (a) 1,7 E-04

3,2 E-02 1,4 E-11 2,4 E-03 1,5 E-12 5,0 E-03 9,8 E-07 1,6 E-01 1,1 E-04 1,4 E-04 6,1 E-09 4,7 E-06 4,6 E-12 8,1 E-06 2,8 E-12

10,5 20 10,3 20 10,1 20

c1 = c2 = 1,05 vini= x/4

Case 6) has best worst case, best results on average, and is the most robust (lowest standard deviation) !

12

PSO Lecture PSO Numerical experiments


0.95 0.9

What happens if
Population size (1000 runs, |fopt-f*| )
N. 1) 2) 3) 4) 5) 40 30 20 10 5 Iter. 15 20 30 60 120 Tot. 600 600 600 600 600

1 0.8 0.6 0.4

0.85 0.8 0.75

0.2 0 0.2

0.7 0.65

0.4 0.6 0.8 1 1.5 1 0.5 0 0.5 1

0.6 0.55
1.5 0.5

Max. 2,2 E-03 1,4 E-02 2,1 E-02 8,2 E-01 9,9 E-01

Avg. 3,2 E-05 2,3 E-05 2,0 E-05 8,9 E-04 7,5 E-03

Min. 0.5 3,0 E-10 1,3 E-10 5,2 E-12 5,0 E-12 1,8 E-11

0.4

0.3 0.2 0.1 Std. Dev.

0.1

0.2

1,4 E-04 4,6 E-04 4,7 E-04 2,6 E-02 7,2 E-02

c1 = c2 = 1,05 w = lin. from 1,0 to 0,3 vini= x/4

Small populations (red cross in figures) dont perform well. Cases 1), 2) and 3) work well. Case 3) will be used in the following.

13

PSO Lecture PSO Numerical experiments

What happens if
Cognitive component (1000 runs, |fopt-f*| )
c1 0,0 0,5 1,05 1,5 2,0 N. 20 20 20 20 20 Iter. 30 30 30 30 30 Tot. 600 600 600 600 600 Max. 6,9 E-03 1,9 E-02 2,5 E-01 8,6 E-01 6,2 E-02 Avg. 1,9 E-05 2,5 E-05 2,6 E-04 8,3 E-04 1,6 E-03 Min. 1,5 E-12 6,2 E-13 2,1 E-11 8,6 E-13 1,4 E-11 Std. Dev. 4,4 E-04 6,1 E-04 8,0 E-03 2,6 E-02 3,9 E-02

c2 = 1,05 w = lin. from 1,0 to 0,3 vini= x/4

It seems that it would be better not to have the cognitive component at all (c1=0) but wait for next slide
14

PSO Lecture PSO Numerical experiments

What happens if
Social component (1000 runs, |fopt-f*| )
c2 0,0 0,5 1,05 1,5 2,0 N. 20 20 20 20 20 Iter. 30 30 30 30 30 Tot. 600 600 600 600 600 Max. 3,7 E-01 1,1 E-01 1,6 E-02 4,1 E-03 1,6 E-01 Avg. 1,5 E-02 2,2 E-03 2,3 E-04 2,1 E-05 4,0 E-04 Min. 2,2 E-07 4,5 E-09 1,1 E-10 2,5 E-11 3,4 E-11 Std. Dev. 3,2 E-02 3,9 E-03 5,3 E-04 2,0 E-04 5,5 E-03

c1 = 1,05 w = lin. from 1,0 to 0,3 vini= x/4

The combined analysis of this and the preceeding table shows that c2 should be bigger than c1, but not too much
15

PSO Lecture The missing pieces

The missing pieces


What happens if a particle flies out of the parameter space?
Mirroring (a1) Loop around (a2) Random (a3)

a1

a2

What happens if a particle violates constraints an becomes unfeasible?


Discard (b1) Keep (b2)

a3

b1

R.I.P.

Integer/discrete variables Adaptivity and different random number distributions

b2
16

PSO Lecture Conclusions

Conclusions
PSO algorithm basics introduced Ease of Matlab implementation shown Numerical experiments:
Inertia should be linearly decreasing between 1 and 0,3 Population size matters (N between 20 and 30) c2=c1+,with between 1 and 1,5

Thanks for attending See you next time !

17

Das könnte Ihnen auch gefallen