Re: Re: indomain/2 gives type error in version 5.5 (not before!)

From: Sebastian Sardina <ssardina_at_cs.toronto.edu>
Date: Mon 02 Dec 2002 03:09:36 PM GMT
Message-Id: <1038841776.1763.50.camel@ssardina.com.ar>
> Your predicate should take care of it.  The easiest way to do this is to (on
> backtracking) remove the value tried so it can not be selected again, and
> then just call your indomain predicate again.  E.g.:
> 
> indomain_random(X) :-
> 	% Find out how many domain elements we have to choose from.
> 	dvar_domain(X, Dom),
> 	dom_size(Dom, Size),
> 	% Get the domain elements.
> 	X :: L,
> 	% Choose one at random.
> 	Index is 1 + (random mod Size),
> 	nth_value(L, Index, Try),
> 	% Try assigning it.
> 	indomain_random(X, Try).
> 
> indomain_random(X, X).
> indomain_random(X, Try) :-
> 	X #\= Try,
> 	indomain_random(X).
> 

very neat. 


> There will be some overhead for the meta-call (calling a predicate passed in
> as a run-time parameter is less efficient than calling one known at compile
> time), but I expect the impact of that is likely to be small in your case.
> 
> Incidentally, what are you using symbolic domains for?  (We have arguments
> here as to whether they're useful or not, so hearing how and why they are
> being used is of interest.)
> 

Well I have no strong reason to use symbolic domains. In my application,
the user/programer writes a set of axioms and programs for a robot and I
have to perform some reasoning over them.

For instance, there may be a set of objects which I describe via a
(symbolic) finite domain, and I have to reason about them with things
like "if the robot picks up object A then she will be holding A, etc.."

I use constraints because sometimes it's very useful and practical to
say things like: "the robot is holding everything except object C"
(e..g, holding(X) "applies" with X#\=C)

That's my whole reason, nothing fancy. ;-)

I can easily imagine pre-processing the specification given by the user
and transforming symbolic domains into integer domains. However, I have
to do the mapping transparent for the user. Is there any already
existing tool to do this?


> Cheers,
> Warwick
> 
> 

Cheers and thanks

Sebastian
Received on Mon Dec 02 15:17:14 2002

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:19 PM GMT GMT