Re: [eclipse-clp-users] rewritten the default indomain(X, max).?

From: Kish Shen <kisshen_at_cisco.com>
Date: Wed, 01 Sep 2010 06:15:20 +0100
On 31/08/2010 22:35, mauricio montecinos wrote:

> get_domain_as_list/2 generates in the second argument the ordered list of
> the values of the current domain.
>
>
>
> Now I can get the behavior of indomain(X, max) write:
>
>
>
> choose_val_indomainmax(Var,Val):-
>
>              get_domain_as_list(Var,Domain),
>
>              mem3(Val,Domain).
>
>
>
> mem3(X,[_|Xs]):- mem3(X,Xs).
>
> mem3(X,[X|_]).
>

indomain(X. max) has two properties:

1) trying values from the largest downwards, *and*
2) excluding tried values from the domain, before trying new values

In fact, all of the different methods of indomain/2 has property 2, 
except for enum, which is equivalent to indomain/1.

The code you show above does not have property 2, and there is no exact 
built-in equivalent in ECLiPSe.

The reason you might want to exclude tried values is because the 
propagation of excluding the values may lead to reduction in domains and 
earlier failures, thus reducing the amount of work you need to do.
You might also do more work because the propagation can also not make 
any difference.

About using get_domain_as_list: Getting the whole domain as a list is 
relatively expensive, because you need to create the whole list. This is 
probably why the internal indomain/1 is implemented without using 
get_domain_as_list.  Getting the maximum of the domain is much cheaper, 
in particular if some of the original values might not be tried at all 
because of the propagation.

Cheers,

Kish




-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Wed Sep 01 2010 - 05:15:28 CEST

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