Package csp.convertors

Examples of csp.convertors.FuzzyToEnumeratedIntegerConvertor


    int defaultBound = 4;
    int k = 1;

    long initTime = System.currentTimeMillis();

    FuzzyToEnumeratedIntegerConvertor ficonv =
        new FuzzyToEnumeratedIntegerConvertor(defaultBound, k, new HashMap<String,Integer>());
    //ficonv.addFuzzyClause(null)
    List<FuzzyClause> clauses = RandomProblemGenerator.readConstraintsFromFile(
        new File("dataset/problem0.txt"));
    //List<FuzzyClause> clauses = RandomProblemGenerator.readConstraintsFromFile(
    //    new File("/home/jeroen/Doctoraat/Implementatie/miniontest"));

    DoubleNegationEliminator dnegElim = new DoubleNegationEliminator();
    ArrayList<FuzzyClause> newClauses = new ArrayList<FuzzyClause>();
    for (FuzzyClause c : clauses) {
      ArrayList<Literal> newLiterals = new ArrayList<Literal>();
      for (Literal l : c.getDisjuncts()) {
        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();
    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");
    }

    //System.out.println("After optimization");
    //for (FuzzyClause c : clauses) {
    //  System.out.println(c);
    //}

    for (FuzzyClause c : clauses) {
      ficonv.addFuzzyClause(c);
    }
    //IntegerToMinionConvertor imconv = new IntegerToMinionConvertor(defaultBound);
    //MinionCSPProblem mProb = imconv.convertCSPToMinion(ficonv.convertToCSPProblem());
    TailorSolver solv = new TailorSolver("tailorV0.3.2/tailor.jar",
        "minion-0.10/bin/minion");
    solv.read(ficonv.convertToCSPProblem());
   
    System.out.println("Ok, read file. Now solving ...");
    CSPSolution solution = solv.solve();
    System.out.println("Solving ended!");
    if (solution != null) {
      solution.getSolution().putAll(trivialAssignments);
      Map<String, Double> fsol = ficonv.convertCSPSolutionToFuzzyModel(solution);
      for (String key : fsol.keySet()) {
        System.out.println(key + ": " + fsol.get(key));
      }
      if(checkModel(clauses, fsol)) {
        System.out.println("Model found!");
View Full Code Here

TOP

Related Classes of csp.convertors.FuzzyToEnumeratedIntegerConvertor

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.