mirror of
https://github.com/marcin-szczepanski/jFuzzyLogic.git
synced 2024-12-18 16:35:27 +01:00
Fix
This commit is contained in:
parent
c3324c0b75
commit
d9b7260030
@ -100,6 +100,9 @@ class FunctionBlock_tipper {
|
|||||||
sum_tip += this.defuzzify_tip[i];
|
sum_tip += this.defuzzify_tip[i];
|
||||||
wsum_tip += x * this.defuzzify_tip[i];
|
wsum_tip += x * this.defuzzify_tip[i];
|
||||||
}
|
}
|
||||||
|
if (sum_tip == 0) {
|
||||||
|
sum_tip = 1.0;
|
||||||
|
}
|
||||||
this.tip = wsum_tip / sum_tip;
|
this.tip = wsum_tip / sum_tip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -68,6 +68,9 @@ public class DefuzzifierCenterOfGravity extends DefuzzifierContinuous {
|
|||||||
out.append("\t\t\t" + sumName + " += this." + defuzzName + "[i];\n");
|
out.append("\t\t\t" + sumName + " += this." + defuzzName + "[i];\n");
|
||||||
out.append("\t\t\t" + wsumName + " += x * this." + defuzzName + "[i];\n");
|
out.append("\t\t\t" + wsumName + " += x * this." + defuzzName + "[i];\n");
|
||||||
out.append("\t\t}\n");
|
out.append("\t\t}\n");
|
||||||
|
out.append("\t\tif (" + sumName + " == 0) {\n");
|
||||||
|
out.append("\t\t\t" + sumName + " = 1.0;\n");
|
||||||
|
out.append("\t\t}\n");
|
||||||
out.append("\t\tthis." + variable.getName() + " = " + wsumName + " / " + sumName + ";\n");
|
out.append("\t\tthis." + variable.getName() + " = " + wsumName + " / " + sumName + ";\n");
|
||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user