bug-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: failure to post arithmetic constraint


From: Bowie Owens
Subject: Re: failure to post arithmetic constraint
Date: Wed, 6 Feb 2002 09:27:11 +1100
User-agent: Mutt/1.2.5i

Hi Daniel,

I see what you are saying. The problem is that having bounds for A and
X before posting A * X #= Y is not always convenient. I am thinking of
the case where bounds on A and Y are known, from these bounds for X can
be derived.  What if you change line 457 of BipsFD/fd_math_fd.fd to:

start Z in min(X)*min(Y) .. 
           ite(max(X)<max_integer/<max(Y), max(X)*max(Y), max_integer)

Assuming I have the syntax right then this should only perform max(X)
* max(Y) if it will not overflow, otherwise it uses max_integer.
Recompiling with this change seems to have the desired effect.

| ?- A * X #= Y.                        

A = _#3(0..268435455)
X = _#22(0..268435455)
Y = _#41(0..268435455)

yes


Putting the above change in context makes the xy_eq_z function:

xy_eq_z(fdv X,fdv Y,fdv Z)

{
 start X in ite(max(Y)==0,0,min(Z)/>max(Y)) ..
            ite(min(Y)==0,max_integer,max(Z)/<min(Y))
 start Y in ite(max(X)==0,0,min(Z)/>max(X)) ..
            ite(min(X)==0,max_integer,max(Z)/<min(X))
 start Z in min(X)*min(Y) ..
            ite(max(X)<max_integer/<max(Y),max(X)*max(Y),max_integer)
}








On Tue, Feb 05, 2002 at 07:28:19PM +0100, Daniel Diaz wrote:
> Hi Bowie,
> 
> you have to define the (relative small) domains of your variables before 
> settings constraints. In
> particular non-linear constraints. In A*X #= Y the max of Y is max(X) * 
> max(A) which leads to an
> overflow on our integers. Recall that FD are for (small) finite domains... 
> :-))
> 
> Bowie Owens wrote:
> > 
> > Hi,
> > 
> > I am having difficulty posting some simple arithmetic constraints in
> > GNU Prolog 1.2.8 (and 1.2.9) under x86 Linux. The problems come from
> > the multiplication of otherwise unconstrained variables. There does seem
> > to be some interaction with the vector representation of variables. As
> > using full AC equality forces use of the vector representation when I
> > would not expect it to do so.
> > 
> > | ?- A * X  #= Y.
> > 
> > no
> > | ?-  A+X #=< 127, A * X  #= Y.
> > 
> > A = _#22(0..127)
> > X = _#41(0..127)
> > Y = _#86(0..16129)
> > 
> > yes
> > | ?- A+X #>= 127, A * X  #= Y.
> > 
> > no
> > | ?- A * X  #=# Y.
> > 
> > A = _#3(0..268435455)
> > X = _#22(0..268435455)
> > Y = _#41(0..127@)
> > 
> > yes
> > | ?- A+X #>= 127, A * X  #=# Y.
> > 
> > A = _#22(0..268435455)
> > X = _#41(0..268435455)
> > Y = _#86(0..127@)
> > 
> > yes
> > | ?- A+X #=< 127, A * X  #=# Y.
> > 
> > A = _#22(0..127)
> > X = _#41(0..127)
> > Y = _#86(0..127)
> > 
> > yes
> > 
> > -- Bowie Owens
> > 
> > CSIRO Mathematical & Information Sciences
> > phone : +61 3 9545 8055
> > email : address@hidden
> > 
> > _______________________________________________
> > Bug-prolog mailing list
> > address@hidden
> > http://mail.gnu.org/mailman/listinfo/bug-prolog
> 
> -- 
> Daniel Diaz   address@hidden
> http://pauillac.inria.fr/~diaz
> gprolog --version 2>&1 | sed -n -e 's/By //p'
> 
-- Bowie Owens

CSIRO Mathematical & Information Sciences
phone : +61 3 9545 8055
email : address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]