/* From PRACTICAL CONSTRAINTS: A TUTORIAL ON MODELLING WITH CONSTRAINTS ROMAN BARTÁK http://kti.mff.cuni.cz/~bartak/NASSLLI2003/files/paper4.pdf */ /* Adam, Boris, and Cecil want to sit in a seesaw in such a way that the seesaw balances. There are five seats placed uniformly on both arms of the seesaw and one seat is placed in the middle (see Figure 6). Moreover, the boys want to have some space around them. In particular, they require that they are at least three seats apart. The weights of Adam, Boris, and Cecil are respectively 36, 32, and 16 kg. */ seasaw1(Sol):- Sol = [A, B, C], Sol in [-5..5], /* Reduce the solution tree by breaking symmetry */ A #< 0, 36*A+32*B+16*C #= 0, abs(A-B) #> 2, abs(A-C) #> 2, abs(B-C) #> 2, labeling_ff(Sol). seasaw2(Sol):- Sol = [A, B, C], Sol in [-5..5], /*using global constraints improves domain prunning*/ diffn([[A,3], [B,3], [C,3]]), A #< 0, 36*A+32*B+16*C #= 0, labeling_ff(Sol).