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

From: Sergii Dymchenko <kit1980_at_...6...>
Date: Sat, 29 Jun 2013 15:32:58 -0700
Claudio,

1. Yes is a constraint variable, it's 1 if I is between Begin and End, and
0 otherwise.
2. This is called reified constraint
http://eclipseclp.org/doc/bips/lib/ic/HE-3.html

Sergii.


On Sat, Jun 29, 2013 at 1:48 PM, Claudio Cesar de Sá <claudio.sa_at_...361....>wrote:

>
> Sergi
>
> About  your model below, two lines are fuzzy for me:
> 1.        Yes #= (I #>= Begin and I #=< End),
>     the variable Yes is not a constraint variable?
>     Which values this variable will receive?
>
> 2.        #=(Xi, 1, Yes) ),
>     What's means this prefix notation?
>
> Thanks once
>
>
> claudio
>
>
>
>
> 2013/6/21 Sergii Dymchenko <kit1980_at_...6...>
>
>> 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_...347...> 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
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>>
>>
>
>
> --
>
> Obrigado
>
> claudio
>     (
>     ))
>    |""|-.
>    |__|-'
>
>
> **********************************************************************
> http://claudiocesar.wordpress.com/about/
> ***********************************************************************
>
Received on Sat Jun 29 2013 - 22:33:06 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST