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;
  }
예제 #2
0
  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);
  }