Re: [eclipse-clp-users] Why the minimize is halting in each solution?

From: Sergii Dymchenko <kit1980_at_...6...>
Date: Fri, 21 Jun 2013 13:24:06 -0700
Quick off-by-1 bug correction: it should be `End - Begin #= SizeWindow - 1,`

Sergii.


On Fri, Jun 21, 2013 at 1:15 PM, Sergii Dymchenko <kit1980_at_...6...> wrote:

> Hi,
>
> In your model your should not have any predicates like `member`, only
> constraints. Basically, your model should not leave any Prolog choice
> points.
>
> And your program can be much much simpler and shorter. My attempt:
>
> :- lib(ic).
> :- lib(branch_and_bound).
>
> model(SizeWindow, Vs, Xs, Total) :-
>     length(Vs, N),
>     dim(Xs, [N]),
>     Xs :: 0..1,
>     [Begin, End] :: 1..N,
>     End - Begin #= SizeWindow,
>     ( foreacharg(Xi, Xs, I), param(Begin, End) do
>         Yes #= (I #>= Begin and I #=< End),
>         #=(Xi, 1, Yes) ),
>     array_list(Xs, Xslist),
>     Total #= Vs * Xslist.
>
> find(Xs, Total) :-
>     Cost #= -Total,
>     minimize(search(Xs, 0, first_fail, indomain, complete, []), Cost).
>
> go :-
>     Vs = [60, 60, 60, 25, 30, 47, 65, 55, 71, 95],
>     model(5, Vs, Xs, Total),
>     find(Xs, Total),
>     writeln([Xs, Total]).
>
>
> Sergii,
>
>
> On Fri, Jun 21, 2013 at 11:50 AM, Claudio Cesar de Sá <claudio.sa_at_...362...7...
> > wrote:
>
>> Hi
>>
>> The program attached select a contiguous set of the values in an array.
>> This contiguous values
>> in array is like a window or frame over this array. I am doing this find
>> the maximal of this subset in
>> a array.
>>
>> The program is woking fine .... but it is halting for one solution per
>> time.
>> The minimize predicate should be exploring all the possibilities ...
>> trying to minimize a cost function.
>> Why the branch-bound is not working?
>>
>> To run it, press go.
>>
>> Thanks in advance and excuse for the code comments in Portugese
>>
>>
>>
>> --
>>
>> Obrigado
>>
>> claudio
>>     (
>>     ))
>>    |""|-.
>>    |__|-'
>>
>>
>> **********************************************************************
>> http://claudiocesar.wordpress.com/about/
>> ***********************************************************************
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Windows:
>>
>> Build for Windows Store.
>>
>> http://p.sf.net/sfu/windows-dev2dev
>> _______________________________________________
>> ECLiPSe-CLP-Users mailing list
>> ECLiPSe-CLP-Users_at_lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>>
>>
>
Received on Fri Jun 21 2013 - 20:24:13 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST