Package fuzzysat

Examples of fuzzysat.FuzzyClause


            FuzzyLiteral flit = (FuzzyLiteral) l;
            FuzzyExpression newExp = flit.getExpression().accept(dnegElim);
            newLiterals.add(new FuzzyLiteral(flit.getLowerBound(),
                                             flit.getUpperBound(), newExp));
        }
        FuzzyClause fcnieuw = new FuzzyClause(newLiterals);
//        System.out.println("na = " + fcnieuw);
        clauses.add(fcnieuw);
    }
View Full Code Here


//        new File("dataset/problem0.txt"));
       
       
        List<FuzzyClause> clauses = new ArrayList();
        FuzzyLiteral lit = new FuzzyLiteral(0.25,0.75,new FuzzyConstantExpression(0.5));
        FuzzyClause cl = new FuzzyClause(lit);
        clauses.add(cl);
        MinionCSPSolver s = new MinionCSPSolver(1,new HashMap(), 4);
        for(FuzzyClause fc:clauses)
            s.addFuzzyClause(fc);
        System.out.println(s.getModel());
View Full Code Here

          FuzzyLiteral flit = (FuzzyLiteral) l;
          FuzzyExpression newExp = flit.getExpression().accept(dnegElim);
          newLiterals.add(new FuzzyLiteral(flit.getLowerBound(),
              flit.getUpperBound(), newExp));
        }
        newClauses.add(new FuzzyClause(newLiterals));
      }

      // overwrite the old clauses with the simplified ones ...
      clauses = newClauses;

      // DEBUG output for checking DoubleNegationEliminator
      //System.out.println("After DoubleNegationEliminator");
      //for (FuzzyClause c : clauses) {
      //  System.out.println(c);
      //}

      // optimization
      //HashMap trivialAssignments = new HashMap();
      HashMap trivialAssignments = new HashMap();
      if (FiniteReductionConfig.optimizeClauses) {
        boolean changed = true;
        while (changed) {
//                System.out.println("...");
          DomainFinder.simplify(clauses);
          changed = DomainFinder.eliminateTriviallySatisfiableClauses(clauses, trivialAssignments);
          //System.out.println("Eliminated trivially satisfiable clause");
        }
        //System.out.println("Optimized the clauses");
      }

      for (FuzzyClause c : clauses) {
        ficonv.addFuzzyClause(c);
      }
      //System.out.println("Solver running...");
      //solution = solver.getModel();
      //solution = solver.getModel(varOrders);
      //System.out.println("Solver found a model");

      TailorSolver solv = new TailorSolver("/home/jeroen/programming/tailorV0.3.2/tailor.jar",
          "/home/jeroen/programming/minion-0.10/bin/minion");
      solv.read(ficonv.convertToCSPProblem());

      System.out.println("Ok, read file. Now solving ...");
      CSPSolution cspSolution = solv.solve();
      solution = ficonv.convertCSPSolutionToFuzzyModel(cspSolution);
      System.out.println("Solving ended!");

      if (solution != null) {
        solution.putAll(trivialAssignments);
        checkModel(clauses, solution);
        printSolution(solution);
        Map<GroundLiteral, Double> interp = new HashMap<GroundLiteral, Double>();
        for (String s : solution.keySet()) {
          GroundLiteral lit = parseLiteral(s);
          interp.put(lit, solution.get(s));
        }
        i = new FaspInterpretation(interp);
        if (prog.isAnswerSet(i)) {
          anssetfound = true;
          //System.out.println("Woot! Answer Set!");
        } else {
          //System.out.println("Model is not an answer set");
          //printSolution(solution);
          // Find a loop

          //System.out.println("Searching loop");
          List<Set<GroundLiteral>> loops = prog.findCycles(i);
          for (Set<GroundLiteral> loop : loops) {
            // For evaluation:
            printLoop(loop);
            // Compute loop formula
            FuzzyClause loopForm = prog.computeLoopFormula2(loop);
            // For evaluation:
            //System.out.println("Loop formula: " + loopForm);
            clauses = prog.createCompletion2();
            clauses.add(loopForm);
            for (FuzzyClause c : loopClauses) {
View Full Code Here

        FuzzyLiteral flit = (FuzzyLiteral) l;
        FuzzyExpression newExp = flit.getExpression().accept(dnegElim);
        newLiterals.add(new FuzzyLiteral(flit.getLowerBound(),
            flit.getUpperBound(), newExp));
      }
      newClauses.add(new FuzzyClause(newLiterals));
    }

    // overwrite the old clauses with the simplified ones ...
    clauses = newClauses;
View Full Code Here

        FuzzyLiteral flit = (FuzzyLiteral) l;
        FuzzyExpression newExp = flit.getExpression().accept(dnegElim);
        newLiterals.add(new FuzzyLiteral(flit.getLowerBound(),
            flit.getUpperBound(), newExp));
      }
      newClauses.add(new FuzzyClause(newLiterals));
    }

    // overwrite the old clauses with the simplified ones ...
    clauses = newClauses;
View Full Code Here

      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)));
      clauseList.add(new FuzzyClause(new FuzzyLiteral(1.0,1.0,exp2)));
      //compArgs.add(new FuzzyBinaryExpression(aExpr, bodyExpr, new IW()));
      //compArgs.add(new FuzzyBinaryExpression(bodyExpr, aExpr, new IW()));
    }

    // Add clauses for constraints (only with Lukasiewicz implicator)
    // TODO: add other implicators or something
    for (GroundRule r : getRules()) {
      if (r.getHead() instanceof LattVal) {
        Double headVal = ((LattVal) r.getHead()).getValue();
        clauseList.add(new FuzzyClause(
            new FuzzyLiteral(1.0, 1.0,
            new FuzzyBinaryExpression(r.convertBodyExpression(),
            new FuzzyConstantExpression(headVal), new IW()))));
      }
    }
View Full Code Here

    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

TOP

Related Classes of fuzzysat.FuzzyClause

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.