필터 지우기
필터 지우기

Fitness Function In the PSO algorithm

조회 수: 7 (최근 30일)
Maria
Maria 2014년 5월 15일
답변: Walter Roberson 2018년 12월 31일
My problem it is about PSO with PID controller , i just tried to tune PID parameters with PSO for tracking circular path as input (input is circular path ) with desired velocity = 0.25 [meter/sec] and desired azimuth given by = (2 * 3.14 * f(t)/m) rad , with m = -40 where m is the slop, f(t)=t , 0=t=40 and sampling time = 0.01 sec . I wrote the code of PSO but it does not work , I think the problem is in the fitness function structure of PSO algorithm and I don't know what is the bugs in the code below ,the fitness function should compute the Mean Square Error , please I hope from you to help me .
In the picture below the desired input is a circular path with a above parameters and the actual output is should be as the desired input .
Many thanks
the fitness function that I wrote :
function F = FitnessFun(pid)
Kp1 = pid(1);
Ki1 = pid(2);
Kd1 = pid(3);
Kp2 = pid(4);
Ki2 = pid(5);
Kd2 = pid(6);
sprintf('The value of interation Kp= %3.0f, Kd= %3.0f', pid(1),pid(2),pid(3),pid(4),pid(5),pid(6));
% Compute function value
simopt = simset('solver','ode5','SrcWorkspace','Current','DstWorkspace','Current'); % Initialize sim options
[tout,xout,yout] = sim('sim1',[0 100],simopt);
n=1;m=-40;
for t=0.3:.3:2*pi
theta_d(n)=((2*pi)* t/m);
n=n+1;
end
t=1:20;
v=step(1,t);
[theta,t]=lsim(theta_d,t);
for k=1:20
eth(k)=theta(k)-theta_d(k);
end
ev=(-v+1);
out=sum((ev.^2)+sum(eth.^2))/20;
F=out;
end
  댓글 수: 2
Maria
Maria 2014년 5월 18일
Any one can answer ? please
Adityabaradwaj Sixth sem
Adityabaradwaj Sixth sem 2018년 12월 31일
Could you post the complete code?? I think there maybe an error in
subsequent lines of code.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 12월 31일
step requires a tf or genss as input, or else a system object of some kind such as aa cascade object detector.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by