Package net.sourceforge.jFuzzyLogic.rule

Examples of net.sourceforge.jFuzzyLogic.rule.LinguisticTerm


    // Add variable's membership functions' parameters
    //---
    // Iterate over each linguistic term
    for( Iterator it = variable.getLinguisticTerms().keySet().iterator(); it.hasNext(); ) {
      String termName = (String) it.next();
      LinguisticTerm linguisticTerm = variable.getLinguisticTerm(termName);
      // Get membership function
      MembershipFunction membershipFunction = linguisticTerm.getMembershipFunction();

      // Guesstimate epsilon
      membershipFunction.estimateUniverse();
      double delta = membershipFunction.getUniverseMax() - membershipFunction.getUniverseMin();
      if( delta == 0 ) delta = variable.getUniverseMax() - variable.getUniverseMin();
      epsilon = delta / UNIVERSE_TO_EPSILON_RATIO;

      // Iterate over each membership funciotn's parameter
      for( int i = 0; i < membershipFunction.getParametersLength(); i++ ) {
        String paramName = variable.getName() + "_" + linguisticTerm.getTermName() + "_" + membershipFunction.getName() + "_" + i;
        ParameterMembershipFunction param = new ParameterMembershipFunction(paramName, epsilon, variable, membershipFunction, i);
        parameterList.add((Parameter) param);
      }
    }
  }
View Full Code Here


    Value exX[] = { new Value(6), new Value(9), new Value(10) };
    Value exY[] = { new Value(0), new Value(1), new Value(1) };
    MembershipFunction excellent = new MembershipFunctionPieceWiseLinear(exX, exY);

    LinguisticTerm ltPoor = new LinguisticTerm("poor", poor);
    LinguisticTerm ltGood = new LinguisticTerm("good", good);
    LinguisticTerm ltExcellent = new LinguisticTerm("excellent", excellent);

    service.add(ltPoor);
    service.add(ltGood);
    service.add(ltExcellent);

    //    FUZZIFY food
    //       TERM rancid := (0, 1) (1, 1) (3,0) ;
    //       TERM delicious := (7,0) (9,1) (10,1);
    //    END_FUZZIFY

    Value ranX[] = { new Value(0), new Value(1), new Value(3) };
    Value ranY[] = { new Value(1), new Value(1), new Value(0) };
    MembershipFunction rancid = new MembershipFunctionPieceWiseLinear(ranX, ranY);

    Value delX[] = { new Value(7), new Value(9), new Value(10) };
    Value delY[] = { new Value(0), new Value(1), new Value(1) };
    MembershipFunction delicious = new MembershipFunctionPieceWiseLinear(delX, delY);

    LinguisticTerm ltRancid = new LinguisticTerm("rancid", rancid);
    LinguisticTerm ltDelicious = new LinguisticTerm("delicious", delicious);

    food.add(ltRancid);
    food.add(ltDelicious);

    //    DEFUZZIFY tip
    //       TERM cheap := (0,0) (5,1) (10,0);
    //       TERM average := (10,0) (15,1) (20,0);
    //       TERM generous := (20,0) (25,1) (30,0);
    //       METHOD : COG;
    //       DEFAULT := 0;
    //    END_DEFUZZIFY

    MembershipFunction cheap = new MembershipFunctionTriangular(new Value(0), new Value(5), new Value(10));
    MembershipFunction average = new MembershipFunctionTriangular(new Value(10), new Value(15), new Value(20));
    MembershipFunction generous = new MembershipFunctionTriangular(new Value(20), new Value(25), new Value(30));

    LinguisticTerm ltCheap = new LinguisticTerm("cheap", cheap);
    LinguisticTerm ltAverage = new LinguisticTerm("average", average);
    LinguisticTerm ltGenerous = new LinguisticTerm("generous", generous);

    tip.add(ltCheap);
    tip.add(ltAverage);
    tip.add(ltGenerous);
View Full Code Here

    FunctionBlock fb = new FunctionBlock(fis);

    Variable v = new Variable("a", 0.0, 20.0);
    MembershipFunction triangular = new MembershipFunctionTriangular(new Value(0.0000343232), new Value(10.0), new Value(13.0));

    LinguisticTerm t1 = new LinguisticTerm("lt1", triangular);
    LinguisticTerm t2 = new LinguisticTerm("lt2", triangular);

    v.add(t1);
    v.add(t2);

    Variable v_out = new Variable("out", 0.0, 20.0);
