📄 ga_f672.m
字号:
function PI=GA_f672(x)
% Fitness max. function evaluation of Example 6.7-2
% PenChen Chou, Aug. 16, 2001
global MIN_offset MUL_factor Kp Ki Kd K a1 a2 MDL FT
global ERR1 ERR2 ERR3 ERR4 ERR5 MAIN_loop evo_fuzzy Emin
global rise_time set_time ov_shoot Emin
Kp=GA_round4dp(x(1));
Ki=GA_round4dp(x(2));
Kd=GA_round4dp(x(3));
PI=0;ERR1=0;ERR2=0;ERR3=0;ERR4=0;ERR5=0;
Err_scale=1;
[T X Y]=sim(MDL,[0 FT]);
in=Y(:,1);y=Y(:,2); N=length(y);yss=in(5);
% Calculate time responses
if N<=1
ERR1=2*Emin; % Divergent response
else
y1=y(N-100);y2=y(N-98); % Check oscillation
if (abs(y1-y2)>0.1)
ERR1=2*Emin;
else
cal_time_resp; % Call tr, ov, ts
% Fitness
A1=min([50 100*rise_time]);
A2=ov_shoot;
A3=min([50 100*set_time]);
ERR1=140-evalfis([A1 A2 A3],evo_fuzzy);
end;
end; %ERR1, pause
% If oscillation, penalize ERR2
if ERR1>Emin
ERR2=2000; % Skip the present choice
else
% Check robustness
K=17661.1;a1=29.73;a2=21.033; % Normal plant
K=2.5*K; a1=0.4*a1; a2=0.4*a2; % Plant variation
[T X Y]=sim(MDL,[0 FT]);
in=Y(:,1);y=Y(:,2); N=length(y);
if N<=1 % Divergent response
ERR2=2000;
else % Check oscillation
ymax=max(y);
if (abs(ymax-yss)>0.1)
ERR2=1999;
end;
end; % ERR2, pause
end;
ERR=ERR1+ERR2+ERR3+ERR4+ERR5;
PI=ERR;
K=17661.1;a1=29.73;a2=21.033; % Back to normal plant
if Emin>PI
Emin=PI; %save xxx Kp Ki Kd Emin rise_time ov_shoot set_time
%[rise_time set_time ov_shoot Emin]
fprintf('\n==>A1=%.2f,A2=%.4f,A3=%.2f,Emin=%.4f\n',A1,A2,A3,Emin);
%pause
else
fprintf('>'); % Find the next choice
end;
if MIN_offset~=0
PI=MIN_offset-PI; % Minimization problem
end;
PI=MUL_factor*PI;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -