Forward-checking

The following shows a propagator that performs forward-checking for the binary constraint.
    'aX=bY+c'(A,X,B,Y,C) =>
          'aX=bY+c_forward'(A,X,B,Y,C).

    'aX=bY+c_forward'(A,X,B,Y,C),var(X),var(Y),{ins(X),ins(Y)} => true.
    'aX=bY+c_forward'(A,X,B,Y,C),var(X) => 
           T is B*Y+C, Ex is T//A, (A*Ex=:=T->X = Ex; true).
    'aX=bY+c_forward'(A,X,B,Y,C) => 
           T is A*X-C, Ey is T//B, (B*Ey=:=T->Y is Ey;true).
When both X and Y are variables, the propagator is suspended. When either variable is instantiated, the propagator computes the value for the other variable.



Neng-Fa Zhou 2013-01-25