users-prolog
[Top][All Lists]
Advanced

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

Re: How to do soft constraints (not FD)?


From: Aleksander Saidi
Subject: Re: How to do soft constraints (not FD)?
Date: Mon, 12 Jun 2006 14:29:04 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

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.


address@hidden 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
address@hidden
http://lists.gnu.org/mailman/listinfo/users-prolog

  

-- 
Aleksander S. Saidi
Ecole Centrale de Lyon
Département Mathématiques-Informatique
Mél : address@hidden
Tél : 04.72.18.65.30, Fax : 04.78.33.16.15

Attachment: Alexandre.Saidi.vcf
Description: Vcard


reply via email to

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