Package net.sourceforge.jFuzzyLogic.membership

Examples of net.sourceforge.jFuzzyLogic.membership.Value


    //       TERM poor := (0, 1) (4, 0) ;
    //       TERM good := (1, 0) (4,1) (6,1) (9,0);
    //       TERM excellent := (6, 0) (9, 1);
    //    END_FUZZIFY

    Value poorX[] = { new Value(0), new Value(4) };
    Value poorY[] = { new Value(1), new Value(0) };
    MembershipFunction poor = new MembershipFunctionPieceWiseLinear(poorX, poorY);

    MembershipFunction good = new MembershipFunctionTrapetzoidal(new Value(1), new Value(4), new Value(6), new Value(9));

    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);
View Full Code Here


        // Variable's value
        Variable var = ((Variable) terms[i]);
        if( var.isOutputVarable() ) throw new RuntimeException("Can't use an output variable '" + var.getName() + "' for a function (It may create a race condition)");
        values[i] = var.getValue();
      } else if( terms[i] instanceof Value ) {
        Value term = (Value) terms[i];
        values[i] = term.getValue();
      } else if( terms[i] instanceof MffFunction ) {
        // Function's value
        MffFunction mff = (MffFunction) terms[i]; // Get function
        mff.evaluateTerms(); // Evaluate function's terms (recurse into tree)
        values[i] = mff.evaluateFunction(); // Evaluate function
View Full Code Here

    FIS fis = new FIS();

    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);
    MembershipFunction triangularOut = new MembershipFunctionTriangular(new Value(2.0), new Value(10.0), new Value(13.0));
    v_out.setDefaultValue(2.0);
    v_out.setDefuzzifier(new DefuzzifierCenterOfGravity(v_out));

    fb.setVariable("a", v);
    fb.setVariable("out", v_out);
View Full Code Here

   * @param tree : tree to parse
   * @return A new membership function
   */
  private MembershipFunction fclTreeFuzzifyTermCosine(Tree tree) {
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    Value net_max = new Value(tree.getChild(0), this);
    Value offset = new Value(tree.getChild(1), this);
    MembershipFunction membershipFunction = new MembershipFunctionCosine(net_max, offset);
    return membershipFunction;
  }
View Full Code Here

   * @param tree : Tree to parse
   * @return A new membership function
   */
  private MembershipFunction fclTreeFuzzifyTermDifferenceSigmoidal(Tree tree) {
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    Value a1 = new Value(tree.getChild(0), this);
    Value c1 = new Value(tree.getChild(1), this);
    Value a2 = new Value(tree.getChild(2), this);
    Value c2 = new Value(tree.getChild(3), this);
    MembershipFunction membershipFunction = new MembershipFunctionDifferenceSigmoidal(a1, c1, a2, c2);
    return membershipFunction;
  }
View Full Code Here

   * @return A new membership function
   */
  private MembershipFunction fclTreeFuzzifyTermGauss(Tree tree) {
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    Tree child = tree.getChild(0);
    Value mean = new Value(child, this);
    Value stdev = new Value(tree.getChild(1), this);
    MembershipFunction membershipFunction = new MembershipFunctionGaussian(mean, stdev);
    return membershipFunction;
  }
View Full Code Here

   * @return A new membership function
   */
  private MembershipFunction fclTreeFuzzifyTermGenBell(Tree tree) {
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    Tree child = tree.getChild(0);
    Value a = new Value(child, this);
    Value b = new Value(tree.getChild(1), this);
    Value mean = new Value(tree.getChild(2), this);
    MembershipFunction membershipFunction = new MembershipFunctionGenBell(a, b, mean);
    return membershipFunction;
  }
View Full Code Here

  private MembershipFunction fclTreeFuzzifyTermPieceWiseLinear(Tree tree) {
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    int numberOfPoints = tree.getChildCount() - 1;
    if( debug ) Gpr.debug("\tNumber of points: " + numberOfPoints);

    Value x[] = new Value[numberOfPoints];
    Value y[] = new Value[numberOfPoints];
    for( int childNum = 1; childNum < tree.getChildCount(); childNum++ ) {
      Tree child = tree.getChild(childNum);
      if( debug ) Gpr.debug("\t\tChild: " + child.toStringTree());
      String leaveName = child.getText();

      // It's a set of points? => Defines a piece-wise linear membership function
      if( leaveName.equalsIgnoreCase("POINT") ) {
        x[childNum - 1] = new Value(child.getChild(0), this); // Parse and add each point
        y[childNum - 1] = new Value(child.getChild(1), this);
        if( debug ) Gpr.debug("\t\tParsed point " + childNum + " x=" + x[childNum - 1] + ", y=" + y[childNum - 1]);
        if( (y[childNum - 1].getValue() < 0) || (y[childNum - 1].getValue() > 1) ) throw new RuntimeException("\n\tError parsing line " + child.getLine() + " character " + child.getCharPositionInLine() + ": Membership function out of range (should be between 0 and 1). Value: '" + y[childNum - 1] + "'\n\tTree: " + child.toStringTree());
      } else throw new RuntimeException("Unknown (or unimplemented) option : " + leaveName);
    }
    return new MembershipFunctionPieceWiseLinear(x, y);
View Full Code Here

   * @param tree : Tree to parse
   * @return A new membership function
   */
  private MembershipFunction fclTreeFuzzifyTermSigmoidal(Tree tree) {
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    Value gain = new Value(tree.getChild(0), this);
    Value t0 = new Value(tree.getChild(1), this);
    MembershipFunction membershipFunction = new MembershipFunctionSigmoidal(gain, t0);
    return membershipFunction;
  }
View Full Code Here

   * @param tree : Tree to parse
   * @return A new membership function
   */
  private MembershipFunction fclTreeFuzzifyTermSingleton(Tree tree) {
    if( debug ) Gpr.debug("Tree: " + tree.toStringTree());
    Value singleTonValueX = new Value(tree, this);
    MembershipFunction membershipFunction = new MembershipFunctionSingleton(singleTonValueX);
    return membershipFunction;
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.jFuzzyLogic.membership.Value

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.