Re: [eclipse-clp-users] Eclipse library IC question on reading the intervals

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Tue, 22 May 2018 13:48:24 +0100
On 22/05/18 12:22, Julio wrote:
> Hi,
> 
> 
> I am using eclipse 7.0 #42 for linux 64 bits, and after loading (in the 
> interpreter) the IC library the answer to the following query appears 
> "erroneous" to me.
> 
> [eclipse 2]: [E1,E2,N1] $:: -1..1, X $= 4 + E1 + E2 + N1, X $= -E1 + 3*E2.
> 
> E1 = E1{-1.0 .. 0.5000000116152874}
> E2 = E2{0.49999998838471316 .. 1.0}
> N1 = N1{-1.0 .. 0.5000000116152874}
> X = X{2.4999999651541396 .. 4.0}
> 
> 
> Delayed goals:...
> 
> It appears to me that the interval for E1 should be -1..-0.5 and that of N1 
> should be -1..0.
> 
> We can, roughly, see that this is the case for E1 when we 'narrow' the domain of 
> E1 as follows.
> 
> [eclipse 3]: E1 $:: -0.4..0.5, [E2,N1] $:: -1..1, X $= 4 + E1 + E2 + N1, X $= 
> -E1 + 3*E2.
> 
> No (0.00s cpu)
> 
> What am I missing in the reading of the displayed intervals?
> 
> Is there an heuristic/method to lead the constraint solver to a tighter answer, 
> in my example?


Hi Julio,

as a general rule, in order to solve a constraint-problem, you have to combine 
the statement of the constraints with a search-procedure.  The constraints (more 
precisely, the implementation's network of "constraint-propagators") help the 
search procedure by pruning domain ranges that definitely do not contain solutions.

If (as in your example) you only state a conjunction of constraints, then you 
only get a "conditional answer" (indicated by the presence of delayed goals). 
The only guarantee you have here is that there are no answers _outside_ the 
resulting domains.  There is no guarantee about tightness, or about the 
existence or number of actual solutions.

When working with integer domains, search is usually done with
http://eclipseclp.org/doc/bips/lib/ic/search-6.htm, which will
locate individual solutions.

With continuous domains, you can use
http://eclipseclp.org/doc/bips/lib/ic/squash-3.html,
http://eclipseclp.org/doc/bips/lib/ic/locate-3.html or
http://eclipseclp.org/doc/bips/lib/ic/locate-4.html.

In your case, where an infinite number of solutions exists, squash/3 is 
appropriate, and narrows the domain bounds to the values you expect:

?- [E1, E2, N1] $:: -1..1,
    X $= 4 + E1 + E2 + N1, X $= -E1 + 3*E2,
    squash([E1, E2, N1, X], 0.001, lin).

E1 = E1{-1.0 .. -0.49908237516423415}
E2 = E2{0.49999998838471316 .. 1.0}
N1 = N1{-1.0 .. 0.0018352496715316469}
X = X{2.4999999651541396 .. 4.0}
There are 2 delayed goals.
Yes (0.00s cpu)



Cheers,
Joachim
Received on Tue May 22 2018 - 13:15:20 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST