mirror of
https://github.com/marcin-szczepanski/jFuzzyLogic.git
synced 2024-12-18 16:35:27 +01:00
Fixes
This commit is contained in:
parent
5783f490a4
commit
c9453b7c53
Binary file not shown.
@ -15,28 +15,38 @@ public class DefuzzifierMeanMax extends DefuzzifierContinuous {
|
|||||||
/** Deffuzification function */
|
/** Deffuzification function */
|
||||||
@Override
|
@Override
|
||||||
public double defuzzify() {
|
public double defuzzify() {
|
||||||
|
/**
|
||||||
|
* Fixes:
|
||||||
|
* @author mdsflyboy
|
||||||
|
*/
|
||||||
|
|
||||||
double max = 0, maxX = 0;
|
double max = 0, maxX = 0;
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
// Calculate max
|
// Calculate max
|
||||||
for( int i = 0; i < values.length; i++ ) {
|
for (double value : values) {
|
||||||
if( values[i] >= max ) max = values[i];
|
if (value >= max)
|
||||||
|
max = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No max? => this variable has no active antecedent
|
// No max? => this variable has no active antecedent
|
||||||
if (max <= 0) return Double.NaN;
|
if (max <= 0) return Double.NaN;
|
||||||
|
|
||||||
// Calculate mean of max
|
// Calculate mean of max
|
||||||
|
boolean isFirstMax = false;
|
||||||
|
int startOfMax = 0;
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
if (values[i] == max) {
|
if (values[i] == max) {
|
||||||
maxX += min + stepSize * i;
|
if (!isFirstMax){
|
||||||
count++;
|
isFirstMax = true;
|
||||||
|
startOfMax = i;
|
||||||
|
}
|
||||||
|
maxX = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return mean of max
|
// Return mean of max
|
||||||
return maxX / count;
|
int middleI = (int) ((maxX + startOfMax) / 2);
|
||||||
|
return min + stepSize * middleI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,12 +64,12 @@ public class MembershipFunctionGenBell extends MembershipFunctionContinuous {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName() + " : " + " , " + parameters[0] + parameters[1] + " , " + parameters[2];
|
return getName() + " : " + parameters[1] + " , " + parameters[2] + " , " + parameters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** FCL representation */
|
/** FCL representation */
|
||||||
@Override
|
@Override
|
||||||
public String toStringFcl() {
|
public String toStringFcl() {
|
||||||
return "GBELL " + parameters[0] + " " + parameters[1] + " " + parameters[2];
|
return "GBELL " + parameters[1] + " " + parameters[2] + " " + parameters[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user