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

From: Claudio Cesar de Sá <claudio.sa_at_udesc.br>
Date: Sun, 23 Jun 2013 09:04:02 -0300
Joachim

Thanks for additional explanation. The program runned perfectly.
The reason to use "member" like a constraint is due some reasons:

1. X_var is a pattern over a set known, so it run faster when the
   list of templates/patterns are pre-computed

2. Really, the original idea is to formulate deterministics constraint like:

 (  X_var #= [1, 1, 0, 0]
    OR
   X_var #= [0, 1, 1, 0]
   OR
   X_var #= [0, 0, 1, 1]
  )

 As I could not  find something to simulate this OR  elegantly,
I used the member predicate, from a traditional logical programming.

For a next time, how I can simulate a OR over an  option list?

Thanks once


claudio




2013/6/22 Joachim Schimpf <jschimpf_at_coninfer.com>

> On 22/06/2013 15:32, Claudio Cesar de Sá wrote:
> > 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?
>
>
> If you want to optimize, then all your search must be done _inside_
> the minimize/2 or bb_min/3 predicate.  As Sergii already said:
>
> > In your model your should not have any predicates like `member`, only
> > constraints. Basically, your model should not leave any Prolog choice
> > points.
>
> This is the basic rule for a constraint program:
> 1. first deterministic constraint setup
> 2. then nondeterministic search (possibly with b&b)
>
>
> So, move your member/2 call inside minimize/2:
>
>        minimize((
>                member(L_X , All_contiguities),
>                search(L_X,0,first_fail,indomain,complete,[])
>           ), Zneg).
>
> In your code, you don't actually need search/6, because L_X is already
> fully instantiated.  It is a bit strange to precompute a list of all
> possibilities, and then search over it.  It would be more elegant to
> nondeterministically generate the different combinations directly and
> do this instead of the member/2.
>
>
> -- Joachim
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> 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 Sun Jun 23 2013 - 12:28:30 CEST

This archive was generated by hypermail 2.2.0 : Tue Jul 09 2013 - 06:14:09 CEST