View Full Code Here

    //---
    // Add variable's membership functions' parameters
    //---
    // Iterate over each linguistic term
    for( String termName : variable.getLinguisticTerms().keySet() ) {
      LinguisticTerm linguisticTerm = variable.getLinguisticTerm(termName);
      // Get membership function
      MembershipFunction membershipFunction = linguisticTerm.getMembershipFunction();

      // Guess epsilon
      membershipFunction.estimateUniverse();
      double delta = membershipFunction.getUniverseMax() - membershipFunction.getUniverseMin();
      if( delta == 0 ) delta = variable.getUniverseMax() - variable.getUniverseMin();
      epsilon = delta / UNIVERSE_TO_EPSILON_RATIO;

      // Iterate over each membership funciotn's parameter
      for( int i = 0; i < membershipFunction.getParametersLength(); i++ ) {
        String paramName = variable.getName() + "_" + linguisticTerm.getTermName() + "_" + membershipFunction.getName() + "_" + i;
        ParameterMembershipFunction param = new ParameterMembershipFunction(paramName, epsilon, variable, membershipFunction, i);
        parameterList.add(param);
      }
    }
  }
View Full Code Here

      String leaveName = child.getText();
      if( debug ) Gpr.debug("\t\tChild: " + child.toStringTree());

      if( leaveName.equalsIgnoreCase("TERM") ) {
        // Linguistic term
        LinguisticTerm linguisticTerm = fclTreeFuzzifyTerm(child, variable);
        variable.add(linguisticTerm);
      } else if( leaveName.equalsIgnoreCase("ACCU") ) // Accumulation method
      throw new RuntimeException("Accumulation method (ACCU) must be defined at RULE_BLOCK");
      // ruleAccumulationMethodType = child.getChild(0).getText();
      else if( leaveName.equalsIgnoreCase("METHOD") ) // Defuzzification method
View Full Code Here

      child = tree.getChild(childNum);
      if( debug ) Gpr.debug("\t\tChild: " + child.toStringTree());
      String leaveName = child.getText();

      if( leaveName.equalsIgnoreCase("TERM") ) {
        LinguisticTerm linguisticTerm = fclTreeFuzzifyTerm(child, variable);
        variable.add(linguisticTerm);
      } else throw new RuntimeException("Unknown/Unimplemented item '" + leaveName + "'");
    }

    return variable;
View Full Code Here

    else if( leaveName.equalsIgnoreCase("SINGLETONS") ) membershipFunction = fclTreeFuzzifyTermSingletons(child);
    else if( leaveName.equalsIgnoreCase("FUNCTION") ) membershipFunction = fclTreeFuzzifyTermFunction(child);
    else if( leaveName.equalsIgnoreCase("-") ) membershipFunction = fclTreeFuzzifyTermSingleton(child);
    else if( leaveName.equalsIgnoreCase("+") ) membershipFunction = fclTreeFuzzifyTermSingleton(child);
    else membershipFunction = fclTreeFuzzifyTermSingleton(child);
    LinguisticTerm linguisticTerm = new LinguisticTerm(termName, membershipFunction);

    // Create linguistic term
    return linguisticTerm;
  }
View Full Code Here

        // Add fuzzyfiers
        fuzzifiers.append("FUZZIFY " + var.getName() + "\n");
        for( Iterator<String> itlt = var.iteratorLinguisticTermNamesSorted(); itlt.hasNext(); ) {
          String ltName = itlt.next();
          LinguisticTerm linguisticTerm = var.getLinguisticTerm(ltName);
          fuzzifiers.append("\t" + linguisticTerm.toStringFcl() + "\n");
        }
        fuzzifiers.append("END_FUZZIFY\n\n");

      } else {
        // Add output variables
        varsOut.append("\t" + var.getName() + " : REAL;\n");

        // Add defuzzyfiers
        defuzzifiers.append("DEFUZZIFY " + var.getName() + "\n");
        for( Iterator<String> itlt = var.iteratorLinguisticTermNamesSorted(); itlt.hasNext(); ) {
          String ltName = itlt.next();
          LinguisticTerm linguisticTerm = var.getLinguisticTerm(ltName);
          defuzzifiers.append("\t" + linguisticTerm.toStringFcl() + "\n");
        }
        defuzzifiers.append("\t" + var.getDefuzzifier().toStringFcl() + "\n");
        defuzzifiers.append("\tDEFAULT := " + (Double.isNaN(var.getDefaultValue()) ? "NC" : Double.toString(var.getDefaultValue())) + ";\n");
        var.estimateUniverse();
        defuzzifiers.append("\tRANGE := (" + var.getUniverseMin() + " .. " + var.getUniverseMax() + ");\n");
View Full Code Here

TOP

Related Classes of net.sourceforge.jFuzzyLogic.rule.LinguisticTerm

Copyright © 2018 www.massapicom. 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.