public static void main(String[] args) { // TODO Auto-generated method stub String fileName = PROJECT_SRC_PATH + "/fcl/allowPlayer.fcl"; FIS fis = FIS.load(fileName, true); // Error while loading? assertNotNull(fis); // Show JFuzzyChart.get().chart(fis); // Set inputs /* Competence : REAL; // domain [0..40] Energy : REAL;// domain [0..100] MatchState : REAL; // domain [-50..50] */ fis.setVariable("Competence", 10); fis.setVariable("Energy", 89); fis.setVariable("MatchState", 7); // Evaluate fis.evaluate(); // Show output variable's chart Variable allow = fis.getVariable("Allow"); JFuzzyChart.get().chart(allow, allow.getDefuzzifier(), true); }
public int fuzzy() { String fileName = "fcl/fuzzyTraffic.fcl"; FIS fis = FIS.load(fileName, true); // Error while loading? if (fis == null) { System.err.println("Can't load file: '" + fileName + "'"); return 0; } int filaIndiretaMedia = (indireto.countCarros(1) + indireto.countCarros(2)) / 2; if (aberto1) { fis.setVariable("qtd", countCarros(2)); fis.setVariable("qtddir", countCarros(1)); fis.setVariable("qtdindir", filaIndiretaMedia); } else { fis.setVariable("qtd", countCarros(1)); fis.setVariable("qtddir", countCarros(2)); fis.setVariable("qtdindir", filaIndiretaMedia); } fis.evaluate(); double value = fis.getVariable("ajuste").defuzzify(); return (int) value; }
public Map<Double, String> executa(InputFuzzy input, boolean chart) throws Exception { String aval = ""; String filename = "fcl/sentimentParesCompleto2_2_1_ingles.fcl"; int cont = 0; FIS fis = FIS.load(filename, true); if (fis == null) { System.err.println("Can't load file: '" + filename + "'"); System.exit(1); } // Get default function block FunctionBlock fb = fis.getFunctionBlock(null); // Set inputs fb.setVariable("author_reputation", input.getAutor_reputation()); fb.setVariable("patterns", input.getPadroes()); fb.setVariable("correctness", input.getCorretude()); // Evaluate fb.evaluate(); // Show output variable's chart fb.getVariable("importance").defuzzify(); if (chart) { JFuzzyChart.get().chart(fis); } // Print ruleSet if (fb.getVariable("importance").getValue() >= 0 && fb.getVariable("importance").getValue() <= 2) { aval = "IF"; } else if (fb.getVariable("importance").getValue() > 2 && fb.getVariable("importance").getValue() <= 4) { aval = "SF"; } else if (fb.getVariable("importance").getValue() > 4 && fb.getVariable("importance").getValue() <= 7) { aval = "BM"; } else { aval = "PL"; } HashMap<Double, String> retorno = new HashMap<Double, String>(); retorno.put(fb.getVariable("importance").getValue(), aval); return retorno; }