particle swarm optimization - university of...

34
Particle Swarm Optimization Dario Schor, M.Sc., EIT [email protected] Space Systems Department Magellan Aerospace Winnipeg Winnipeg, Manitoba Particle Swarm Optimization (April 16, 2015) 1 of 34

Upload: dokhanh

Post on 21-May-2018

228 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Particle Swarm Optimization

Dario Schor, M.Sc., EIT [email protected]

Space Systems Department

Magellan Aerospace Winnipeg Winnipeg, Manitoba

Particle Swarm Optimization (April 16, 2015) 1 of 34

Page 2: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Motivation •  Optimization:

Where, –  g(x) represents constraints on the parameters. –  F(x) knowledge:

•  With prior knowledge, we can select appropriate techniques to find a solution quickly and efficiently.

–  E.g., Using gradient based techniques of unimodal functions. •  Without prior knowledge, the parameter space is too large to evaluate

all options, so heuristics are needed to find “good” solutions efficiently.

Optimization Techniques

min x F(x), subject to g(x) = 0

Particle Swarm Optimization (April 16, 2015) 2 of 34

Page 3: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Motivation •  Particle Swarm Optimization (PSO)

–  Evolutionary algorithm modeled after schools of fish and flocks of birds.

–  Iterative algorithm where particles move through a parameter space looking for a “good” solution.

–  At each step, the movement is based on a weighted sum between the personal knowledge of a particle and the collective knowledge of the swarm.

Particle Swarm Optimization

Particle Swarm Optimization (April 16, 2015) 3 of 34

Page 4: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Motivation •  Test Functions

–  There are many different kinds of evolutionary algorithms like genetic algorithms, simulated annealing, ant colony optimization, and PSO. What’s different in each one?

–  There are many different implementations for a single algorithm; •  How do you compare the different implementations? •  How do you pick which implementation to use?

–  A common approach is to use a set of benchmark functions (i.e., Sphere, Rastrigin, Griewank, and Rosenbrock).

Verifying Algorithms

Particle Swarm Optimization (April 16, 2015) 4 of 34

Page 5: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Outline •  Motivation •  Particle Swarm Optimization

–  Original algorithm –  Some variations

•  Demonstration –  Simulation in 2D using NetLogo

•  Experiments –  Benchmark functions

•  Concluding Remarks

A Study of PSO Trajectories for Real-Time Scheduling

Particle Swarm Optimization (April 16, 2015) 5 of 34

Page 6: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Particle Swarm Optimization (1 of 2) •  Model behavior of schools of fish and birds [KeEb95]

•  A set of SK particles are randomly distributed within the parameter space.

•  The particles traverse through a K-dimensional space looking for an optimal solution.

•  At each iterations, n, the particles update their position based on their personal and social knowledge.

Original PSO Algorithm

Particle Swarm Optimization (April 16, 2015) 6 of 34

Page 7: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Particle Swarm Optimization (2 of 2) •  Movement of particles based on [KeEb01]

Original PSO Algorithm

where,Sx,k , Sv,k , S p,k Position, velocity, and best positionSϕ1, Sϕ 2

Sp,g Personal, and social weightsBest position in neighbourhood

Sv,k n( ) = Sv,k n −1( ) +Sϕ1 × random(0,1)× S p,k − Sx,k n −1( )( ) +Sϕ 2 × random(0,1)× S p,g − Sx,k n −1( )( )

Sx,k n( ) = Sx,k n −1( ) + Sv,k n( )

Personal influence (2)

Social influence (3)

Update position (4)

Update velocity (1)

Particle Swarm Optimization (April 16, 2015) 7 of 34

Page 8: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Particle Swarm Optimization (2 of 2) •  The steps are updated independently for each of the K

dimensions in the problem. •  The step is determined based on:

1.  Update velocity •  This serves as an “inertial force” that encourages particles to

continue moving in the direction they were already going. 2.  Personal influence

•  Memory of the particle from previous individual best solution found. 3.  Social influence

•  Memory and knowledge from the community/swarm. 4.  Update position

