moved sources
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 551 B |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 514 B After Width: | Height: | Size: 514 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@ -1,80 +1,80 @@
|
|||||||
package net.sourceforge.jFuzzyLogic.membership;
|
package net.sourceforge.jFuzzyLogic.membership;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combined Gaussian membership function
|
* Combined Gaussian membership function
|
||||||
* @author pcingola@users.sourceforge.net
|
* @author pcingola@users.sourceforge.net
|
||||||
*/
|
*/
|
||||||
public class MembershipFunctionGaussian2 extends MembershipFunctionContinuous {
|
public class MembershipFunctionGaussian2 extends MembershipFunctionContinuous {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param mean : Mean
|
* @param mean : Mean
|
||||||
* @param stdev : Standardt deviation
|
* @param stdev : Standardt deviation
|
||||||
*/
|
*/
|
||||||
public MembershipFunctionGaussian2(Value meanl, Value stdevl, Value meanr, Value stdevr) {
|
public MembershipFunctionGaussian2(Value meanl, Value stdevl, Value meanr, Value stdevr) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
parameters = new Value[4];
|
parameters = new Value[4];
|
||||||
parameters[0] = meanl;
|
parameters[0] = meanl;
|
||||||
parameters[1] = stdevl;
|
parameters[1] = stdevl;
|
||||||
parameters[2] = meanr;
|
parameters[2] = meanr;
|
||||||
parameters[3] = stdevr;
|
parameters[3] = stdevr;
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
StringBuffer errors = new StringBuffer();
|
StringBuffer errors = new StringBuffer();
|
||||||
if (!checkParamters(errors)) throw new RuntimeException(errors.toString());
|
if (!checkParamters(errors)) throw new RuntimeException(errors.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkParamters(StringBuffer errors) {
|
public boolean checkParamters(StringBuffer errors) {
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
|
|
||||||
if (parameters[1].getValue() < 0 || parameters[3].getValue() < 0) {
|
if (parameters[1].getValue() < 0 || parameters[3].getValue() < 0) {
|
||||||
ok = false;
|
ok = false;
|
||||||
if (errors != null) errors.append("Parameters 'stdev' should be greater than zero : " + parameters[1] + " " + parameters[3] + "\n");
|
if (errors != null) errors.append("Parameters 'stdev' should be greater than zero : " + parameters[1] + " " + parameters[3] + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters[0].getValue() > parameters[2].getValue()) {
|
if (parameters[0].getValue() > parameters[2].getValue()) {
|
||||||
ok = false;
|
ok = false;
|
||||||
if (errors != null) errors.append("Parameters 'mean1' should be lower than 'meand2' : " + parameters[0] + " " + parameters[2] + "\n");
|
if (errors != null) errors.append("Parameters 'mean1' should be lower than 'meand2' : " + parameters[0] + " " + parameters[2] + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void estimateUniverse() {
|
public void estimateUniverse() {
|
||||||
// Are universeMin and universeMax already set? => nothing to do
|
// Are universeMin and universeMax already set? => nothing to do
|
||||||
if ((!Double.isNaN(universeMin)) && (!Double.isNaN(universeMax))) return;
|
if ((!Double.isNaN(universeMin)) && (!Double.isNaN(universeMax))) return;
|
||||||
universeMin = parameters[0].getValue() - 4.0 * parameters[1].getValue();
|
universeMin = parameters[0].getValue() - 4.0 * parameters[1].getValue();
|
||||||
universeMax = parameters[2].getValue() + 4.0 * parameters[3].getValue();
|
universeMax = parameters[2].getValue() + 4.0 * parameters[3].getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see net.sourceforge.jFuzzyLogic.membership.MembershipFunction#membership(double)
|
* @see net.sourceforge.jFuzzyLogic.membership.MembershipFunction#membership(double)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double membership(double in) {
|
public double membership(double in) {
|
||||||
if (in < parameters[0].getValue()) {
|
if (in < parameters[0].getValue()) {
|
||||||
return Math.exp(-(in - parameters[0].getValue()) * (in - parameters[0].getValue()) / (2 * parameters[1].getValue() * parameters[1].getValue()));
|
return Math.exp(-(in - parameters[0].getValue()) * (in - parameters[0].getValue()) / (2 * parameters[1].getValue() * parameters[1].getValue()));
|
||||||
} else if (in > parameters[2].getValue()) {
|
} else if (in > parameters[2].getValue()) {
|
||||||
return Math.exp(-(in - parameters[2].getValue()) * (in - parameters[2].getValue()) / (2 * parameters[3].getValue() * parameters[3].getValue()));
|
return Math.exp(-(in - parameters[2].getValue()) * (in - parameters[2].getValue()) / (2 * parameters[3].getValue() * parameters[3].getValue()));
|
||||||
} else return 1;
|
} else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName() + " : " + parameters[0] + " , " + parameters[1] + " , " + parameters[2] + " , " + parameters[3];
|
return getName() + " : " + parameters[0] + " , " + parameters[1] + " , " + parameters[2] + " , " + parameters[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** FCL representation */
|
/** FCL representation */
|
||||||
@Override
|
@Override
|
||||||
public String toStringFcl() {
|
public String toStringFcl() {
|
||||||
return "GAUSS2 " + parameters[0] + " " + parameters[1] + " " + parameters[2] + " " + parameters[3];
|
return "GAUSS2 " + parameters[0] + " " + parameters[1] + " " + parameters[2] + " " + parameters[3];
|
||||||
}
|
}
|
||||||
}
|
}
|