Examples of FuzzyRuleSet


Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

    FIS fis = FIS.load(fileName, false);
    if( fis == null ) { // Error while loading?
      System.err.println("Can't load file: '" + fileName + "'");
      return null;
    }
    FuzzyRuleSet fuzzyRuleSet = fis.getFuzzyRuleSet();

    // Time recording
    List timeRecords = new ArrayList();
    long startTime;
    int curStep = 0;

    // Test
    for( int i = 0; i <= steps; i++, curStep += stepSize ) {
      startTime = System.currentTimeMillis();

      for( int j = 0; j <= curStep; j++ ) {
        // Set inputs
        for( int k = 0; k < inputVariables.length; k++ )
          fuzzyRuleSet.setVariable(inputVariables[k], Math.random() * 5);

        // Evaluate fuzzy set
        fuzzyRuleSet.evaluate();
      }
      timeRecords.add(new Double(System.currentTimeMillis() - startTime));
      Gpr.debug(debug, "Evaluate " + fileName + "\ti:" + i + "\tcurStep: " + curStep);
    }
    return timeRecords;
View Full Code Here

Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

      Gpr.debug(verbose, "Tree: " + parseTree.toStringTree());

      // Add every FuzzyRuleSet (there may be more than one in each FCL file)
      for( AST child = parseTree; child != null; child = child.getNextSibling() ) {
        // Create a new ruleset
        FuzzyRuleSet ruleSet = new FuzzyRuleSet();

        // Generate fuzzyRuleSet based on tree
        String ruleSetName = ruleSet.fclTree(child);
        Gpr.debug(debug, "Ruleset Name: '" + ruleSetName + "'");
        fis.addFuzzyRuleSet(ruleSetName, ruleSet);

        // Show tree?
        if( verbose ) {
View Full Code Here

Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

    Collections.sort(al);

    // Iterate over each ruleSet and append it to output string
    for( Iterator it = al.iterator(); it.hasNext(); ) {
      String ruleSetName = (String) it.next();
      FuzzyRuleSet ruleSet = getFuzzyRuleSet(ruleSetName);

      // Convert ruleSet to string (using FLC?)
      if( useFCL ) out.append(ruleSet.toStringFCL());
      else out.append(ruleSet.toString());
    }

    return out.toString();
  }
View Full Code Here

Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

        "END_RULEBLOCK\n" + //
        "\n" + //
        "END_FUNCTION_BLOCK\n";

    FIS fis = FIS.createFromString(fcl, true);
    FuzzyRuleSet fuzzyRuleSet = fis.getFuzzyRuleSet("tipper");
    fuzzyRuleSet.chart();

    // Set inputs
    fuzzyRuleSet.setVariable("service", 3);
    fuzzyRuleSet.setVariable("food", 7);
    // Evaluate fuzzy set
    fuzzyRuleSet.evaluate();

    // Show output variable's chart
    fuzzyRuleSet.getVariable("tip").chartDefuzzifier(true);

    // Print ruleSet
    System.out.println(fuzzyRuleSet);
   
    System.out.println("End TestTipperString");
View Full Code Here

Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

    // Load from 'FCL' file?
    FIS fis = FIS.load("fcl/membershipFunctionsDemo.fcl", false);
    if( fis == null ) return;

    // Show ruleset
    FuzzyRuleSet fuzzyRuleSet = fis.getFuzzyRuleSet();
    fuzzyRuleSet.chart();
  }
View Full Code Here

Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

      System.err.println("Can't load file: '" + fileName + "'");
      return;
    }

    // Show ruleset
    FuzzyRuleSet fuzzyRuleSet = fis.getFuzzyRuleSet();
    fuzzyRuleSet.chart();

    // Set inputs
    fuzzyRuleSet.setVariable("service", 3);
    fuzzyRuleSet.setVariable("food", 7);
    // Evaluate fuzzy set
    fuzzyRuleSet.evaluate();

    // Show output variable's chart
    fuzzyRuleSet.getVariable("tip").chartDefuzzifier(true);

    // Print ruleSet
    System.out.println(fuzzyRuleSet);
  }
View Full Code Here

Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

    //---
    // Load FIS (Fuzzy Inference System)
    //---
    FIS fis = FIS.load("fcl/qualify.fcl");
    FuzzyRuleSet fuzzyRuleSet = fis.getFuzzyRuleSet();

    //---
    // Create a list of parameter to optimize
    //---
    ArrayList<Parameter> parameterList = new ArrayList<Parameter>();
    // Add variables.
    // Note: Fuzzy sets' parameters for these (scoring and credLimMul) variables will be optimized
    Parameter.parameterListAddVariable(parameterList, fuzzyRuleSet.getVariable("scoring"));
    Parameter.parameterListAddVariable(parameterList, fuzzyRuleSet.getVariable("credLimMul"));
    // Add every rule's weight
    for( Iterator it = fuzzyRuleSet.getRules().iterator(); it.hasNext(); ) {
      FuzzyRule rule = (FuzzyRule) it.next();
      Parameter.parameterListAddRule(parameterList, rule);
    }

    //---
    // Create an error function to be optimzed (i.e. minimized)
    //---
    ErrorFunctionQualify errorFunction = new ErrorFunctionQualify();

    //---
    // Optimize (using 'Delta jump optimization')
    //---
    OptimizationDeltaJump optimizationDeltaJump = new OptimizationDeltaJump(fuzzyRuleSet, errorFunction, parameterList);
    optimizationDeltaJump.setMaxIterations(20); // Number optimization of iterations
    optimizationDeltaJump.optimize(true);

    //---
    // Save optimized fuzzyRuleSet to file
    //---
    System.out.println(fuzzyRuleSet.toStringFCL());
    Gpr.toFile("fcl/qualify_optimized.fcl", fuzzyRuleSet.toStringFCL());

    System.out.println("ParameterOptimizationDemo: End");
  }
View Full Code Here

Examples of net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

      System.err.println("Can't load file: '" + fileName + "'");
      return;
    }

    // Get rule set
    FuzzyRuleSet fuzzyRuleSet = fis.getFuzzyRuleSet();

    // Show ruleset
    if( show ) fuzzyRuleSet.chart();

    for( int i = 0; i < 5; i++ ) {
      // Set inputs
      fuzzyRuleSet.setVariable("pressure", 60 + 5 * i);
      fuzzyRuleSet.setVariable("temp", 15 + 2 * i);
      // Evaluate fuzzy rule set
      fuzzyRuleSet.evaluate();
      System.out.println("Temp: " + fuzzyRuleSet.getVariable("temp").getValue() + ", Pressure: " + fuzzyRuleSet.getVariable("pressure").getValue() + " => Valve: " + fuzzyRuleSet.getVariable("valve").getLatestDefuzzifiedValue());
      // System.out.println(fuzzyRuleSet);
    }

    // Print ruleSet
    if( show ) System.out.println(fuzzyRuleSet);
    System.out.println(fuzzyRuleSet.toStringFCL());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.