4.2 Set Constraints

JaCoP implements a number of set constraints specified in appendix A.2. Constraints AinS, AeqB and AinB are primitive constraints and can be reified and used in other constraints, such as conditional and logical. Other constraints are treated as ordinary JaCoP constraints.

Consider the following code that uses union constraint.

SetVar s1 = new SetVar(store, "s1", 
                new BoundSetDomain(new IntervalDomain(1,1), 
                                   new IntervalDomain(1,4))); 
SetVar s2 = new SetVar(store, "s2", 
                new BoundSetDomain(new IntervalDomain(2,2), 
                                   new IntervalDomain(2,5))); 
SetVar s = new SetVar(store, "s", 1,10); 
Constraint c = new AunionBeqC(s1, s2, s);

It performs operation {{1}..{1..4}} {{2}..{2..5}} = {{}..{1..10}} and produces {{1}..{1..4}} {{2}..{2..5}} = {{1..2}..{1..5}}. This represents 108 possible solutions.