⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nefcon.m

📁 模糊神经网络采用matlab编程 o install NEFCON follow these steps: 1. Unpack the tar file NEFCON.TAR into your MA
💻 M
📖 第 1 页 / 共 2 页
字号:
function [outp] = nefcon(input_st);  
% NEFCON  The nefcon fuzzy learning system 
%
%         This function contains the main loop for the NEFCON 
%         learning environment. The learning methods are selected
%         and the status is controlled by this function. 
%
%         nefcon(input_st)
% 
% See also NEFGUI, SNEFCON. 

% Author: Andreas Nuernberger, TU Braunschweig, August 1996; a.nuernberger@tu-bs.de
%         contact: Ludger Merz, DASA-Airbus GmbH, Hamburg; ludger.merz@airbus.de

drawnow

% Globals: Description in nefmat  
global NEFCON_PROT NEFCON_STAT NEFCON_RULE NEFCON_OPT NEFCON_IFM NEFCON_EFM NEFCON_EFMN  
global NEFCON_RATE NEFCON_FERR NEFCON_FIS NEFCON_NUMIN   
global NEFCON_RBT NEFCON_RBND NEFCON_RBT1 NEFCON_RBND1 NEFCON_OBT NEFCON_OBND   
global NEFCON_GEN  
global NEFCON_SYSNAME 
global NEFCON_NOISE NEFCON_ADDR NEFCON_MFIT NEFCON_MFOT 
 
%actual cycle  
global NEFCON_ACTCYC  
global NEFCON_STOP  
global NEFCON_BTN
  
global IN_N OUT_N  
global IN_MF_N OUT_MF_N FIS_TYPE IN_MF_TYPE OUT_MF_TYPE RULE_N DEFUZZ_METHOD in_bound out_bound  
global IMP_METHOD RULE_WEIGHT AND_OR RULE_LIST  
global IN_PARAM OUT_PARAM  
global NEFCON_GENN NEFCON_MFIN NEFCON_MFOUT 
  
global output_stack in_mf_value qualified_out_mf overall_out_mf  
global NOF_CALLS  
global FHANDLE  

%actual input/output intervall and gain information   
global NEFCON_INT NEFCON_GAIN 
   
% number of inputs of errorfismat (if defined) - used in syserr 
global NEFCON_FNUMIN 
  
% rulebase backup during NEFCON rulelearning (main and current) 
global NEFCON_RULE_M NEFCON_RULE_C 
 
global NEFCON_STATEX 

global NEFCON_TOLD 
 
%ckeck input  
m = size(input_st, 2);  
if (m <= 1)  
	error('To few input parameters!');  
end  
m = size(input_st, 1);  
if (m ~= 1)  
	error('Only one input vector supported!');  
end  
 
 
%get current time  
time = input_st(1,1);  

%set input_stack var  
input_stack = input_st(1,2:NEFCON_NUMIN+1);  
    
%fuzzy_error = 0;  
%output_stack = 0;  
 
