View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Particle Swarm Optimization Simulation

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.7 | 35 ratings Rate this file 67 Downloads (last 30 days) File Size: 12.7 KB File ID: #11559 Version: 1.1
image thumbnail

Particle Swarm Optimization Simulation


Wesam Elshamy (view profile)


27 Jun 2006 (Updated )

an animated simulation of particles searching for the minima of a simple function

| Watch this File

File Information

An animated simulation of Particles in 2D searching for a global minima of a simple function using Particle Swarm Optimization algorithm


This file inspired Particle Swarm Optimisation Augmented and Particle Swarm Optimization (Vectorized Code).

Required Products MATLAB
MATLAB release MATLAB 7.2 (R2006a)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (47)
26 Jun 2016 abbas issa

Hello, I'm looking for simple matlab code for PSO that can optimize the base station placement in mobile communication based particle swarm optimization

Comment only
28 Mar 2016 Obed Kondo

Hello Sir,
Please, can you help me with a matlab programme on finding optimal location of wells (drilling petroleum wells) using PSO?
My objective function is maximization of Net Present Value in drilling oil wells

Please, kindly help me

Thank you

Comment only
27 Mar 2016 abdulfeta mehammed

i need the code for placement and sizing of DG using PSO can u help me pleas.

Comment only
27 Mar 2016 abdulfeta mehammed

i need the code for placement and sizing of DG can u help me pleas

Comment only

can u help in optimizing...minimize
C=0.15247* P^2+ 38.5397*P+756.79800

24 Feb 2016 Rejeki Tambun

Hello sir,
Can you help me to find the optimal placement and capacity of Distributed Generation by using PSO?
please help me

Comment only
24 Jan 2016 mourad

mourad (view profile)

First, thanks for sharing this code.
I want to do an optimal sizing & placement of Distributed Generation on networks.
could you tell me how to write the objective function in matlab ?
Thank you

24 Jan 2016 mourad

mourad (view profile)

24 Jan 2016 mourad

mourad (view profile)

Do u know how Mr. Arif Rizvi ?

18 Nov 2015 Arif Rizvi

Very nice code . I am new learner of matlab ,I am working on Placement of Distributed Generation on Smart Grid usinf PSO , Can any one give me this code explanation.I have a problem at line no 35. Why here use 1000 ?
swarm(:, 4, 1) = 1000;

31 Jul 2015 Worawut Srisukkham  
09 Jun 2015 Lola

Lola (view profile)

19 May 2015 Hamza

Hamza (view profile)

I have a question
this code is too simple for my criteria.
is it possible to modify this code for multi-objective optimization.


Comment only
11 May 2015 Hamza

Hamza (view profile)

awesome code.
very simple , easy to understand and very close to the theoretical model of PSO.
as a starter in PSO, I am lucky to run through this code.

Comment only
23 Sep 2014 marian farouk

i need to ask you if i have 7 variables how can i put them in the program

17 Dec 2013 anum eman

easy to learn PSO realy

15 Jul 2013 Tam

Tam (view profile)

good work

27 Jan 2013 saddam saeed

nice work boy but can u please tell me how to find global maxima for PSO

05 Oct 2012 Jukkrit Kluabwang

Very good! It is easy to learn PSO concept.
Thank you very much.

04 Sep 2012 Sonki Prasetya

This is very useful in understanding PSO. Thank you for the share.

27 Mar 2012 yap ee chiet

good is easy to understand and we are able to observe the movement of particles..

Comment only
27 Mar 2012 Vinod

Vinod (view profile)

21 Nov 2011 mostafa saeed  
02 May 2011 Milton

Milton (view profile)

Good one!!, It is easy and simple to understand.

21 Feb 2011 hu jia

hu jia (view profile)

Good code.thank you!!

Comment only
09 Dec 2010 Amirhosein Azarbakht

Nice work!

25 Nov 2010 Watterpadder Watté

Thank you !

02 Nov 2010 nandagopal suryadevara  
04 Jan 2010 Lyeyee Wong

May I know what is the function of 'Live_fn.m'?

Comment only
22 Oct 2009 Patrick

A very clear example...
Nice work.....

30 Mar 2009 khalid haroun

Thanks a lot dear for your sharing us your code
with the best regard

04 Nov 2008 mohammed med


21 Oct 2008 C Lunga  
29 Aug 2008 Igor S

Learned PSO on simple example :) Thanx!

25 May 2008 Royalos Yin

It is a good tutorial tool.
Thank you.

16 Apr 2008 jonghoon han


Comment only
14 Jan 2008 Sarayut Nonsiri

Thank you very much for your code.

18 Dec 2007 rahim mozafari

thank you for sharing your code

12 Jun 2007 mo ar  
13 Apr 2007 craig hudson

good code!

still not sure about what implications the [temp, gbest] line has in relation to the updated velocity but the rest I have picked up with relative ease!

Comment only
19 Jan 2007 Amr Yassin

Thank you Wesam for sharing your PSO code it was realy useuful and easy to use

03 Nov 2006 Neil King

Nice, really nice. Simple but effective demonstration of how the algorithm works.

28 Sep 2006 wang li

I love you!you are best!Thank you for sharing your code!

25 Sep 2006 li chong

I expect one day i can write matlab program like you,you set me a example

10 Aug 2006 Sushrut Pavanaskar

Perfect Graphical Simulation is seen !!

24 Jul 2006 Rafael Gomez

Nice example!!!

20 Jul 2006 xuemei zhu


30 Nov 2014 1.1

Now available in Toolbox format.

Contact us