Particle swarm optimisation problem
古いコメントを表示
Hello all,
I am trying to use PSO for solving a system of nonlinear transcendental equations used in SHE PWM.
Following is the code i am using to solve
fun = @(alpha) pwm_equations_multilevel_pso(alpha0,1,2,harmonics)
nvars = 3;
lb=[0, 0, 0];ub=[deg2rad(90),deg2rad(90),deg2rad(90)];
options = optimoptions('particleswarm','SwarmSize',200,'MaxStallIterations',200)
options = optimoptions(options,'PlotFcn',@pswplotbestf);
[x,fval,exitflag,output] = particleswarm(fun,nvars,lb,ub,options)
where 'pwm_equations_multilevel_pso' is simply as follows
function F_dot = pwm_equations_multilevel_pso(alpha,M,harmonic_cancellation,harmonics)
F(1) = cos(harmonics(1)*alpha(1)) + cos(harmonics(1)*alpha(2)) - cos(harmonics(1)*alpha(3));
F(2) = cos(harmonics(2)*alpha(1)) + cos(harmonics(2)*alpha(2)) - cos(harmonics(2)*alpha(3));
F(3) = (cos(alpha(1)) + cos(alpha(2)) - cos(alpha(3))) - M;
F_dot=dot(F,F)
end
So the scalar value returned is a dot product of F with itself. I want to minimize F_dot to zero, but when i use PSO i get the following result

Unfortunately PSO does not converge to zero, it does not do anything in my case.
Obviously I am doing something wrong, but I am not sure what
Any help will be appreciated!
6 件のコメント
Walter Roberson
2019 年 8 月 18 日
fun = @(alpha) pwm_equations_multilevel_pso(alpha0,1,2,harmonics)
Your objective function ignores the current state vector, alpha, and always calculates the equations on the same inputs, alpha0, 1, 2, harmonics . That is not going to change with the state vector, so you are going to get constant output instead of minimization.
RAN
2019 年 8 月 18 日
Walter Roberson
2019 年 8 月 18 日
Please post enough so that we can test your code -- in particular we need the value of harmonics
Question: why do you have harmonic_cancellation as a parameter of the function when you do not use it?
Walter Roberson
2019 年 8 月 18 日
particleswarm() does not offer any constraints other than lb / ub .
You could add a penalty to the output for inputs that are out of order.
RAN
2019 年 8 月 18 日
回答 (1 件)
Nishma Sai
2021 年 1 月 22 日
0 投票
can u just provide the entire code as i got some errors with my code
1 件のコメント
Walter Roberson
2021 年 1 月 22 日
You could post your attempt, along with the error message, and we could help you debug the problems.
カテゴリ
ヘルプ センター および File Exchange で Particle Swarm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

