Problem in matlab code for Multiobjective GA?

1 view (last 30 days)
Hi,
I am using GA-otimization TBX of MATLAB R2009b version. My project work is to optimize the parameters of PID controller for speed control by GA where my objective is to get a smooth, fastest response with least overshoot. I had earlier designed my fitness function and had got a nice result through offline GA, but it still had some overshoot. Code is as follows:
function fval = optim(x_pop)
kd=x_pop(1);
kp=x_pop(2);
ki=x_pop(3);
num=[];
den=[];
sys=tf(num,den); % the transfer funtion is of second order
time=0:0.01:40;
y=step(sys,time);
err=zeros(1,1000);
for i=1:100
err(i) = 1-y(i); % y is the output of plant
end
err_sq = err.*err;
kum=0;
for j= 1:100
kum= kum+err_sq(j);
end
MSE=kum/max(size(err));
fval=1/MSE;
so, now I wish to apply "ONLINE MULTI-OBJECTIVE GA" for the same problem. I had designed the code, where 1 function is for error minimization but dont know where/how to include the 2nd function for overshoot reduction.
function F = eval_jj(k)
global Kp Ki Kd
assignin('base', 'k', k)
Kp = k(1);
Ki = k(2);
Kd = k(3);
sim('jj'); % 'jj' is the model having a PID controller (with gains as k(1),
k(2) and k(3) and transfer function of the plant in series and a
unity feedback closed loop.
err=ip-y; % ip is the input of pid block and y is its output
es=err.*err;
f(1)=1/es; % don't know about f(2)
F=f(1)+f(2);
I need answer to 2 questions:
1- The input and output files should be from PID block or rather it should be the input and output of the whole model?
2- How do I include a code for overshoot into it?
Kindly help......

Answers (0)

Community Treasure Hunt

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

Start Hunting!