// // 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 Test { public static void main(String[] args) { Problem pb = new Problem(); IntDomainVar tot = pb.makeBoundIntVar("tot",20,20); IntDomainVar v1 = pb.makeEnumIntVar("v1",1,10); IntDomainVar v2 = pb.makeEnumIntVar("v2",1,10); IntDomainVar v3 = pb.makeEnumIntVar("v3",1,10); pb.post(pb.eq(pb.sum(new IntVar[]{v1,v2,v3}),tot)); Solver s = pb.getSolver(); pb.solve(true); System.out.println("feasible: " + pb.isFeasible()); System.out.println("nbSol: " + s.getNbSolutions()); } }