users-prolog
[Top][All Lists]
Advanced

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

Re: FD problem: "vector too small"


From: AbdelAli ED-DBALI
Subject: Re: FD problem: "vector too small"
Date: Sat, 29 Nov 2008 23:42:34 +0100
User-agent: Thunderbird 2.0.0.18 (X11/20081125)

Jesper Eskilson a écrit :
Hi,

I'm using the FD solver in GNU prolog to solve a couple of problems
over at http://ProjectEuler.net. The problem I'm currently solving is
this: http://projecteuler.net/index.php?section=problems&id=39:

If p is the perimeter of a right angle triangle with integral length
sides, {a,b,c}, there are exactly three solutions for p = 120.

{20,48,52}, {24,45,51}, {30,40,50}

For which value of p 1000, is the number of solutions maximised?

This sounds like an excellent problem for applying some CLP/FD, I
thought, and wrote this program:

perimeter([P,X,Y,Z]) :-
        X #>= 1,
        Y #>= X,
        Z #>= Y,
        P #= X + Y + Z,
        X ** 2 + Y ** 2 #= Z ** 2,
        fd_all_different([X,Y,Z]),
        fd_labeling([P,X,Y,Z]).

p39(0, Length, Length).
p39(P, MaxLen, Length) :-
        findall([X,Y,Z], perimeter([P,X,Y,Z]), Solutions),
        length(Solutions, NewLen),
        max_list([NewLen, MaxLen], NewMaxLen),
        P0 is P - 1,
        p39(P0, NewMaxLen, Length).

p39(MaxLen) :-
        p39(1000, 0, MaxLen).

but when I run it, I get lots and lots of warnings on the form:

    Warning: Vector too small - maybe lost solutions (FD Var:_54)

What does this warning mean? And how do I avoid getting it?


Hi,

This is due to the value of vector_max variable which is set to 127 by default. Try to increase the value of fd_vector_max to 512 or upper value :
export VECTORMAX=512 (in bash before running gprolog)
or by changing the flag :
fd_set_vector_max(512). (of course after running gprolog!)

See page: http://www.gprolog.org/manual/gprolog.html#fd-set-vector-max/1

You may have to increase also the Global Stack value (see documentation at http://www.gprolog.org/manual/gprolog.html#htoc11

Regards.

Ali.




reply via email to

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