//+++++++++++++++++++++++++++++++++++++++++++++++++++++ // File automatically generated by Xfuzzy - DO NOT EDIT //+++++++++++++++++++++++++++++++++++++++++++++++++++++ package pkg.xfsg.defuz; import xfuzzy.lang.*; public class Quality extends DefuzMethod { public Quality() { super("xfsg","Quality"); Parameter single[] = new Parameter[0]; setSingleParameters(single); } public double compute(AggregateMemFunc mf) { double min = mf.min(); double max = mf.max(); double num=0, denom=0; for(int i=0; i<mf.conc.length; i++) { num += mf.conc[i].degree() * mf.conc[i].center() / mf.conc[i].basis(); denom += mf.conc[i].degree() / mf.conc[i].basis(); } if(denom == 0) return (min+max)/2; return num/denom; } 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 num=0, denom=0;"+eol; code += " for(int i=0; i<mf.conc.length; i++) {"+eol; code += " num += mf.conc[i].degree() * mf.conc[i].center() / mf.conc[i].basis();"+eol; code += " denom += mf.conc[i].degree() / mf.conc[i].basis();"+eol; code += " }"+eol; code += " if(denom == 0) return (min+max)/2;"+eol; code += " return num/denom;"+eol; return code; } public String getCCode() { String eol = System.getProperty("line.separator", "\n"); String code = ""; code += " double num=0, denom=0;"+eol; code += " int i;"+eol; code += " for(i=0; i<mf.length; i++) {"+eol; code += " num += mf.degree[i] * mf.conc[i].center() / mf.conc[i].basis();"+eol; code += " denom += mf.degree[i] / mf.conc[i].basis();"+eol; code += " }"+eol; code += " if(denom == 0) return (min+max)/2;"+eol; code += " return num/denom;"+eol; return code; } public String getCppCode() { String eol = System.getProperty("line.separator", "\n"); String code = ""; code += " double num=0, denom=0;"+eol; code += " for(int i=0; i<mf.length; i++) {"+eol; code += " num += mf.conc[i]->degree() * mf.conc[i]->center() / mf.conc[i]->basis();"+eol; code += " denom += mf.conc[i]->degree() / mf.conc[i]->basis();"+eol; code += " }"+eol; code += " if(denom == 0) return (min+max)/2;"+eol; code += " return num/denom;"+eol; return code; } }