how can i implement a pid controller with firefly algorithm to optimize pid parameters ?
Show older comments
i use firefly algorithm to find the optimal values of PID parameters Kp,Kd,Ki i built code for PID controller with my system but how can i implement the firefly algorithm with my code to find optimal value for PID parameters
Answers (2)
noor diyana
on 11 May 2017
0 votes
Hi Sandy jeak . You can try out this code from my senior project. I think its working successful. For objective function and MaxIt ,runtime also you can change as system that you want. All the best! Now, I've to use social spider optimization(SSO)to optimize PID Controller.Hopefully someone can help me also.
6 Comments
ednilson szeskoski
on 2 Sep 2017
Edited: ednilson szeskoski
on 2 Sep 2017
Hello, how can I implement this transfer function in code? Thank you very much already:
% 0.004 s^4 + 0.454 s^3 + 5.55 s^2 + 15.1 s + 10 % -------------------------------------------------------------------------------------------
% 1.6e-05 s^7 + 0.002032 s^6 + 0.04732 s^5 + 0.4286 s^4 + 2.133 s^3 + 8.76 s^2 + 18.01 s + 11
Walter Roberson
on 2 Sep 2017
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])
... Or did you mean something different by "implement this transfer function in code" ?
ednilson szeskoski
on 3 Sep 2017
Edited: ednilson szeskoski
on 3 Sep 2017

The way to write the function is quiet, the question is how do I add the constants kp ki and kd. The system I would like to implement is in the attached image. Thank you for your help.
ednilson szeskoski
on 6 Sep 2017
Edited: Walter Roberson
on 6 Sep 2017
I solved using feedback in the mesh, calculating mathematically was not efficient.
The problem is that I am now having errors in the code, in some of the runtime it occurs errors like:
runtime=1
Best Values:32.2255 at Iteration =20
runtime=2
Best Values:26.8245 at Iteration =20
runtime=3
Error using -
Matrix dimensions must agree.
Error in main (line 77)
rij=norm(pop(i).Position-pop(j).Position)/dmax;
Walter Roberson
on 6 Sep 2017
Please post (or link to) the code you are using.
Varun Rai
on 14 Feb 2020
suppose we have multiple pid controllers in simulink model then how can we write the firefly algorithm foe that. for eg. multiararea load frequency control . reply pls
ednilson szeskoski
on 12 Sep 2017
0 votes
The way to write the transfer function was correct. What was generating the error was the VarMax = 10 where when decreasing the variable obtained success in the simulation. Thank you.
Categories
Find more on PID Controller Tuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!