Please Help Optimization using PSO
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ibrahim alzoubi
el 4 de En. de 2021
Respondida: Walter Roberson
el 5 de En. de 2021
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 ???
0 comentarios
Respuesta aceptada
Walter Roberson
el 5 de En. de 2021
%{
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
X1 = solve(eqn, 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.
0 comentarios
Más respuestas (1)
Ameer Hamza
el 5 de En. de 2021
Check the code of this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/75101-non-linear-equality-and-inequality-constrained-pso. It might give you some ideas.
0 comentarios
Ver también
Categorías
Más información sobre Particle Swarm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!