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

From: Joachim Schimpf <joachim.schimpf_at_monash.edu>
Date: Thu, 05 Aug 2010 17:22:12 +1000
Stephan Schiffel wrote:
> Thanks for the suggestion, but this is not what I want. I really just want to 
> remember some information about the best solution, not about all solutions.

Ah sorry, I was making assumptions ;-)


> The output I'd like would be:
> 
> ? hash_create(H), minimize((member(X,[3,2,1,4,5]), hash_add(H,solution,X)), 
> X).
> ...
> H = hash(4, 1, [solution -> 1])
> X = 1

But then why not simply

?- hash_create(H), minimize(member(X,[3,2,1,4,5]), X), hash_add(H,solution,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, 1, [solution -> 1])
X = 1
Yes (0.00s cpu)


> 
> That means as long as I'm not using any non-logical storage, I'd like 
> minimize(Goal, Cost) to behave exactly as calling Goal and selecting 
> the "right" branches on choice points instead of the first one first. So far, 
> I thought of lib(hash) as logical storage, because it behaves well on 
> backtracking. I know that it is not strictly logical, because it uses 
> setarg/3 internally.

You could use lib(m_map), which is a pure tree-based data structure.


-- Joachim
Received on Thu Aug 05 2010 - 07:22:21 CEST

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