Please Help Optimization using PSO

5 ビュー (過去 30 日間)
ibrahim alzoubi
ibrahim alzoubi 2021 年 1 月 4 日
回答済み: Walter Roberson 2021 年 1 月 5 日
I have optimization problem using PSO "I have to write the code without using toolbox" .. I wrote the mainPSO code and the objective function but I don't know how to define the equality and inequality constraints
x1+x2+x3+x4+x5 =1000;
x1^2-4x2+5x3^3+x4^4-3.5x5^2 = 300
How to define these two constraints ???

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 5 日
%{
x1+x2+x3+x4+x5 =1000;
x1^2-4x2+5x3^3+x4^4-3.5x5^2 = 300
%}
Notice that x2 is the only variable that appears linearly in the second equation. So rewrite the first equation as
%{
x2 = 1000 - x1 - x3 - x4 - x5
%}
Now substitute that into the second equation
%{
x1^2-4*(1000 - x1 - x3 - x4 - x5)+5x3^3+x4^4-3.5x5^2 = 300
%}
This is a quadratic in x1 (or x5), so solve it for x1
syms x1 x2 x3 x4 x5
eqn = x1^2-4*(1000 - x1 - x3 - x4 - x5)+5*x3^3+x4^4-3.5*x5^2 == 300
eqn = 
X1 = solve(eqn, x1)
X1 = 
Now you run two different PSO runs, one substituting 1000 - x1 - x3 - x4 - x5 for x2 and the first of those X1 values for x1; the other run substituting 1000 - x1 - x3 - x4 - x5 for x2 and the second of those X1 values for x1. These runs will not require equality or inequality constraints (unless there are more constraints you did not tell us about.)
The runs you would do would be over 3 variables only, x3, x4, x5, with you having substituted for x1 and x2 in your objective function.

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2021 年 1 月 5 日

カテゴリ

Help Center および File ExchangeParticle Swarm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by