Please Help Optimization using PSO

조회 수: 3 (최근 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 CenterFile Exchange에서 Particle Swarm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by