import choco.integer.IntDomainVar;
import choco.Problem;
public class SortingExample {
public static void main (String[] args) {
Problem p = new Problem();
IntDomainVar[] u = p.makeEnumIntVarArray("u", 4, 1, 5);
IntDomainVar[] v = p.makeEnumIntVarArray("v", 4, 2, 6);
p.post(new SortingConstraint(u, v));
p.post(p.allDifferent(u));
if(p.solve() == Boolean.TRUE) {
System.out.print("u = [ " + u[0].getVal() + " " + u[1].getVal() + " " + u[2].getVal() + " " + u[3].getVal() + " ] - ");
System.out.println("v = [ " + v[0].getVal() + " " + v[1].getVal() + " " + v[2].getVal() + " " + v[3].getVal() + " ]");
}
while(p.nextSolution() == Boolean.TRUE) {
System.out.print("u = [ " + u[0].getVal() + " " + u[1].getVal() + " " + u[2].getVal() + " " + u[3].getVal() + " ] - ");
System.out.println("v = [ " + v[0].getVal() + " " + v[1].getVal() + " " + v[2].getVal() + " " + v[3].getVal() + " ]");
}
}
}
|