•  Increments the current position along one dimension.

Original PSO Algorithm

Particle Swarm Optimization (April 16, 2015) 8 of 34

Page 9: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Implementation •  Initialization:

–  Randomly select starting position and velocities. –  Usually constrained to a range based on empirical testing.

Original PSO Algorithm

Particle Swarm Optimization (April 16, 2015) 9 of 34

Page 10: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Implementation •  Main loop:

Original PSO Algorithm

Result of velocity equation.

Result of position equation.

Particle Swarm Optimization (April 16, 2015) 10 of 34

Page 11: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Population Size •  Intuitively:

–  More particles = greater exploration of the parameter space. –  More particles = more resources to execute algorithm.

•  Recommended sizes in literature are [20, 100] –  Requires testing within the specified problem space to evaluate.

•  Directly linked to the type of topology used.

PSO Variations

Particle Swarm Optimization (April 16, 2015) 11 of 34

Page 12: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Neighborhood Topologies •  Social knowledge derived from neighborhood

topology used [ScKA10] •  Divided into global (gBest) and local (lBest) topologies

–  gBest can converge faster, but may get stuck in a local minimum

PSO Variations

gBest lBest ring

lBest star

lBest torus

lBest hierarchical

Particle Swarm Optimization (April 16, 2015) 12 of 34

Page 13: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Limiting Step Size •  Required to prevent the velocity from growing too quickly.

–  The compounded step size could cause particles to diverge from the rest of the swarm.

•  Some options: 1.  Limit velocities using hard-coded values

•  Effective, but can lead to particles oscillating around the solution. Ideally, we want the step sizes to decrease as we approach the solution.

•  Picked based on expected range for solutions.

PSO Variations

Particle Swarm Optimization (April 16, 2015) 13 of 34

Page 14: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Limiting Step Size •  Some options continued:

2.  Use an inertial weight •  Like a temperature gradient in simulated annealing. •  Decreases a weight multiplier for the velocity from 0.9 to 0.4. •  Equation for the decrease is usually non-linear exponential decay. •  Although used in late 1990’s, this is seldom used today as it

introduces yet another parameter to vary in the problem. •  Furthermore, it is more susceptible to getting stuck in local solutions.

PSO Variations

Particle Swarm Optimization (April 16, 2015) 14 of 34

Page 15: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Limiting Step Size •  Some options continued:

3.  Using a constriction coefficient •  Derived from the eigenvalues such that they are real and non-

negative guaranteeing convergence. •  Commonly used in most PSO implementations.

PSO Variations

Particle Swarm Optimization (April 16, 2015) 15 of 34

Page 16: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Personal and Social Weights •  Initially picked at random in the range 0 to 1. •  Intuitively it is like any person:

–  Sometimes you have your own plans, and sometimes you go along with your friends and do something else.

•  A multiplier was added to help particles move faster towards the solution.

PSO Variations

Particle Swarm Optimization (April 16, 2015) 16 of 34

Page 17: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Stopping Criterion •  Different options:

–  Solution found satisfies problem constrains. –  All particles converge on an region. –  Best solution does not change for a few iterations in a row.

PSO Variations

Particle Swarm Optimization (April 16, 2015) 17 of 34

Page 18: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Demonstration •  NetLogo

–  Multi-agent programmable modeling environment. –  Developed by Dr. Uri Wilensky from Northwestern University. –  Software used in courses throughout North America such as the

Santa Fe Institute. –  Free to download from:

http://ccl.northwestern.edu/netlogo/index.shtml

Particle Swarm Optimization

Particle Swarm Optimization (April 16, 2015) 18 of 34

Page 19: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

NetLogo •  Allows you to create:

–  GUI to test parameters in a simulation.

–  Quick and easy to edit. –  Follows the 1980’s Logo

principles where a Turtle moves throughout the screen.

Demonstration

Particle Swarm Optimization (April 16, 2015) 19 of 34

Page 20: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Benchmark Functions •  In 1975, De Jong proposed a set of test functions for

