Examples of Solver


Examples of solver.Solver

    BoolVar[][][] P, M;

    @Override
    public void createSolver() {
        solver = new Solver("Social golfer " + g + "-" + w + "-" + s);
    }
View Full Code Here

Examples of solver.Solver

    int n = 4;
    int vals = n - 1;

    @Override
    public void createSolver() {
        solver = new Solver();
    }
View Full Code Here

Examples of solver.Solver

    int n = 10;
    IntVar[] vars;

    @Override
    public void createSolver() {
        solver = new Solver("Pigeons");
    }
View Full Code Here

Examples of solver.Solver

    int n = 4;
    int vals = n - 1;

    @Override
    public void createSolver() {
        solver = new Solver();
    }
View Full Code Here

Examples of solver.Solver

  // METHODS
  //***********************************************************************************

  @Override
  public void createSolver() {
    solver = new Solver("Cumulative example: makespan minimisation");
  }
View Full Code Here

Examples of solver.Solver

    private final int n = 9;
    IntVar[][] rows, cols, carres;

    @Override
    public void createSolver() {
        solver = new Solver("Sudoku");
    }
View Full Code Here

Examples of solver.Solver

    IntVar[] square1, square2, vars;
    Constraint[] ALLDIFFS;

    @Override
    public void createSolver() {
        solver = new Solver("Ortho Latin square " + m);
    }
View Full Code Here

Examples of solver.Solver

    Constraint[] lights;
    Constraint alldiff;

    @Override
    public void createSolver() {
        solver = new Solver("Langford number");
    }
View Full Code Here

Examples of solver.Solver

    IntVar[] vars;

    @Override
    public void createSolver() {
        solver = new Solver("Eq5");
    }
View Full Code Here

Examples of solver.Solver

   * @param val
   * @return la liste des positions des reines.
   */
  public static List<Integer> dominationQueen(int n, int val) {
    System.out.println("Domination queen (Q" + n + ":" + val + ")");
    Solver pb = new Solver("Introductive Example");
    IntVar[] X = new IntVar[n * n];
    //une variable par case avec pour domaine la reine qui l attaque. (les reines sont ainsi designees par les valeurs, et les cases par les variables)
    for (int i = 0; i < X.length; i++) {
      X[i] = VariableFactory.enumerated("Q" + i, 1, n*n, pb);
    }
    IntVar N = VariableFactory.fixed(val,pb);
    pb.post(IntConstraintFactory.nvalues(X,N));
    //i appartient a la variable j ssi la case i est sur une ligne/colonne/diagonale de j
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        //pour chaque case
        for (int k = 1; k <= n; k++) {
          for (int l = 1; l <= n; l++) {
            if (!(k == i || l == j || Math.abs(i - k) == Math.abs(j - l))) {
              pb.post(IntConstraintFactory.arithm(X[n * (i - 1) + j - 1], "!=", (k - 1) * n + l));
            }
          }
        }
      }
    }

    pb.set(IntStrategyFactory.lexico_LB(X));

    pb.findSolution();
    System.out.println("Back  : " + pb.getMeasures().getBackTrackCount());
    System.out.println("Time  : " + pb.getMeasures().getTimeCount()+" (sec)");

    List<Integer> values = new LinkedList<Integer>();
    if (pb.isFeasible() == ESat.TRUE) {
      for (int i = 0; i < n * n; i++) {
        if (!values.contains(X[i].getValue()))
          values.add(X[i].getValue());
      }
      System.out.print("Solution: ");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.