Re: all solutions

From: Jean-Michel Leconte (Jean-Michel.LeconteNOSPAMPLZ_at_inria.fr)
Date: 08/20/04

  • Next message: Student: "Godel's Incompleteness and Nonmonotonic Logic"
    Date: Fri, 20 Aug 2004 15:24:08 +0200
    
    

    ask to prolog

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

    because when you post constraints to the constraints solver, it removes
    inconsitent solutions but here you have two solutions, so you have
    'label' the variables with fd_labeling (in GNU Prolog)

    here what i see on my computer

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

    C = 0
    D = 0 ? ;

    C = 1
    D = 1

    Aitor Gonzalez Gonzalez wrote:

    > 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: Student: "Godel's Incompleteness and Nonmonotonic Logic"