Week 9 Computational Intelligence: Particle Swarm Optimization Mudrik Alaydrus Faculty of Computer Sciences University of Mercu Buana, Jakarta mudrikalaydrus@yahoo.com Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 1
Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 2
What we will learn today : Single Search versus PSO Origin and Idea Basic Procedure Examples Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 3
SS Vs PSO Single Search Particle Swarm Optimization (PSO) Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 4
How can birds or fish exhibit such a coordinated collective behavior? Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 5
Reynolds proposed a behavioral model in which each agent follows three rules: Separation (collision avoidance) Each agent tries to move away from its neighbors if they are too close. Alignment (velocity matching) Each agent steers towards the average heading of its neighbors. Cohesion (centering) Each agent tries to go towards the average position of its neighbors. Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 6
Examples: http://www.bekkoame.ne.jp/~ishmnn/java/boid.html http://www.bekkoame.ne.jp/~ishmnn/java/boid2.html http://www.bekkoame.ne.jp/~ishmnn/java/boid3.html http://hp.vector.co.jp/authors/va009508/java/boids/boids.html Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 7
Particle Swarm Optimization Inventors : James Kennedy and Russell Eberhart An Algorithm originally developed to imitate the motion of a Flock of Birds, or insects Assumes Information Exchange (Social Interactions) among the search agents Basic Idea: Keep track of Global Best Self Best Presentasi 8Mudrik Alaydrus 8
Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 9
1. Create a population of agents (called particles) uniformly distributed over X. 2. Evaluate each particle s position according to the objective function. 3. If a particle s current position is better than itsprevious best position, update it. 4. Determine the best particle (according to the particle s previous best positions). 5. Update particles velocities according to v new = w rand v old + sc rand ( x x) + cc rand ( x x) selfbest globalbest Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 10
6. Move particles to their new positions according to 7. Go to step 2 until stopping criteria are satisfied. Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 11
Almost all modifications vary in some way the velocity-update rule: inertia v new = w rand v old + sc rand ( x x) + cc rand ( x x) selfbest globalbest Personal influence (Self consciousness) social influence (collective consciousness) Presentasi Mudrik Alaydrus 8Mudrik Alaydrus Presentasi 8 Fasilkom, UMB 12
PSO Modeling Each solution vector is modeled as The coordinates of a bird or a particle in a swarm flying through the search space All the particles have a non-zero velocity and thus never stop flying and are always sampling new regions. Each particle remembers Where the global best and where the local best are. The search is guided by The collective consciousness of the swarm Introducing randomness into the dynamics in a controlled manner Presentasi 8Mudrik Alaydrus 13
%% Initialization N=10; iterations = 30; inertia = 1.0; sc = 1.0; %self consciousness cc = 1.0; %collective swarm_size = N*N; % ---- initial swarm position ----- index = 1; for i = 1 : N for j = 1 : N swarm(index, 1, 1) = i; swarm(index, 1, 2) = j; index = index + 1; end end swarm(:, 4, 1) = 1000; % best value so far swarm(:, 2, :) = 0; % initial velocity Presentasi 8Mudrik Alaydrus 14
%% Iterations for iter = 1 : iterations %-- evaluating position & quality --- for i = 1 : swarm_size swarm(i, 1, 1) = swarm(i, 1, 1) + swarm(i, 2, 1)/1.3; %update x position swarm(i, 1, 2) = swarm(i, 1, 2) + swarm(i, 2, 2)/1.3; %update y position x = swarm(i, 1, 1); y = swarm(i, 1, 2); val = (x - 15)^2 + (y - 20)^2; if val < swarm(i, 4, 1) % if new position is better swarm(i, 3, 1) = swarm(i, 1, 1); % update best x, swarm(i, 3, 2) = swarm(i, 1, 2); % best y postions swarm(i, 4, 1) = val; % and best value end end [temp, gbest] = min(swarm(:, 4, 1)); % global best position %--- updating velocity vectors for i = 1 : swarm_size swarm(i, 2, 1) = rand*inertia*swarm(i, 2, 1) + sc*rand*(swarm(i, 3, 1) - swarm(i, 1, 1)) + cc*rand*(swarm(gbest, 3, 1) - swarm(i, 1, 1)); swarm(i, 2, 2) = rand*inertia*swarm(i, 2, 2) + sc*rand*(swarm(i, 3, 2) - swarm(i, 1, 2)) + cc*rand*(swarm(gbest, 3, 2) - swarm(i, 1, 2)); end end Presentasi 8Mudrik Alaydrus 15
Presentasi 8Mudrik Alaydrus 16