// // How many dominos are there? // Expressed as a CP // // NOTE: uses variable and value ordering // import org.chocosolver.solver.Solver; import org.chocosolver.solver.variables.*; import org.chocosolver.solver.constraints.*; import org.chocosolver.solver.search.strategy.*;//IntStrategyFactory; import org.chocosolver.solver.trace.Chatterbox; import org.chocosolver.solver.exception.ContradictionException; import org.chocosolver.solver.search.strategy.selectors.values.IntDomainMax; import org.chocosolver.solver.search.strategy.strategy.IntStrategy; import org.chocosolver.solver.search.strategy.selectors.variables.InputOrder; public class Domino99 { public static void main(String args[]) throws ContradictionException { Solver solver = new Solver("domino3"); IntVar v1 = VF.bounded("v1",0,6,solver); // NOTE: bound! IntVar v2 = VF.bounded("v2",0,6,solver); solver.post(ICF.arithm(v1,"<=",v2)); // // IntStrategy made up of variables to choose, variable ordering then value ordering heuristics // May need to use this for simple bin packing // IntStrategy intStrat = new IntStrategy(new IntVar[]{v1,v2},new InputOrder<>(),new IntDomainMax()); solver.set(intStrat); // find all solutions if (solver.findSolution()) { do {System.out.println("["+v1.getValue() +" : "+ v2.getValue() +"]");} while (solver.nextSolution()); } } }