characterizing and comparing the performance of different algorithms and their implementations.

•  The set of functions grown since then to incorporate other important features representative of real problems. –  E.g., Lots of local solutions, fast/slow gradients, deep peaks, etc.

•  These functions: –  Have known optimal values for comparison with calculated solution; –  Are non-linear and often multimodal; –  Do not have constraints on the variables; and –  The nominal trajectories of the particles will differ as they approach

the solution.

Test Functions

Particle Swarm Optimization (April 16, 2015) 20 of 34

Page 21: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Sphere Function •  Simplest equation in the set.

–  All points are monotonically decreasing towards the origin.

•  Given by equation:

•  Smooth and often used for comparing faster approaches. –  It is almost like testing a worst case sorted list with a sorting

algorithm to see whether your algorithm is still smart enough to handle it.

Benchmark Functions

Particle Swarm Optimization (April 16, 2015) 21 of 34

Page 22: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Benchmark Functions Sphere Function

Particle Swarm Optimization (April 16, 2015) 22 of 34

Page 23: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

•  Particles oscillate towards the solution [ScKi10] [ScKi11]

•  Two distinct behaviors: –  Transient –  Steady state

Sphere Trajectories Benchmark Functions

Particle Swarm Optimization (April 16, 2015) 23 of 34

Page 24: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Benchmark Functions

•  Select particle to study –  Fix particle initial conditions and run algorithm 200 times –  Nominal particle selected to minimize mean square error

Sphere Trajectories

0 100 200 300 400 500−25

−20

−15

−10

−5

0

5

Position trajectory for Sk=7 of 200 runs on G

1(x) function

Iteration

Posi

tion

TrajectoriesMean95% CI

410 420 430 440 450 460 470−1.5

−1

−0.5

0

0.5

1

1.5Zoomed in on trajectories

Iteration

Po

sitio

n

TrajectoriesMean95% CI

410 420 430 440 450 460 470−1.5

−1

−0.5

0

0.5

1

1.5Zoomed in on typical and worst behaviour

Iteration

Posi

tion

95% CITypical (run 91)Worst (run 6)

410 420 430 440 450 460 470−1.5

−1

−0.5

0

0.5

1

1.5Zoomed in on typical and worst behaviour

Iteration

Posi

tion

95% CITypical (run 91)Worst (run 6)

0 100 200 300 400 500−25

−20

−15

−10

−5

0

5

Position trajectory for Sk=7 of 200 runs on G

1(x) function

Iteration

Posi

tion

TrajectoriesMean95% CI

Particle Swarm Optimization (April 16, 2015) 24 of 34

Page 25: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Rastrigin Function •  Given by equation:

•  Shows envelope function that resembles the convex shape of the sphere to guide global search.

•  Many local solutions through the cosine function. •  Usually implemented in a small range (-5.12, 5.12).

Benchmark Functions

Particle Swarm Optimization (April 16, 2015) 25 of 34

Page 26: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Benchmark Functions Rastrigin Function

Particle Swarm Optimization (April 16, 2015) 26 of 34

Page 27: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

•  Particles oscillate towards the solution [ScKi10], [ScKi11].

•  Two distinct behaviors: –  Transient –  Steady state

Rastrigin Trajectories Benchmark Functions

Particle Swarm Optimization (April 16, 2015) 27 of 34

Page 28: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

0 100 200 300 400 500−1.5

−1

−0.5

0

0.5

1

Position trajectory for Sk=7 of 200 runs on G

1(x) function

Iteration

Posi

tion

TrajectoriesMean95% CI

Benchmark Functions

•  Select particle to study –  Fix particle initial conditions and run algorithm 200 times –  Nominal particle selected to minimize mean square error

Rastrigin Trajectories

410 420 430 440 450 460 470−1

−0.8−0.6−0.4−0.2

00.20.40.60.8

1Zoomed in on trajectories

Iteration

Posi

tion

TrajectoriesMean95% CI

0 100 200 300 400 500−25

−20

−15

−10

−5

0

5

Position trajectory for Sk=7 of 200 runs on G

