//+++++++++++++++++++++++++++++++++++++++++++++++++++++ // File automatically generated by Xfuzzy - DO NOT EDIT //+++++++++++++++++++++++++++++++++++++++++++++++++++++ package pkg.xfl.defuz; import xfuzzy.lang.*; public class LastOfMaxima extends DefuzMethod { public LastOfMaxima() { super("xfl","LastOfMaxima"); Parameter single[] = new Parameter[0]; setSingleParameters(single); } public double compute(AggregateMemFunc mf) { double min = mf.min(); double max = mf.max(); double step = mf.step(); double out=min, maximum = 0; for(double x=min; x<=max; x+=step) { double m = mf.compute(x); if(m>=maximum) { maximum = m; out = x; } } return out; } public boolean test () { return true; } public boolean test(AggregateMemFunc mf) { return true; } public String getJavaCode() { String eol = System.getProperty("line.separator", "\n"); String code = ""; code += " double out=min, maximum = 0;"+eol; code += " for(double x=min; x<=max; x+=step) {"+eol; code += " double m = mf.compute(x);"+eol; code += " if(m>=maximum) { maximum = m; out = x; }"+eol; code += " }"+eol; code += " return out;"+eol; return code; } public String getCCode() { String eol = System.getProperty("line.separator", "\n"); String code = ""; code += " double x, m, out=min, maximum=0;"+eol; code += " for(x=min; x<=max; x+=step) {"+eol; code += " m = compute(mf,x);"+eol; code += " if(m>=maximum) { maximum = m; out = x; }"+eol; code += " }"+eol; code += " return out;"+eol; return code; } public String getCppCode() { String eol = System.getProperty("line.separator", "\n"); String code = ""; code += " double out=min, maximum=0;"+eol; code += " for(double x=min; x<=max; x+=step) {"+eol; code += " double m = mf.compute(x);"+eol; code += " if(m>=maximum) { maximum = m; out = x; }"+eol; code += " }"+eol; code += " return out;"+eol; return code; } }