This commit is contained in:
marcin-szczepanski 2022-05-12 11:29:56 +02:00
parent 5783f490a4
commit c9453b7c53
3 changed files with 22 additions and 12 deletions

View File

@ -15,28 +15,38 @@ public class DefuzzifierMeanMax extends DefuzzifierContinuous {
/** Deffuzification function */
@Override
public double defuzzify() {
/**
* Fixes:
* @author mdsflyboy
*/
double max = 0, maxX = 0;
int count = 0;
// Calculate max
for( int i = 0; i < values.length; i++ ) {
if( values[i] >= max ) max = values[i];
for (double value : values) {
if (value >= max)
max = value;
}
// No max? => this variable has no active antecedent
if( max <= 0 ) return Double.NaN;
if (max <= 0) return Double.NaN;
// Calculate mean of max
for( int i = 0; i < values.length; i++ ) {
if( values[i] == max ) {
maxX += min + stepSize * i;
count++;
boolean isFirstMax = false;
int startOfMax = 0;
for (int i = 0; i < values.length; i++) {
if (values[i] == max) {
if (!isFirstMax){
isFirstMax = true;
startOfMax = i;
}
maxX = i;
}
}
// Return mean of max
return maxX / count;
int middleI = (int) ((maxX + startOfMax) / 2);
return min + stepSize * middleI;
}
@Override

View File

@ -64,12 +64,12 @@ public class MembershipFunctionGenBell extends MembershipFunctionContinuous {
*/
@Override
public String toString() {
return getName() + " : " + " , " + parameters[0] + parameters[1] + " , " + parameters[2];
return getName() + " : " + parameters[1] + " , " + parameters[2] + " , " + parameters[0];
}
/** FCL representation */
@Override
public String toStringFcl() {
return "GBELL " + parameters[0] + " " + parameters[1] + " " + parameters[2];
return "GBELL " + parameters[1] + " " + parameters[2] + " " + parameters[0];
}
}