|
Hi there, If the aim is to have e.g. predicate_y fail, you may use something like : predicate(....):- predicate_x(....), if_possible(predicate_y(...)), predicate_z(....). with : if_possible(P) :- call(P) , !. if_possible(P). "if_else(P)" is actually : (P, ! ; true) but the "cut" is put outside. The drawback : one solution for P (given the cut) + make a new branch in the search tree. Another solution (less simple) : associate a boolean parameter to predicate_y (will carry its result) and use constraintes. Example : Let the following be an initial programme : predicate(A, B, C) :-
p_x(A),
p_y(A, C),
p_z(A, C, B).
p_x(1). p_x(3).
p_y(A,C) :- A + C #> 4.
p_z(A, C, B) :- B #= A + C.
A goal like
predicate(A,B, 1).
fails.
Now, replace p_y/2 withe p_y/3 (the third parameter R takes out the 0/1 boolean result => failure or success of the old p_y/2)
predicate(A, B, C) :-
p_x(A),
p_y_bis(A, C,R), fd_at_most_one([R]),
p_z(A, C, B).
p_x(1). p_x(3).
p_z(A, C, B) :- B #= A + C.
p_y_bis(A,C,1) :- A + C #> 4.
p_y_bis(A,C,0) :- A + C #< 5.
Now, p_y_bis can fail, but it succeeds as much as possible : we want R to be atmost = 1 = success (can be 0 = failure).
Hope that will help.Alex PS : I focused on the predicates and did not look deeply inside the various resulats. [EMAIL PROTECTED] a écrit : predicate(....):- predicate_x(....), predicate_y(...), predicate_z(....). Suppose I have a predicate and there are some conditions that it must satisfy (ie the predicate x,y,z). How can I make one of the predicates into a soft constraint, for example such that the predicate_y does not have to be true all the times but should maximize such that it is true as much as possible? In FD, it is possible to use reified constraints and the fd_maximize() function, I wonder if I can do something similiar in my case? Thanks guys. :) Anthony _______________________________________________ Users-prolog mailing list [email protected] http://lists.gnu.org/mailman/listinfo/users-prolog -- Aleksander S. Saidi Ecole Centrale de Lyon Département Mathématiques-Informatique Mél : [EMAIL PROTECTED] Tél : 04.72.18.65.30, Fax : 04.78.33.16.15 |
begin:vcard fn:A-S Saidi n:Saidi;Aleksander-Sadegh org:Ecole Centrale de Lyon;LIRIS-CNRS UMR 5205 adr;quoted-printable:B.P. 163;;36 Ave. Guy de Collongue;Ecully;Rh=C3=B4ne;69134;France email;internet:[EMAIL PROTECTED] title;quoted-printable:Ma=C3=AEtre de Conf=C3=A9rences tel;quoted-printable;work:(33=C3=A0 04 72 18 65 30 tel;fax:(33) 04 78 33 16 15 x-mozilla-html:TRUE url:http://www.mi.ec-lyon.fr version:2.1 end:vcard
_______________________________________________ Users-prolog mailing list [email protected] http://lists.gnu.org/mailman/listinfo/users-prolog
