how can i write cost function in firefly algorithm for optimal tuning pid parameters in matlab
Afficher commentaires plus anciens
Iam using firefly algorithm for optimal tuning pid parameters , the cost function is IAE i wrote IAE function as a function of pid parameters {kp,ki.kd} but it doesnot work it gives error that it undefined variable ,should i give initial values for parameters?? and what is error in the IAE function
costFunction = integral(abs(error),0,Inf);
it gives Undefined function 'abs'
Réponses (2)
noor diyana
le 11 Mai 2017
0 votes
Here are example from my senior project. You can try it. You can change the objective function, MaxIt, runtime as system that you want. Anything can email me diyana.escosa2014@gmail.com All the best!
2 commentaires
sandy jeak
le 13 Mai 2017
Hansem Rosas Ramos
le 5 Juin 2024
Hello Noor diyana,
Pls could you explain me how to change the system in the code, in my case I must change for this system:
G(s)=1065.5/(s+10.57) (Plant)
I think that in your code called "trackls.m", i have to change in SystemA for the feedback controlled system (Wc(s)=(G(s)C(s))/(1 + G(s)C(s)),where C(s)=Kp + Ki/s + Kd*s , and continue the operation algebratically, for example my feedback system controlled would be:
SystemA=tf([1605.5*kd 1605.5*kp 1605.5*ki ],[(1605.5*kd + 1) (1605.5*kp + 10.57) 1605.5*ki]);
this is correct?
And then the main program pulls the data and parameters contained in the tracklsq code? Pls I would appreciate it if you could explain that part better to me.
Best Regards
ednilson szeskoski
le 3 Sep 2017
0 votes
I have the same problem. I'm implementing PID for a voltage control system. The goal is to optimize using firefly, the same error quoted is happening, how can I implement in the code the transfer function of my case? Thank you.
tf([0.004, 0.454, 5.55, 15.1, 10], [1.6e-05, 0.002032, 0.04732, 0.4286, 2.133, 8.76, 18.01, 11])


3 commentaires
Walter Roberson
le 3 Sep 2017
I am confused about whether you are using Simulink or trying to do it in MATLAB itself? Are you trying to implement Firefly algorithm in Simulink? Are you trying to implement Firefly algorithm where the function being computed is the result of simulating a Simulink model?
ednilson szeskoski
le 3 Sep 2017
Modifié(e) : Walter Roberson
le 3 Sep 2017
The image where the mesh is drawn representing the system is only for understanding my system I work with it in simulink but only by changing the PID values, the image with the equation is the result of the transfer function of the feedback system, in which I am not able to implement in the Diyana code.
Below I have the code that I made simply to get the transfer function. Now the problem is to apply the adapted PID to the firefly optimization code.
%%Malha da excitação
amp = tf([10] , [0.1 1])
exit = tf([1] , [0.4 1])
ger = tf([1] , [1 1])
sens = tf([1], [0.01 1])
h = amp * exit * ger
g = sens
malhaeq = h / (1+h*g)
step(malhaeq)
Catégories
En savoir plus sur PID Controller Tuning dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!