I'm trying to model a puzzle in order to resolve it with the Choco solver.
One of the constraint I'm coding is cyclical (it's triplet which follow themselves) like the following example:
s.post(LogicalConstraintFactory.ifThen(
IntConstraintFactory.member(mvt[i], new int[]{1, 2, 3}),
IntConstraintFactory.not_member(mvt[i + 1], new int[]{1, 2, 3})
));
s.post(LogicalConstraintFactory.ifThen(
IntConstraintFactory.member(mvt[i], new int[]{4, 5, 6}),
IntConstraintFactory.not_member(mvt[i + 1], new int[]{4, 5, 6})
));
s.post(LogicalConstraintFactory.ifThen(
IntConstraintFactory.member(mvt[i], new int[]{7, 8, 9}),
IntConstraintFactory.not_member(mvt[i + 1], new int[]{7, 8, 9})
));
// and so one...
I think that my library isn't very known so the mathematics equivalent is :
if(foo[i] is in {1, 2, 3}) then
foo[i+1] shouldn't be in {1, 2, 3}
if(foo[i] is in {4, 5, 6}) then
foo[i+1] shouldn't be in {4, 5, 6}
...
Any idea of how I can model this problem with modulo (to avoid writing each triplet)?
[1,2,3],[4,5,6],[....],...
) – rolfl♦ Feb 15 '14 at 15:47