Package csp.datatypes

Examples of csp.datatypes.CSPSolution


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


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

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

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

    return out.toString();
  }

  public CSPSolution solve() {
               
    CSPSolution model = null;
    try {
      // Tailor is quite picky over where the flags can occur
      // so -out FILENAME must be up front!!
                        System.out.println("start taylor");
      Process tailor = Runtime.getRuntime().exec(
View Full Code Here

    //temp.delete();
    return model;
  }

  private CSPSolution parseMinionOutput(BufferedReader reader) {
    CSPSolution model = new CSPSolution();
    boolean hasSolution = false;
    int i = 0;
    int j = 0;
    String line;
    String solutionPrefix = "Sol: ";
    String hasSolutionPrefix = "Problem solvable?: ";
    try {
      while ((line = reader.readLine()) != null) {
        //System.err.println(line);
        if (line.startsWith(solutionPrefix)) {
          hasSolution = true;
          Integer value = Integer.parseInt(line.trim().substring(solutionPrefix.length()));
          String variable = "";
          if (i < dVars.size()) {
            variable = dVars.get(i++).getName();
            model.addVariable(variable, value);
          } else if (j < eVars.size()) {
            variable = eVars.get(j++).getName();
            model.addVariable(variable, value);
          }
        } else if (line.startsWith(hasSolutionPrefix)) {
          String solStatus = line.trim().substring(hasSolutionPrefix.length());
          if(solStatus.equals("yes")) {
            hasSolution = true;
View Full Code Here

      System.err.println("Could not create temp file for solving: " + e);
    }
  }

  private CSPSolution parseMinionOutput(BufferedReader reader) {
    CSPSolution model = new CSPSolution();
   
    int i = 0;
    int j = 0;
    String line;
    String solutionPrefix = "Sol: ";
    try {
      while ((line = reader.readLine()) != null) {
        //System.out.println(line);
        if (line.startsWith(solutionPrefix)) {
          Integer value = Integer.parseInt(line.trim().substring(solutionPrefix.length()));
          String variable = "";
          if (i < dVars.size()) {
            variable = dVars.get(i++).getName();
          } else if (j < eVars.size()) {
            variable = eVars.get(j++).getName();
          }
          // TODO: remove hardcoded dummy string!!
          // and remove duplication of this string in the convertor
          // and solver somehow ...
          // We make sure that dummy variables are not output.
          if (!variable.startsWith("miniondummy"))
            model.addVariable(variable, value);
        }
      }
      if (i == 0 && j == 0) {
        return null;
      } else {
View Full Code Here

      return null;
    }
  }

  public CSPSolution solve() {
    CSPSolution model = null;
    try {
      Process p = Runtime.getRuntime().exec(
          minionPath + " -timelimit " + timeout + " " + temp.getAbsolutePath());
      // TODO: killer does not work in netbeans. Does it work on CLI?
      Runtime.getRuntime().addShutdownHook(new Thread(new MinionKiller(p)));
View Full Code Here

TOP

Related Classes of csp.datatypes.CSPSolution

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.