I have implemented a whole fuzzy logic system in Java, but I am having serious issues on the defuzzification process.
In my code, I defined my inputs as time and distance, and the output is simply output. I have every linear function that constructs the input and output sets, so I have access to any value of it.
The fuzzy rules are as follows:
FuzzySet []outputs = new FuzzySet[9]; //these are the rules
outputs[0] = new FuzzySet(INSUFFICIENT, min(timeMap.get(BAD).getDegreeOfMembership(), distanceMap.get(BAD).getDegreeOfMembership()));
outputs[1] = new FuzzySet(AVERAGE_SUFICIENT, min(timeMap.get(AVERAGE).getDegreeOfMembership(), distanceMap.get(AVERAGE).getDegreeOfMembership()));
outputs[2] = new FuzzySet(SUFFICIENT, min(timeMap.get(GOOD).getDegreeOfMembership(), distanceMap.get(GOOD).getDegreeOfMembership()));
outputs[3] = new FuzzySet(AVERAGE_SUFICIENT, min(timeMap.get(GOOD).getDegreeOfMembership(), distanceMap.get(BAD).getDegreeOfMembership()));
outputs[4] = new FuzzySet(SUFFICIENT, min(timeMap.get(GOOD).getDegreeOfMembership(), distanceMap.get(AVERAGE).getDegreeOfMembership()));
outputs[5] = new FuzzySet(SUFFICIENT, min(timeMap.get(AVERAGE).getDegreeOfMembership(), distanceMap.get(GOOD).getDegreeOfMembership()));
outputs[6] = new FuzzySet(INSUFFICIENT, min(timeMap.get(AVERAGE).getDegreeOfMembership(), distanceMap.get(BAD).getDegreeOfMembership()));
outputs[7] = new FuzzySet(AVERAGE_SUFICIENT, min(timeMap.get(BAD).getDegreeOfMembership(), distanceMap.get(GOOD).getDegreeOfMembership()));
outputs[8] = new FuzzySet(INSUFFICIENT, min(timeMap.get(BAD).getDegreeOfMembership(), distanceMap.get(AVERAGE).getDegreeOfMembership()));
At each one of these rules, I first define to what set the output for those two inputs belong (could be INSUFFICIENT
, AVERAGE_SUFFICIENT
or SUFFICIENT
). With that done, I need to move on to the defuzzication process, this is where my understanding gets a bit shady.
After going through the rules, I have three of each for each set of the output (essentially I have three values classified as SUFFICIENT
, three on SUFFICIENT_AVERAGE
and three of INSUFFICIENT
). So now what? Are all these 9 outputs going to be part of the centroid calculation? Do I choose the maximum of all three sets and then throw them in the centroid formula? (which is what I did, but the result's aren't working when compared to matlab)