File Exchange

image thumbnail

Multi-Objective Particle Swarm Optimization (MOPSO)

version (11.4 KB) by Yarpiz
A structure MATLAB implementation of MOPSO for Evolutionary Multi-Objective Optimization


Updated 20 Oct 2015

View License

For more information, see following link:

Cite As

Yarpiz (2021). Multi-Objective Particle Swarm Optimization (MOPSO) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (42)

zaki dahia

Hi everyone, my ZDT function is
Tp=140;Tf= 600;
Error in @(x)ZDT(x)
Error in mopso (line 69)
please any solution to this problem
thanks in advance

jie yu

I'm a student, it's very hard for me to understand the code completely. because there is so many kinds of MOPSO methods, can you provide me some relevant documentation to help me analyse the code.My English is not very good, please forgive mail box is would really appreciate your reply.

nehad khattab

Nafees Ahamad

@sidharth parhi
Did you find the answer to your question?
"3 variables with different ranges" please help. How to handle variables width different lower and upper bound ?

ahmad eldeeb

@ all
for all who suffer from this error:
Error in FindGridIndex (line 25)

Error in mopso (line 87)

this is the solution from Yarpiz website:

"Your objectives can have the value of NaN. So everything may fall, due to incomparability of NaN to other numbers. You should modify your code, to replace the potential NaN outputs, with nun-NaN but invalid values."

ahmad eldeeb

Index exceeds array bounds.

Any solution to this problem

Error in FindGridIndex (line 25)

Error in mopso (line 87)

Ruiqi Wang

Very useful program. Structure is very clear, and it is easy to modify. Thank the authors.

Joshua Desbordes

Error in Mutate (line 33)
simpily do this

Cheng-Ying Yang

Thanks, it's great. But how do we define nonlinear constraints in this code?

manish sharma

Sir, I am using your Matlab code but I am facing the same problem as Ravi Mandava. Please help me.

Fodhil Fadhila

Nafees Ahamad

Index exceeds matrix dimensions.
Error in FindGridIndex (line 24)
Error in mopso (line 87)
Error in main (line 14)

Problem can be solved if you put
z = [f1 ; f2]; not z = [f1 f2];

nima rezaee

firs of all awesome code and algorithm. thank you.
but unfortunately i have the same problem as RAVI MANDAVA. i want to have different varmin and varmax for each variable in mopso.
i can change the code but im not sure it will work. i dont know maybe im missing something.
can someone please help me .
thanks in advance.

yibe man

can you tell me how to accept the training and test data from excel


osama bany mousa

This is great!
Thank you

liruixinch liruixinch

Anuraag Dash

How to implement it in MATLAB


Can anyone please tell me HOw to convert the normalized pareto fronts (between 0 and 1 ) into original values ??
email id :


hi I am using Mopso but i have 4 variables i am facing error. how i will write the Varmax and Var min in mutate function


VarMax =

10 100 60 6

VarMin =

6 50 40 2

In an assignment A(I) = B, the number of elements in B and I must be the

Error in Mutate (line 33)

Error in mopso (line 120)


Can anyone PLEASE explain me, how to use this toolbox ?

Luanna Lira

Does this code deal with binary variables?

Mingjuan Zhu

Thank you. Great works.
Could you tell me the paper about this code?


Great work! Thanks for sharing.

Saket Kulkarni

How do we define constraints in this implementation ?

preeti s

Can anyone tell me what is that exact function.That function in not in code library...

Undefined function or variable 'unifrnd'.

Error in mopso (line 66)

ahmed abdulsahib

think you ... where is equation which write this code or where is the refreance paper for this code ... and have you optimal sizing and location to reduce power losses in radial distribution system can you help me plase
my email

Crystal Tinnes

shashi bhushan jha

please share the published paper link

Dilip Kumar Roy

Thanks, Great work! Is it suitable for non-linear constraints?

Lined Koukeche

Thanks for the file.
Please how to display the optimal solutions for the variables?
Looking for your reply as soon as possible.


sidharth parhi

Index exceeds matrix dimensions.
Error in FindGridIndex (line 24)
Error in mopso (line 87)
Error in main (line 14)
The above error is showing while I am taking 3 variables with different ranges.


dear Yarpiz,
how to make sure that the generated element is within the specified decision space,like this:-1<x1<1,2<x2<5,-2<x3<8,.... thank u !

juzheng zhang




Great work, thanks for sharing.

I have a question regarding how to handle constraints in MOPSO. In GA I know there is a feature where you can define your constraints but I could not find any similar thing in MOPSO. More specifically, I'm doing power system optimization and would like to check my bus voltages after each solution and if my voltages are not in the limits then I would like to give a message to the solver it is not the right way to go. I used to do it in GA by assigning infinity to the cost function when my voltages out of the range. I've tried the same thing in MOPSO, but did not work.



Kareem Metwaly

Fernando Silva

Great code! There is some version of PSO with binary representation of the particles?

Adri Jenie

i'm doing a PSO for aggregate production planning with many decision variables. how many particle in a swarm i must initiate to find pareto optimal for optimizing 16 variable

Mahesh Kumar

How to update the velocity of particle,

initial particle.....particle(i).Position



if we see the value of initial particle (particle(i).Position) and best particle position (particle(i).Best.Position) is same so in the velocity update it will be zero value.

anyone can help in this please


Thank you for your comment. There were a minor bug in the code, which is now resolved. The lower and upper bound of variables did not applied correctly.


hello,i need your help please. i use the function ZDT.m which from "ypea124-moea-d",but it can not run. help me please. thank you very much!
??? Improper assignment with rectangular empty matrix.

Error in ==> FindGridIndex at 24

Error in ==> mopsozdt1 at 158

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!