2

I am using GA to optimize the parameters of the membership functions in my fuzzy system. I create a function for fitness:

function y = gafuzzy(x)
global FISsys
global allData
global realResult

FISsys = readfis('aCAess.fis'); 
allData = importdata('ab.mat');
realResult = importdata('ad.mat');

FISsys.input(1,1).mf(1,1).params = [x(1) x(2) x(3)];
FISsys.input(1,1).mf(1,2).params = [x(4) x(5) x(6)];

FISsys.input(1,2).mf(1,1).params = [x(7) x(8) x(9)];
FISsys.input(1,2).mf(1,2).params = [x(10) x(11) x(12)];

FISsys.output.mf(1,1).params = [x(13) x(14) x(15)];
FISsys.output.mf(1,2).params = [x(16) x(17) x(18)];

c = evalfis(allData,FISsys);
e=sum(abs(c-realResult)); 
y = e;

end

And A[15*18] matrix for linear inequalities is :

A = [1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1;
0,1,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,-1,0]

and b[15*1] vector is:

b = [0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]

but when I run GA, I get this error: Illegal parameters in fisTriangleMf() --> a > b

why?

NKN
  • 6,482
  • 6
  • 36
  • 55
Omid Omidi
  • 1,670
  • 2
  • 16
  • 23

1 Answers1

3

Generally, in the triangle MF the first number, here a (shows the left vertex) should be smaller than the second number, here b (the top vertex). So you can have a triangle MF like [-1 0 1] but it cannot be like [0 -1 1].

in your code, I assume sometimes you don't satisfy the inequality in one of those places:

[x(1) < x(2) < x(3)];
[x(4) < x(5) < x(6)];
[x(7) < x(8) < x(9)];
[x(10) < x(11) < x(12)];
....

if the program is randomizing these values, you can bound them in your code easily by checking and replacing, for instance:

if x(1) >= x(2)
     tmp = x(1);
     x(1) = x(2);
     x(2) = tmp;
end
NKN
  • 6,482
  • 6
  • 36
  • 55
  • Thanks NKN, but I set linear inequalities correctly. Why its not working truely? – Omid Omidi Jan 06 '14 at 16:53
  • @OmidOmidi I didn't mean linear inequalities for the GA. check out how you are setting the x(i) values in your code. Those values should be taking care of. – NKN Jan 06 '14 at 17:11
  • (Constraints) : Linear inequalities of the form A*x ≤ b are specified by the matrix A and the vector b. (In optimtool). by add your code for each iteration need 10 sec. – Omid Omidi Jan 06 '14 at 18:00
  • How do you select x(i) for the MFs? – NKN Jan 06 '14 at 18:50
  • With this: FISsys.input(1,1).mf(1,2).params = [x(5) x(6) x(7)]; – Omid Omidi Jan 06 '14 at 19:47
  • I know that man, where those numbers are coming from? (x(5),x(6),...)? Do you define them by yourself? – NKN Jan 06 '14 at 19:51
  • Dear NKN! This function is fitness function in GA and GA products X(i)s and put those in function automatically. – Omid Omidi Jan 06 '14 at 20:23
  • Then you need to check those values inside this function. Make sure that for example: x(5) < x(6) < x(7) and so on. – NKN Jan 06 '14 at 20:28
  • GA not perform constraints. @NKN, X(i)s are static and cannot modifying manually. – Omid Omidi Jan 07 '14 at 20:00
  • Omid Omidi, did you ever find a solution to this issue? I'm actually running into the same problem with the Matlab Fuzzy toolbox with constant MF parameters that are definitely ordered correctly. – SwarthyMantooth Apr 30 '14 at 23:22