[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
findall in FD
From: |
chinadicom |
Subject: |
findall in FD |
Date: |
Sun, 21 Jul 2002 18:48:52 +0800 |
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
- findall in FD,
chinadicom <=