Re: [eclipse-clp-users] strange behaviour of minimize/bb_min

From: Joachim Schimpf <joachim.schimpf_at_monash.edu>
Date: Thu, 05 Aug 2010 09:54:27 +1000
> Stephan Schiffel wrote:
>>
>> ?- hash_create(H), minimize((member(X,[3,2,1]), hash_add(H,solution,X)), X).
>> Found a solution with cost 3
>> Found a solution with cost 2
>> Found a solution with cost 1
>> Found no solution with cost -1.0Inf .. 0
>>
>> H = hash(4, 0, [])
>> X = 1

To get the behaviour you want, use a store that survives backtracking
(record, bag, store, shelf), e.g.

?- record_create(H),
   minimize((member(X, [3, 2, 1]), recordz(H, X)), X),
   recorded_list(H, Xs).

H = 'REC'(16'060c99d0)
X = 1
Xs = [3, 2, 1]
Yes (0.00s cpu)


-- Joachim
Received on Wed Aug 04 2010 - 23:54:41 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET