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 */
|
||||
@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;
|
||||
|
||||
// Calculate mean of max
|
||||
boolean isFirstMax = false;
|
||||
int startOfMax = 0;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] == max) {
|
||||
maxX += min + stepSize * i;
|
||||
count++;
|
||||
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
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user