1(x) function

Iteration

Posi

tion

TrajectoriesMean95% CI

Particle Swarm Optimization (April 16, 2015) 28 of 34

Page 29: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

More Benchmarks •  Rosenbrock

–  Smooth curves with mix of steep and gentle gradients. –  The gentle gradient makes it hard for some implementations.

•  E.g., Using an inertia weight to decrease the step size over time.

Benchmark Functions

From: http://www.sfu.ca/~ssurjano/rosen.html

Particle Swarm Optimization (April 16, 2015) 29 of 34

Page 30: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

More Benchmarks •  Ackley

–  Lots of local minima to get trapped without a significant global gradient to guide search.

–  Once you enter the big peak, you find the answer very quickly.

Benchmark Functions

From: http://www.sfu.ca/~ssurjano/ackley.html

Particle Swarm Optimization (April 16, 2015) 30 of 34

Page 31: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

More Benchmarks •  List arranged by type:

–  Has equation, graph, nominal range, and a description of the functions.

–  http://www.sfu.ca/~ssurjano/optimization.html

•  List of common functions: –  Has equation, graph, nominal range, description,

and MATLAB code for each function. –  http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/

Hedar_files/TestGO_files/Page364.htm

Benchmark Functions

Particle Swarm Optimization (April 16, 2015) 31 of 34

Page 32: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Picking Benchmarks •  Selection of benchmarks depends on:

–  Common functions used in the literature for the algorithm you are testing.

•  Ultimately, you want to compare your implementation/variation to the state-of-the-art.

–  Real-problem you are trying to solve (what is really representative)

•  These are two separate objectives: –  1st points at Comp Sci analysis of algorithms, and –  2nd points to Engineering solution.

It is a balancing act for selecting parameters.

Benchmark Functions

Particle Swarm Optimization (April 16, 2015) 32 of 34

Page 33: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

Concluding Remarks •  Particle Swarm is a powerful algorithm for solving

unconstrained optimization problems. –  Can be used for a variety of applications.

•  Benchmark functions provide a standardized comparison between implementations and variations of the algorithm.

Particle Swarm Optimization

Particle Swarm Optimization (April 16, 2015) 33 of 34

Page 34: Particle Swarm Optimization - University of Manitobaece.eng.umanitoba.ca/undergraduate/ECE4850T02/Lecture Slides/PSO... · Motivation • Particle Swarm Optimization (PSO) – Evolutionary

References [KeEb01] James Kennedy and Russell Eberhart, Swarm Intelligence, Morgan Kaufmann, 2001, 512pp. {ISBN

978-1558605954} [KeEb95] James Kennedy and Russell Eberhart, “Particle swarm optimization,” in Proc. of the IEEE

International Conference on Neural Networks, 1995, (Perth, WA, USA; November 27-December 1, 1995), vol. 4, pp. 1942–1948, 1995.

[Scho13] Dario Schor, “A Study of Particle Swarm Optimization Trajectories for Real-Time Scheduling”, MSc. Thesis. University of Manitoba, 2013.

[ScKA10] Dario Schor, Witold Kinsner, and John Anderson, “A Study of Optimal Topologies in Swarm Intelligence,” in Proc. of the IEEE Canadian Conference on Electrical and Computer Engineering, CCECE 2010, (Calgary, AB; May 2{5, 2010), pp. 1–8, 2010.

[ScKi10] Dario Schor and Witold Kinsner, “A Study of Particle Swarm Optimization for Cognitive Machines,” in Proc. of the 9th IEEE Intermational Conference on Cognitive Informatics, ICCI 2010, (Beijin, China; July 7–9, 2010), pp. 26–33, 2010.

[ScKi11] Dario Schor and Witold Kinsner, “Time and Frequency Analysis of Particle Swarm Trajectories for Cognitive Machines," International Journal of Cognitive Informatics and Natural Intelligence, vol. 5, no. 1, pp. 18–41, 2011.

Particle Swarm Optimization

Particle Swarm Optimization (April 16, 2015) 34 of 34