users-prolog
[Top][All Lists]
Advanced

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

Re: findall in FD


From: Johannes Middeke
Subject: Re: findall in FD
Date: Sun, 21 Jul 2002 17:07:15 +0200 (MEST)

hi,


your mistake is pretty simple: in line 4 of your code you have
   findall(x, member(x, INPUTS), LL)
where INPUTS is an uninstantiated variable. so prolog tries to find all
possible lists with an 'x' inside them. just try
   member(x,L)
on the top-level (L being uninstantiated) an you will see what happens.


hope that helps





> Hello,
>
> I'm a newbie in Prolog, I want to use GNU Prolog for constraint sovling in 
> FD. I have written a program to generate input to produce the expected 
> output, but when I want to generate all the input using "findall", I cannot 
> get all the useful result. Here is my code, can any one give me some hint on 
> my code to produce all the result? Thanks in advance!
>
>
> HERE is the code:
>
>
> q(OUTPUTS):-
>       get_fd_labeling(Lab),
>       statistics(runtime, _),
>       findall(x, member(x, INPUTS), LL),
>       test_temp_1(Lab,INPUTS,OUTPUTS),
>       statistics(runtime, [_,Y]),
>       write(OUTPUTS), nl,
>       write(INPUTS), nl,
>       write('time: '), write(Y), nl.
>
> /*----------- Model definition -----------*/
>
> test_temp_1(Lab, INPUTS, OUTPUTS):-
>       OUTPUTS = [Iout],
>       INPUTS = [I1,I2,I3],
>
>       /*---- Domains for integers ----*/
>       fd_domain(Iout, 0, 1),
>       fd_domain(Iout0, 0, 1),
>       fd_domain(I1, 0, 3),
>       fd_domain(I2, 0, 3),
>       fd_domain(I3, 0, 3),
>       fd_domain(TempK, 0, 3),
>
>       TempK #= (I1 + I2) rem 4,
>
>       TempK #< I3 #<=> Iout,
>
>       1*Iout0 - Iout #= 0,
>
>       lab(Lab, INPUTS).
>
> /*----------- End of model definition -----------*/
>
> lab(normal,L):-
>         fd_labeling(L).
>
> lab(ff,L):-
>         fd_labelingff(L).
>
> get_fd_labeling(Lab):-
>         argument_counter(C),
>         get_labeling1(C,Lab).
>
> get_labeling1(1,normal).
>
> get_labeling1(2,Lab):-
>         argument_value(1,Lab).
>
> :- initialization(q([1])).
>
>
>
>
>             chinadicom
>             address@hidden
>
>
>
> _______________________________________________
> Users-prolog mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/users-prolog
>




reply via email to

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