all solutions

From: Aitor Gonzalez Gonzalez (gonzalez_at_ibdm.univ-mrs.fr)
Date: 08/20/04

  • Next message: Jean-Michel Leconte: "Re: all solutions"
    Date: Fri, 20 Aug 2004 15:00:22 +0100
    
    

    Dear prolog users,

    I am biologist and I am using a code in prolog written by informaticiens
    in my university. In this test code, ab([C, D],[E, F]), that I want to
    apply to bigger problems.

    ----------- DEBUT CODE -----------------

    ab(In, Out) :-
         In = [I_A, I_B],
         Out = [O_A, O_B],

    fd_domain(I_A, 0, 1),
          fd_domain(O_A, 0, 1),
          fd_relation([[0,0],[1,1]], [O_A, E_BA]),

    fd_domain(I_B, 0, 1),
          fd_domain(O_B, 0, 1),
          fd_relation([[0,0],[1,1]], [O_B, E_AB]),

          E_AB #<=> (I_A #=# 1),
          E_BA #<=> (I_B #=# 1),
    true.

    ----------- FIN CODE -------------------

    This code returns integer values for E and F, from value in C and D,
    whose solutions look like this.

    C D | E F
    ----|----
    0 0 | 0 0
    0 1 | 1 0
    1 0 | 0 1
    1 1 | 1 1

    If I specify the initial values I get one solution, eg.,
    | ?- ab([0, 0],[E, F]).

    E = 0
    F = 0

    yes

    However I would like to get all solutions where the value of C equals
    that of E and the value of D equals that of F. I've done in the
    following wat, but the output is not very informative,

    | ?- ab([C, D], [C, D]).

    C = _#0(0..1)
    D = _#101(0..1)

    yes

    I would like to have something like,

    C = 0
    D = 0

    and

    C = 1
    D = 1

    I've tried to used the built-in findall, but I was not able to
    understand, how it works.

    Thank you in advance,

    Aitor


  • Next message: Jean-Michel Leconte: "Re: all solutions"