Re: [eclipse-clp-users] Finite solution for real

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Wed, 03 Dec 2014 17:24:53 +0000
On 03/12/14 09:04, Edgaonkar, Shrirang wrote:
> Dear clp users,
>
>    I have the following problem with constraints. If the solution is finite like
> [0.1,0.4], [0.2,0.2],[0.3,0.1] and [0.4,0.1].
>
> :-lib(ic).
>
> top(X):-
>
>    X :: 0 .. 1.0,
>    Y :: 0 .. 1.0,
>    X + Y $= 0.5,
>    locate([X, Y], 0.1),
>    writeln([X, Y]).
>
> Then why does the output still come in ranges. Note that the precision is 0.1 in
> this case.
>
> Output
>
> X = X{0.125 .. 0.1875}
> Y = Y{0.3125 .. 0.375}
> There is 1 delayed goal.
> Yes (0.00s cpu, solution 1, maybe more)

The precision of 0.1 only means that the ranges will be reduced until they are 
smaller than 0.1.  There are still infinitely many solutions, and none are lost.

If you want variables with discrete values, it is better to model them as 
integers.  Due to the nature of floating point interval arithmetic, you will 
usually not get precise values for reals.


-- Joachim
Received on Wed Dec 03 2014 - 17:25:03 CET

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST