Package expressions

Examples of expressions.FuzzyExpression


            this.name = name;
        }
    }

    public static void main(String[] args) {
        FuzzyExpression exp1 = new FuzzyBinaryExpression(new FuzzyVariableExpression("a"), new FuzzyVariableExpression("b"), new TW());
        FuzzyExpression exp2 = new FuzzyUnaryExpression(new FuzzyVariableExpression("c"), new N());
        FuzzyExpression exp = new FuzzyBinaryExpression(exp1, exp2, new TW());
        FuzzyLiteral lit = new FuzzyLiteral(0.2, 0.4, exp);
        FuzzyClause cl = new FuzzyClause(lit);
        List<FuzzyClause> constraints = new ArrayList();
        constraints.add(cl);
        LinearProgrammingSolver solver = new LinearProgrammingSolver(constraints);
View Full Code Here


    for (GroundLiteral a : getHerbrandBase()) {
      for (GroundRule r : getRules()) {
        if (r.getHead().equals(a)) {
          if (ruleMap.containsKey(a)) {
            FuzzyExpression expr = ruleMap.get(a);
            ruleMap.put(a, new FuzzyBinaryExpression(r.convertBodyExpression(), expr, new SM()));
          } else {
            ruleMap.put(a, r.convertBodyExpression());
          }
        }
      }
    }

    for (GroundLiteral a : getHerbrandBase()) {
      FuzzyExpression aExpr = new FuzzyVariableExpression(a.toString());
      FuzzyExpression bodyExpr;
      if (ruleMap.containsKey(a)) {
        bodyExpr = ruleMap.get(a);
      } else {
        bodyExpr = new FuzzyConstantExpression(0.0);
      }
      FuzzyExpression exp1 = new FuzzyBinaryExpression(aExpr, bodyExpr, new IW());
      FuzzyExpression exp2 = new FuzzyBinaryExpression(bodyExpr, aExpr, new IW());
      // TODO DEBUG commenting out following line is a test
      //clauseList.add(new FuzzyClause(
      //    new FuzzyLiteral(1.0, 1.0, new FuzzyBinaryExpression(exp1, exp2, new TM()))));
      // TODO DEBUG adding the following two lines is a test as well ...
      clauseList.add(new FuzzyClause(new FuzzyLiteral(1.0,1.0, exp1)));
View Full Code Here

        // denotes the body of rule r and /\_r is the t-norm associated
        // with r
        ArrayList<FuzzyExpression> args = new ArrayList<FuzzyExpression>();
        args.add(r.convertBodyExpression());
        args.add(r.convertToFuzzyExpression());
        FuzzyExpression ruleBodyCompletion = new FuzzyMultiExpression(args, r.getRuleTNorm());


        if (ruleMap.containsKey(l)) {
          // Add the body completion of the new rule to the body completion of the other rules
          // with this literal in the head using the minimum
          ruleMap.put(l, new FuzzyBinaryExpression(ruleMap.get(l), ruleBodyCompletion, new TM()));


        } else {
          // Add the body completion
          ruleMap.put(l, ruleBodyCompletion);


        }
      }
    }

    // Now create the fuzzy literals corresponding to each fasp literal:
    // These are of the form a = (B(r_1) /\_{r_1} r_1) /\_m ... /\_m (B(r_n) /\_{r_n} r_n)
    // such that H(r_i) = a for i = 1..n, hence we add them as two implications.
    for (GroundLiteral l : ruleMap.keySet()) {
      FuzzyExpression litExp = l.convertToFuzzyExpression();
      FuzzyExpression bodyExp = ruleMap.get(l);
      // Add the first implication of the equivalence
      literalList.add(new FuzzyLiteral(1.0, 1.0, new FuzzyBinaryExpression(litExp, bodyExp, new IW())));
      // The second implication of the equivalence
      literalList.add(new FuzzyLiteral(1.0, 1.0, new FuzzyBinaryExpression(bodyExp, litExp, new IW())));
View Full Code Here

    // 2.a Create antecedent: max(l1,...,ln) for l in loop
    ArrayList<FuzzyExpression> antList = new ArrayList<FuzzyExpression>();
    for (GroundLiteral l : loop) {
      antList.add(new FuzzyVariableExpression(l.toString()));
    }
    FuzzyExpression ant = new FuzzyMultiExpression(antList, new SM());
    // 2.b Create consequent: max(B1,...,Bn) for l <- Bi in R^{+}(P,L)
    ArrayList<FuzzyExpression> consList = new ArrayList<FuzzyExpression>();
    // Add a zero for elements that never occur in the head of a rule
    consList.add(new FuzzyConstantExpression(0.0));
    for (GroundRule r : rMinus) {
      consList.add(r.convertBodyExpression());
    }
    FuzzyExpression cons = new FuzzyMultiExpression(consList, new SM());
    return new FuzzyClause(
        new FuzzyLiteral(1.0, 1.0, new FuzzyBinaryExpression(ant, cons, new IW())));
  }
View Full Code Here

    }
    // Create the antecedent of the implication to generate:
    if (loop.size() >= 1) {
      Iterator<GroundLiteral> loopIt = loop.iterator();
      GroundLiteral first = loopIt.next();
      FuzzyExpression antecExp = new FuzzyVariableExpression(first.toString());


      while (loopIt.hasNext()) {
        antecExp = new FuzzyBinaryExpression(antecExp,
            new FuzzyVariableExpression(loopIt.next().toString()),
            new SM());
      }

      // Now create the consequent by stringing together the completion
      // formulas of the rules in RMINUS with SM:
      Iterator<GroundRule> ruleIt = RMINUS.iterator();
      FuzzyExpression consExp;


      if (ruleIt.hasNext()) {
        GroundRule firstRule = ruleIt.next();
        consExp = firstRule.createCompletion();
View Full Code Here

TOP

Related Classes of expressions.FuzzyExpression

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.