Re: negative values of Finite Domain Variables

Salvador Abreu <[email protected]> Fri, 27 May 2022 15:27:27 -0700
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
hi Daniel,

You can try with the negative domain variant; to do that=20
(1) clone get the gprolog source (from github or sourceforge)
(2) in the GNU prolog src subdir, do:
    git switch negative-domains
    make distclean
    ./configure
    make
(3) you will have a version that can handle domains which range into =
negative values; a easy way to use it without installing system-wide is =
to continue with the commands:
    . SETVARS
(in the same directory)

here=E2=80=99s a transcript:

15:21:52$ . SETVARS=20
15:21:54$ gprolog
GNU Prolog 1.5.0 (64 bits)
Compiled May 27 2022, 15:21:42 with gcc
Copyright (C) 1999-2022 Daniel Diaz

| ?- fd_domain(X,-100,100), 2 #=3D X + 9.

X =3D -7

yes
| ?-=20

if you want to remain with the main branch, you need to remodel your =
problems to work with positive numbers only (e.g. with an offset).

hope this helps.
-spa


> On 27 May 2022, at 12:28, Daniel Ajoy <[email protected]> wrote:
>=20
> Hi,
>=20
> I was expecting:
>=20
> fd_domain(X,-100,100), 2 #=3D X + 9.
>=20
> to produce
>=20
> X  =3D -7
>=20
> But it didn't find that answer. Is it the case that the FD variables =
can only be positive?
>=20
> If that's the case, is there a workaround?
>=20
> Daniel
>=20