// // How many dominos are there? // Expressed as a CP // // Can we prove this is correct using a counting argument? // import static choco.Choco.*; import choco.cp.model.CPModel; import choco.cp.solver.CPSolver; import choco.kernel.model.Model; import choco.kernel.solver.Solver; import choco.kernel.model.variables.integer.IntegerExpressionVariable; import choco.kernel.model.variables.integer.IntegerVariable; public class Domino { public static void main(String[] args) { Model m = new CPModel(); IntegerVariable v1 = makeIntVar("v1",0,6); IntegerVariable v2 = makeIntVar("v2",0,6); m.addConstraint(leq(v1,v2)); Solver s = new CPSolver(); s.read(m); if (s.solve().booleanValue()){ System.out.println("[" + s.getVar(v1).getVal() + " : " + s.getVar(v2).getVal() + "]"); //System.out.println(pb.pretty()); while (s.nextSolution().booleanValue()) System.out.println("[" + s.getVar(v1).getVal() + " : " + s.getVar(v2).getVal() + "]"); //System.out.println(pb.pretty()); } /* s.solve(true); System.out.println("feasible: " +s.isFeasible()); System.out.println("nbSol: " + s.getNbSolutions()); */ } }