How can i use Genetic algorithm in simulink for PID?

조회 수: 17 (최근 30일)
Mohammed benzaouia
Mohammed benzaouia 2019년 11월 4일
댓글: Sam Chak 2022년 6월 6일
Hello,
I want to use genetic algorithm to find Kp,Ki and Kd for PID controller in SimulinK,
can someone give me some ideas ?

답변 (2개)

Ibrahim Seleem
Ibrahim Seleem 2020년 2월 12일
The main idea is creating s fitness function which depend on the process you want. In your case, I suggest to use sum of square error
function y=fcn(x)
Kp=x(1);
Ki=x(2);
Kd=x(3);
simopt = simset('solver','ode5','SrcWorkspace','Current','DstWorkspace','Current'); % Initialize sim options
[yout]=sim('your model name',[0 simulation time],simopt);
err1=error.^2;
err=sum(err1);
end
This is a simple code, if you can upload your complete model, I can help you to modify it.
  댓글 수: 1
Sam Chak
Sam Chak 2022년 6월 6일
Can you open and ask a new question?
fitfun = @hata;
options = optimoptions('ga', 'ConstraintTolerance', 1e-6, 'PlotFcn', @gaplotbestf);
[K, fval] = ga(fitfun, nvars, A, b, Aeq, beq, lb, ub, nonlcon, options)
K =
1.37333774469592 1.13832193717631 0.392244213118769
fval =
1.67188417949144

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


JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 11월 4일
To perform a genetic algorithm in simulink and find optimal parameters of a pid controller, the first thing you have to do is define how you are going to encode these parameters in a population, I recommend that the population encode it in digits, after this, you must define the performance of each individual based on the stability of the process (which you can evaluate by simulating some disturbances) and thus being able to select individuals in several iterations, you will probably need help from some codes in Matlab, since it would be much easier to do it in Matlab directly

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by