Re: [eclipse-clp-users] Out of range error

From: Joachim Schimpf <joachim.schimpf_at_...269...>
Date: Wed, 08 Dec 2010 11:57:02 +1100
Mick Hallward wrote:
> Dear Joachim,
> 
> Many thanks for the prompt reply, which was very helpful.
> Due to the nature of the problem, I cannot impose initial 
> bounds to the variables (these are not generally known
> ahead of time), so I'm inclined to go with the second option,
> the use of propia. My only concern is the replacement of
> "or" with the semicolon operator. I need to deal with
> arbitrary boolean constraints, potentially containing 
> negations of disjunctions, and I'm not sure if that's
> compatible with the "infers ic" syntax. In fact I tried
> it but it doesn't seem to work, e.g. with the definition
> foo(X) :-
>     ((X #>= 20 and X #=< 20) or (X #>= 100,X #=< 150)) infers ic,
>     labeling([X]).
> the query foo(A) gives the same error: "out of range in 
> indomain(A{-1.0Inf .. 1.0Inf})". 
> 
> While I could put the boolean conditions in DNF and then 
> use the semicolon operator as in your example, I'd rather not, 
> since the transformation to DNF could take too long.
> 
> Any suggestions? Many thanks again! 


Here is an alternative method:

foo(X) :-
    B1 #= (X #>= 20 and X #=< 20),
    B2 #= (X #>= 100 and X #=< 150),
    B1 or B2,

    labeling([B1,B2]),
    labeling([X]).

For each branch of a disjunction, introduce a boolean variable.
Then label these booleans _before_ the other variables.
This should work for arbitrarily nested expressions.


-- Joachim
Received on Wed Dec 08 2010 - 00:57:14 CET

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