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

📄 ga_fis.m

📁 其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載
💻 M
字号:
 function PI=GA_fis(x)
 % function PI=GA_fis(x)
 % Create tipper.fis by using command lines of statements
 % The new FIS is named as tipper3.fis
 
 % PenChen Chou. 3/28/2002
 
 global MIN_offset MUL_factor tipper3 Emin RESULT N_rules Target in
 global out IN_main
 x=GA_round4dp(x);
 % x(1,2)=0.1 ---2
 % x(3)  =0.05-- 8
 % x(4)  =0.1-- 10
 % x(5)  =0.1-- 15
 % x(6,7)=1 or 2 only (and, or)
 % x(8,9)=1 or 2 or 3 only 
 x(6)=min([2, round(x(6))]); x(6)=max([1 x(6)]);
 x(7)=min([2, round(x(7))]); x(7)=max([1 x(7)]);
 x(8)=min([3, round(x(8))]); x(8)=max([1 x(8)]);
 x(9)=min([3, round(x(9))]); x(9)=max([1 x(9)]);
 
 % Create name and add membership functions
 a=newfis('tipper3');
 a=addvar(a,'input','service',[0 10]);
 a=addmf(a,'input',1,'poor',     'gaussmf',[x(1)  0]);
 a=addmf(a,'input',1,'good',     'gaussmf',[x(2)  5]);
 a=addmf(a,'input',1,'excellent','gaussmf',[x(1) 10]);
 
 a=addvar(a,'input','food',[0 10]);
 a=addmf(a,'input',2,'rancid',   'trapmf',[0 0 x(3) max([x(3), x(4)])]);
 a=addmf(a,'input',2,'delicious','trapmf',[min([10-x(4), 10-x(3)]), 10-x(3) 10 10]);

 a=addvar(a,'output','tip',[-16 46]);
 a=addmf(a,'output',1,'cheap',   'trimf',[-16  0 15]);
 a=addmf(a,'output',1,'average', 'trimf',[x(5) 15 30-x(5)]);
 a=addmf(a,'output',1,'generous','trimf',[ 15 30 46]);
 
 % Append rules
 ruleList=[
    	1 1 x(8)    1 x(6) 
     %   1 1 1       1 2
        2 0 2       1 1
        3 2 x(9)    1 x(7)
        %3 2 3       1 2
    ];
 [N_rules, v]=size(ruleList);   
 a = addrule(a,ruleList); clear ruleList
 
 % Write and read FIS
 writefis(a,'tipper3'); clear a
 tipper3=readfis('tipper3');
 
 % Check results
 %in=[0 0;10 10;5 0;0 5;5 5;3 7;7 3;0 10;10 0];
 out = evalfis(in,tipper3);
 %Target=[0
 %  30.0000
 %   7.2382
 %        0
 %  15.0000
 %  20.2348
 %   9.7652
 %  15.0000
 %  15.0000];
 PI=sum(abs(Target-out).^2); ERR=PI;
 if Emin>ERR
     Emin=ERR; fprintf('S'); RESULT=x;
 else
     fprintf('>');
 end
 
 % Modify to a min. problem if necessary.
 attached_part;
 
 % IN_main==1, save FIS in xxx1
 if IN_main==1
     save xxx1 tipper3
 end

⌨️ 快捷键说明

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