📄 nefcon.m
字号:
NEFCON_STAT = NEFCON_STAT + 1;
nefgui('status');
else
error('Illegal rule learning type');
end
%compute output of fuzzy inference system with modified parameters
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
elseif NEFCON_STAT == 3, % rule learning /phase 2
% calculate fuzzy error
fuzzy_error = neferr(input_stack);
if NEFCON_RULE == 1, % bottom up
% disable noise (phase 2 is cleanup phase: noise would destroy state prediction)
NEFCON_NOISE=0;
% nur f黵 gleiche typen richtig !!!
rbnd = NEFCON_RBND+NEFCON_RBND1;
if NEFCON_BTN == 0 & ...
( (NEFCON_RBT1 == 1 & time > rbnd) ...
| (NEFCON_RBT1 == 2 & NOF_CALLS > rbnd)...
| (NEFCON_RBT1 == 3 & NEFCON_ACTCYC > rbnd)...
| NEFCON_STATEX(NEFCON_STAT) == 0 )
if NEFCON_STATEX(NEFCON_STAT) == 1
% end of phase 2 - cleanup (end of step ii)
nefrule2(fuzzy_error, input_stack, 12);
end
% skip to next step
NEFCON_STAT = NEFCON_STAT + 1;
nefgui('status');
else
nefrule2(fuzzy_error, input_stack, 1);
end
%compute output of fuzzy inference system with modified parameters
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
% check if any rule has fired...
if sum(sum(qualified_out_mf)) == 0
%add new rule (previous step)
disp('adding new rule...');
% calculate fuzzy error (in correct status)
NEFCON_STAT = 2;
fuzzy_error = neferr(input_stack);
nefrules(fuzzy_error, input_stack, 1); % only bottom up possible
NEFCON_STAT = 4;
%compute output of fuzzy inference system with modified parameters
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
end
elseif NEFCON_RULE == 2, % Nefcon
% enable/disable noise during rule learning
NEFCON_NOISE = NEFCON_GENN;
% nur f黵 gleiche typen richtig !!!
rbnd = NEFCON_RBND+NEFCON_RBND1;
if NEFCON_BTN == 0 & ...
( (NEFCON_RBT1 == 1 & time > rbnd) ...
| (NEFCON_RBT1 == 2 & NOF_CALLS > rbnd)...
| (NEFCON_RBT1 == 3 & NEFCON_ACTCYC > rbnd)...
| NEFCON_STATEX(NEFCON_STAT) == 0 )
if NEFCON_STATEX(NEFCON_STAT) == 1
% end of phase 2 - cleanup (end of step ii)
nefrule2(fuzzy_error, input_stack, 22);
end
%compute output of fuzzy inference system with modified parameters
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
% skip to next step
NEFCON_STAT = NEFCON_STAT + 1;
nefgui('status');
else
nefrule2(fuzzy_error, input_stack, 2);
end
%compute output of fuzzy inference system with modified parameters inside nefrule2
elseif NEFCON_RULE >= 3, % rule learning disabled
% skip to next step
NEFCON_STAT = NEFCON_STAT + 1;
nefgui('status');
%compute output of fuzzy inference system with modified parameters
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
% check if any rule has fired...
if sum(sum(qualified_out_mf)) == 0
%add new rule (previous step)
disp('adding new rule...');
% calculate fuzzy error (in correct status)
NEFCON_STAT = 2;
fuzzy_error = neferr(input_stack);
nefrules(fuzzy_error, input_stack, 1); % only bottom up possible
NEFCON_STAT = 4;
%compute output of fuzzy inference system with modified parameters
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
end
else
error('Illegal rule learning type');
end
elseif NEFCON_STAT == 4, % optimizing
% disable noise
NEFCON_NOISE=0;
% calculate fuzzy error
fuzzy_error = neferr(input_stack);
if NEFCON_OPT == 1 | NEFCON_OPT == 2, % nefcon modified | with shift
% nur f黵 gleiche typen richtig !!!
rbnd = NEFCON_OBND+NEFCON_RBND+NEFCON_RBND1;
if NEFCON_BTN == 0 & ...
( (NEFCON_OBT == 1 & time > rbnd) ...
| (NEFCON_OBT == 2 & NOF_CALLS > rbnd)...
| (NEFCON_OBT == 3 & NEFCON_ACTCYC > rbnd) ...
| NEFCON_STATEX(NEFCON_STAT) == 0 )
% skip to next step
NEFCON_STAT = NEFCON_STAT + 1;
nefgui('status');
else
nefopt(fuzzy_error, input_stack, NEFCON_OPT);
end
elseif NEFCON_OPT == 3, % disabled
% skip to next step
NEFCON_STAT = NEFCON_STAT + 1;
nefgui('status');
else
error('Illegal optimizing type');
end
%compute output of fuzzy inference system with modified parameters
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
if NEFCON_ADDR
% check if any rule has fired...
if sum(sum(qualified_out_mf)) == 0
%add new rule
disp('adding new rule...');
% calculate fuzzy error (in correct status)
NEFCON_STAT = 2;
fuzzy_error = neferr(input_stack);
nefrules(fuzzy_error, input_stack, 1); % add rule using bottom up
NEFCON_STAT = 4;
%compute output of fuzzy inference system with modified parameters
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
end
end
elseif NEFCON_STAT == 5, % ready (controlling)
% calculate fuzzy error
fuzzy_error = neferr(input_stack);
%compute output of fuzzy inference system
if RULE_N > 0
[output_stack, in_mf_value, qualified_out_mf, overall_out_mf] = evalfis(input_stack, NEFCON_FIS);
else
disp('No rules defined in fismatrix!');
end
if NEFCON_STATEX(NEFCON_STAT) == 0 & NEFCON_BTN == 0
NEFCON_STAT = NEFCON_STAT + 1;
end
else
%disp(['NEFCON: illegal status ' num2str(NEFCON_STAT) '.']);
fuzzy_error = 0;
output_stack = 0;
NEFCON_STOP = 1;
NEFCON_STAT = 0;
end
if NEFCON_STAT > 0
NOF_CALLS = NOF_CALLS + 1;
end
outp = [output_stack; fuzzy_error];
%outp = [output_stack];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -