From: Claudio Cesar de Sá <claudio.sa_at_...347...>

Date: Sat, 22 Jun 2013 11:32:06 -0300

Date: Sat, 22 Jun 2013 11:32:06 -0300

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? Thanks claudio 2013/6/21 Sergii Dymchenko <kit1980@...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@...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 >> >> > > > ------------------------------------------------------------------------------ > 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 22 2013 - 14:32:14 CEST

*
This archive was generated by hypermail 2.2.0
: Mon Jul 09 2018 - 02:05:30 CEST
*