Package csp.convertors

Examples of csp.convertors.FuzzyToIntegerConvertor


    int defaultBound = 4;
    int k = 1;

    long initTime = System.currentTimeMillis();

    FuzzyToIntegerConvertor ficonv =
        new FuzzyToIntegerConvertor(defaultBound, k);
    //ficonv.addFuzzyClause(null)
    List<FuzzyClause> clauses = RandomProblemGenerator.readConstraintsFromFile(
        new File("/home/jeroen/Doctoraat/Implementatie/godel.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("/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 ...");
    solv.PPLEVELNUMBER = TailorSolver.PPLEVELNUMBER.SAC;
    solv.VARORDERNUMBER = TailorSolver.VARORDERNUMBER.LDF;
    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


          distances);
      ArrayList<String> varOrders = createVarOrderings(townStrings, atmStrings,
          distances);
//      System.out.println(boolVars);
      //ChocoSolver solver = new ChocoSolver(10);
      FuzzyToIntegerConvertor ficonv =
          new FuzzyToIntegerConvertor(defaultBound, k);

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

    model.addConstraint(new Constraint(Constraint.Operator.GEQ,exp1,5));*/

    int defaultBound = 4;
    int k = 1;

    FuzzyToIntegerConvertor ficonv = new FuzzyToIntegerConvertor(defaultBound, k);
    //ficonv.addFuzzyClause(null)
    List<FuzzyClause> clauses = RandomProblemGenerator.readConstraintsFromFile(
        new File("/home/jeroen/Doctoraat/Implementatie/minionsmalltest.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());
    MinionSolver solv = new MinionSolver("/home/jeroen/programming/minion-0.10/bin/minion");
    System.out.println("Reading file...");
    solv.read(mProb);
    System.out.println("Ok, read file. Now solving ...");
    CSPSolution solution = solv.solve();
    System.out.println("Solving ended!");
    if (solution != null) {
      Map<String, Double> fsol = ficonv.convertCSPSolutionToFuzzyModel(solution);
      solution.getSolution().putAll(trivialAssignments);
      checkModel(clauses, fsol);
      for (String key : fsol.keySet()) {
        System.out.println(key + ": " + fsol.get(key));
      }
View Full Code Here

    for (FuzzyClause c : clauses) {
      System.out.println(c);
    }


    FuzzyToIntegerConvertor ficonv =
        new FuzzyToIntegerConvertor(defaultBound, k);

//    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;

    HashMap trivialAssignments = new HashMap();
//    if (FiniteReductionConfig.optimizeClauses) {
//      boolean changed = true;
//      while (changed) {
//        DomainFinder.simplify(clauses);
//        changed = DomainFinder.eliminateTriviallySatisfiableClauses(clauses, trivialAssignments);
//      }
//    }

    for (FuzzyClause c : clauses) {
      ficonv.addFuzzyClause(c);
    }

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

TOP

Related Classes of csp.convertors.FuzzyToIntegerConvertor

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.