Re: RIA Constraint Solver Question

From: Warwick Harvey <wh_at_icparc.ic.ac.uk>
Date: Wed 30 Jul 2003 11:43:03 AM GMT
Message-ID: <20030730124254.K18432@tempest.icparc.ic.ac.uk>
Hi,

On Tue, Jul 29, 2003 at 11:55:04PM -0400, Xiao-Hua Kong wrote:
> Hi,
> 
> I am a new user of Eclipse and want to use it for RIA constraint solving.
> I wrote two programs. One with finte domain and another with IC. But I did
> not got the same result.
> What's the problem with my program? 
> 
> ####################################################
> 	With FD solver
> ####################################################
> :- lib(fd).
> :- lib(ic).

You shouldn't load both of these solvers.  The code here works with either
of them, but not both.

> case3_fd(LD1, LD2):-
> LD1 = [X1,X2,X3,X4],
> LD2 = [D1,D2],
> LD1 :: [0 .. 20],
> LD2 :: [1 .. 12],
> X1 #= 0,
> X2 #=< X1+4,
> X2 #>= X1+2,
> X3 #= X1+D1,
> X4 #= X2+D2,
> D1 #=< D2+1,
> D1 #>= D2-1,
> X4 #=< X3+2.
> 
> -------------------------------
> I got the result as I expected
> 
> ###############################################
> 	With IC solver--if I did it right :-)
> ################################################
> :- lib(ic).
> 
> case3_ic(LD1, LD2):-
> LD1 = [X1,X2,X3,X4],
> LD2 = [D1,D2],
> LD1 :: [0.0 .. 20.0],
> LD2 :: [1 .. 12.0],

The problem here is that `1' is an integer and `12.0' is a float.  Thus the
:: does not know whether to make the variable an integer variable or not.
This should give a type error, but unfortunately the current implementation
just fails (we will correct this).

You may find it easier to use the recently-introduced #:: (for integer
variables) and $:: (for real variables) to make it explicit whether you wish
to impose integrality or not, rather than relying on :: to infer the type
from the arguments you provide.

Also, are you using TkECLiPSe?  If so, it should be relatively easy for
simple programs such as the ones here to figure out where things are going
wrong using the Tracer.  Chapter 5 of the tutorial document "ECLiPSe: An
Introduction" should be able to give you more help on this.

> ic:(X1 =:= 0),
> ic:(X2 =< X1+4.0),
> ic:(X2 >= X1+2),
> ic:(X3 = X1+D1),
> ic:(X4 = X2+D2),

Note that the above two lines should have =:=, not =.

> ic:(D1 =< D2+1),
> ic:(D1 >= D2-1),
> ic:(X4 =< X3+2).
> 
> --------------------------
> The result of query was "No"

Cheers,
Warwick
Received on Wed Jul 30 12:45:20 2003

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