Re: #=> and #<=> constraints

From: <wh_at_icparc.ic.ac.uk>
Date: Wed 29 Sep 2004 07:53:32 PM GMT
Message-ID: <20040929195332.GF27266@tempest.icparc.ic.ac.uk>
Hi Mark,

When reporting problems, please let us know which version of ECLiPSe you are
using, and which solver you are using.  It makes it easier and faster for us
to correctly diagnose your problems.

It looks as though you are trying to use the old FD library's reification
predicates with the IC library.  To quote from the "Differences between IC
and FD" section of the Constraint Library Manual:

    The reified connectives provided by the two solvers are different: FD's
    #\+/1, #/\/2, #\//2, #=>/2 and #<=>/2 (and their reified versions)
    correspond to IC's neg/1, and/2, or/2, =>/2 and #=/2 (and their reified
    versions).  Note that IC has better reification support, in that any
    constraint may be embedded in any other constraint expression,
    evaluating to that constraint's reified value.

Please read the "Reified constraints" section in the IC chapter of the
Constraint Library Manual and let us know if you have any further questions.

Cheers,
Warwick

On Wed, Sep 29, 2004 at 07:43:55PM +0100, Mark A. Hennessy wrote:
>  Hi there,
> 
>    I've been trying to use the #=> and #<=> constraints in Eclipse but 
> keep getting a syntax error which I don't understand. The code I've 
> written is to use channeling constraints to enforce a permutation on a 
> set of variables:
> 
> channelling(N,X) :-
>    % Primal Model
>    dim(X, [N]),
>    X[1..N] :: 1..N,
> 
>    % Dual Model
>    dim(R, [N]),
>    R[1..N] :: 1..N,
> 
>    (for(I,1,N), param(N,X,R) do
>        (for (J,1,N), param(I,X,R) do
>            X[I] #= J #=> R[J] #= I,
>            R[J] #= I #=> X[I] #= J
>            )
>        ),
>    X =.. [_|Vars],
>    writeln("Setup complete..."),
>    labeling(Vars).
> 
> I keep getting an error from Eclipse:
> 
> | file testing.ecl, line 17: syntax error: postfix/infix operator expected
> |         X[I] #= J #=> R[J] #= I,
> |                       ^ here
> 
> Also, I would have expected to be able to be able to write the above 
> code using the #<=> constraint as follows:
> 
> channelling(N,X) :-
>    % Primal Model
>    dim(X, [N]),
>    X[1..N] :: 1..N,
> 
>    % Dual Model
>    dim(R, [N]),
>    R[1..N] :: 1..N,
> 
>    (for(I,1,N), param(N,X,R) do
>        (for (J,1,N), param(I,X,R) do
>            X[I] #= J #<=> R[J] #= I,
>            )
>        ),
>    X =.. [_|Vars],
>    writeln("Setup complete..."),
>    labeling(Vars).
> 
> When I tried the following code using "=>" instead:
> 
> channelling(N,X) :-
>    % Primal Model
>    dim(X, [N]),
>    X[1..N] :: 1..N,
> 
>    % Dual Model
>    dim(R, [N]),
>    R[1..N] :: 1..N,
> 
>    (for(I,1,N), param(N,X,R) do
>        (for (J,1,N), param(I,X,R) do
>            X[I] #= J => R[J] #= I,
>            R[J] #= I => X[I] #= J
>            )
>        ),
>    X =.. [_|Vars],
>    writeln("Setup complete..."),
>    labeling(Vars).
> 
> 
> I got the desired result but I don't think that semantically this 
> correct since it is the logical implies
> rather than the constraint implication.
> 
> I also tried:
> 
> channelling(N,X) :-
>    % Primal Model
>    dim(X, [N]),
>    X[1..N] :: 1..N,
> 
>    % Dual Model
>    dim(R, [N]),
>    R[1..N] :: 1..N,
> 
>    (for(I,1,N), param(N,X,R) do
>        (for (J,1,N), param(I,X,R) do
>            X[I] = J #=> R[J] = I,
>            R[J] = I #=> X[I] = J
>            )
>        ),
>    X =.. [_|Vars],
>    writeln("Setup complete..."),
>    labeling(Vars).
> 
> ...but I get the same syntax error as above.
> 
> If anyone could shed some light on this for me I would be grateful.
> 
> Thanks,
> Mark.
> 
> 
> 
> 
> 
Received on Wed Sep 29 20:56:43 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:30 PM GMT GMT