// // How many solutions are there to the equation // // v1 + v2 + v3 = 20 // // where 1 <= v1,v2,v3 <= 10 // import choco.Problem; import choco.ContradictionException; import choco.integer.*; import choco.Solver; import choco.Solution; public class XXX { public static void main(String[] args) { Problem pb = new Problem(); IntDomainVar tot = pb.makeBoundIntVar("tot",11,11); IntDomainVar x = pb.makeEnumIntVar("x",0,11); IntDomainVar y = pb.makeEnumIntVar("y",0,11); IntDomainVar z = pb.makeEnumIntVar("z",0,11); IntDomainVar w = pb.makeEnumIntVar("w",0,11); pb.post(pb.min(new IntVar[]{x,y,z},w)); pb.post(pb.eq(pb.sum(new IntVar[]{x,y,z}),tot)); Solver s = pb.getSolver(); pb.solve(true); System.out.println("feasible: " + pb.isFeasible()); System.out.println("nbSol: " + s.getNbSolutions()); } }