On 22/06/2013 15:32, Claudio Cesar de Sá wrote: > Sergii > > Thanks your solution, surely it is simpler and shorter, but in my > solution in predicate member(X_var , [list the templates = option]) > should be works like: > ?- member(X, [[1, 1, 0], [0, 1, 1]]). > X = [1, 1, 0] > Yes (0.00s cpu, solution 1, maybe more) > X = [0, 1, 1] > Yes (0.01s cpu, solution 2) > > where each solution is a branch in the tree search. > These are choices points for the search. > > Why is it not working as expected? If you want to optimize, then all your search must be done _inside_ the minimize/2 or bb_min/3 predicate. As Sergii already said: > In your model your should not have any predicates like `member`, only > constraints. Basically, your model should not leave any Prolog choice > points. This is the basic rule for a constraint program: 1. first deterministic constraint setup 2. then nondeterministic search (possibly with b&b) So, move your member/2 call inside minimize/2: minimize(( member(L_X , All_contiguities), search(L_X,0,first_fail,indomain,complete,[]) ), Zneg). In your code, you don't actually need search/6, because L_X is already fully instantiated. It is a bit strange to precompute a list of all possibilities, and then search over it. It would be more elegant to nondeterministically generate the different combinations directly and do this instead of the member/2. -- JoachimReceived on Sat Jun 22 2013 - 16:20:16 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST