-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathANFISGA.m
59 lines (47 loc) · 1.38 KB
/
ANFISGA.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
clear all
close all
load Data
Table=a;
Table=Table';
[trainingData,valInd,testingData] = dividerand(Table,0.5,0,0.5);
trainingData=trainingData';
testingData=testingData';
%% Anfis
fisys=readfis('y3kprof_5input');
epoch_n = 40;
dispOpt = nan(1,4);
optMethod=1;
[out_fis, error,ss,out_fis1,error1]= anfis(trainingData,fisys,epoch_n,dispOpt,testingData,optMethod);
writefis(out_fis,'testfis')
op_anfis=(evalfis(testingData(:,1:end-1),out_fis));
Anfis_error1=op_anfis-testingData(:,end);
Anfis_error=mser(op_anfis,testingData(:,end));
%% GA starts here
fitness= @(z) objectiveGA(z,testingData);
options = gaoptimset('MutationFcn',@mutationadaptfeasible,'PopulationSize',10);
options = gaoptimset(options,'PlotFcns',@gaplotbestf, ...
'Display','iter','Generations',50);
% options = gaoptimset(options,'OutputFcn',@myoutputfcn);
dim=5*23*2;
[x,fval,exitflag,output] = ga(fitness,dim,[],[],[],[],0,1,[],options);
out_fis=readfis('GAupdatedfis');
op_fisGA=(evalfis(testingData(:,1:end-1),out_fis));
GAerr=op_fisGA-testingData(:,end);
%%
figure
plot(Anfis_error1,'b')
hold on
plot(GAerr,'g')
hold on
%% Plot of Membership function
noInp=numel(out_fis.input);
figure
for ii=1:noInp
subplot(3,2,ii)
plotmf(out_fis,'input',ii)
end
figure
for ii=1:noInp
subplot(3,2,ii)
plotmf(out_fis,'input',ii)
end