if NEFCON_STAT == 0 | NEFCON_STAT == [],  
  
    % Set status to initializing  
    NEFCON_STAT = 1;  
    nefgui('status');  

	% set actual gain and interval settings and initialize all undefined globals
	NEFCON_INT = [];
	NEFCON_GAIN = [];
	nefdef;

    if NEFCON_STATEX(NEFCON_STAT) == 1 & NEFCON_BTN == 0 
 
        if NEFCON_FERR == 1,  
            % load error fismatrix  
            [NEFCON_EFM, errorStr]= readfis(NEFCON_EFMN);  
            if NEFCON_EFM == [],  
                 error(['Could not load error fismatrix ''' NEFCON_EFMN '''.\n' errorStr]);  
            end 
            NEFCON_FNUMIN = getfis(NEFCON_EFM, 'numInputs'); 
        end  
 
        if NEFCON_RULE == 1,        % bottom-up  
            NEFCON_FIS = []; 
            if deblank(NEFCON_IFM) == '' 
                % create MFs 
                type = ['trimf  ';'gaussmf']; 
                NEFCON_FIS = nefinit('NEFCON_FIS', NEFCON_NUMIN, NEFCON_MFIN, ... 
                                deblank(type(NEFCON_MFIT,:)), NEFCON_INT(2:NEFCON_NUMIN+1,:), ...
                                NEFCON_MFOUT, deblank(type(NEFCON_MFOT,:)), NEFCON_INT(1,:), 0);   
            else 
                % load matrix 
                [NEFCON_FIS, errorStr] = readfis(NEFCON_IFM);  
                if NEFCON_FIS == [],  
                    error(['Could not load fismatrix ''' NEFCON_IFM '''. \n ' errorStr]);  
                else 
                    nefgui('status', ['NEFCON: Initial fismatrix ''' NEFCON_IFM ''' loaded.\n']); 
                end  
            end 
        elseif NEFCON_RULE == 2,        % nefcon original 
            NEFCON_FIS = []; 
            if deblank(NEFCON_IFM) ~= '' 
                % load matrix 
                [NEFCON_FIS, errorStr] = readfis(NEFCON_IFM);  
                if NEFCON_FIS == [],  
                    error(['Could not load fismatrix ''' NEFCON_IFM '''. \n ' errorStr]);  
                else 
                    nefgui('status', ['NEFCON: Initial fismatrix ''' NEFCON_IFM ''' loaded.\n']); 
                end  
            end 
            type = ['trimf  ';'gaussmf']; 
            % create MFs and all rules (if undefined) 
            NEFCON_FIS = nefinit('NEFCON_FIS', NEFCON_NUMIN, NEFCON_MFIN, ... 
                            deblank(type(NEFCON_MFIT,:)), NEFCON_INT(2:NEFCON_NUMIN+1,:), ... 
                            NEFCON_MFOUT, deblank(type(NEFCON_MFOT,:)), NEFCON_INT(1,:), 1);   
        elseif NEFCON_RULE == 3,        % rulelearning disabled - use initial fismatrix  
            NEFCON_FIS = []; 
            [NEFCON_FIS, errorStr] = readfis(NEFCON_IFM);  
            if NEFCON_FIS == [],  
                error(['Could not load fismatrix ''' NEFCON_IFM '''. \n ' errorStr]);  
            end  
        elseif NEFCON_RULE == 4,        % rulelearning disabled - use actual fismatrix  
        end  

    end      
  
        % return size of parameters an initial conditions  
        % nof cont. states, nof discrete states, nof out, nof in, nof discont. roots, flag ???  
        IN_N =  getfis(NEFCON_FIS, 'numInputs');  
        if IN_N ~= NEFCON_NUMIN  
            error('Illegal number of inputs in fismatrix or external definition!');  
        end  
        OUT_N = getfis(NEFCON_FIS, 'numOutputs');  
    	IN_MF_N = 	getfis(NEFCON_FIS, 'numInputMFs');  
    	OUT_MF_N = 	getfis(NEFCON_FIS, 'numOutputMFs');  
        FIS_TYPE = 	getfis(NEFCON_FIS, 'type');  
        FIS_TYPE(find(FIS_TYPE == 0)) = [];  
        if ~strcmp(FIS_TYPE, 'mamdani')  
    	    error('Unsupported FIS type (only mamdani allowed)!');  
        end  
        IN_MF_TYPE    = getfis(NEFCON_FIS, 'inMFTypes');  
        OUT_MF_TYPE   = getfis(NEFCON_FIS, 'outMFTypes');  
        RULE_N        =	getfis(NEFCON_FIS, 'numRules');  
        DEFUZZ_METHOD =	getfis(NEFCON_FIS, 'defuzzMethod');  
        in_bound      = getfis(NEFCON_FIS, 'inRange');  
        out_bound     = getfis(NEFCON_FIS, 'outRange');  
        IMP_METHOD    = getfis(NEFCON_FIS, 'impMethod');  
        IMP_METHOD(find(IMP_METHOD == 0)) = [];  
        if ~strcmp(IMP_METHOD, 'min')  
        	error('Unsupported imp_method (only min allowed)!');  
        end  
        if RULE_N > 0,  
            tmp =		    getfis(NEFCON_FIS, 'Rulelist');  
            RULE_WEIGHT =	tmp(:, IN_N+OUT_N+1);  
            AND_OR =		tmp(:, IN_N+OUT_N+2);  
            RULE_LIST =	    tmp(:, 1:IN_N+OUT_N);  
        end  
        IN_PARAM      = getfis(NEFCON_FIS, 'inMFParams');  
        OUT_PARAM     = getfis(NEFCON_FIS, 'outMFParams');  
  
 
    NOF_CALLS = 0;  
 
    NEFCON_RSTATE = 0; 
    NEFCON_RULE_M = []; 
    NEFCON_RULE_C = []; 
 
    fuzzy_error = 0; 
    output_stack = 0; 
 
    % Set status to next step  
    NEFCON_STAT = NEFCON_STAT + 1;  
    nefgui('status');  
 
elseif NEFCON_STAT == 2,        % rule learning /phase 1 
  
    % enable/disable noise during rule learning 
    NEFCON_NOISE = NEFCON_GENN; 
 
    % calculate fuzzy error  
    fuzzy_error = neferr(input_stack);
 
    if NEFCON_RULE == 1,        % bottom up  
  
        if    NEFCON_BTN == 0 & ...
			 ((NEFCON_RBT == 1 & time > NEFCON_RBND) ...  
             | (NEFCON_RBT == 2 & NOF_CALLS > NEFCON_RBND)...  
             | (NEFCON_RBT == 3 & NEFCON_ACTCYC > NEFCON_RBND)  ... 
             | NEFCON_STATEX(NEFCON_STAT) == 0 )
            % skip to next step  
            NEFCON_STAT = NEFCON_STAT + 1;  
            nefgui('status');  
        else 
            nefrules(fuzzy_error, input_stack, 1);  
        end  
  
 
    elseif NEFCON_RULE == 2,        % nefcon 
 
        if    NEFCON_BTN == 0 & ...
             ( (NEFCON_RBT == 1 & time > NEFCON_RBND) ...  
             | (NEFCON_RBT == 2 & NOF_CALLS > NEFCON_RBND)...  
             | (NEFCON_RBT == 3 & NEFCON_ACTCYC > NEFCON_RBND)... 
             | NEFCON_STATEX(NEFCON_STAT) == 0  )
            % skip to next step  
            NEFCON_STAT = NEFCON_STAT + 1;  
            nefgui('status');  
        else 
            %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
 
            nefrules(fuzzy_error, input_stack, 2);  
        end  
 
    elseif NEFCON_RULE >= 3,        % rule learning disabled  
  
        % skip to next step  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -