Re: [eclipse-clp-users] REAL VARIABLE SOLVING FAILING

From: Kish Shen <kisshen_at_...5...>
Date: Thu, 20 Nov 2014 09:35:04 +0000
On 20/11/2014 08:36, Choughule, Yogesh wrote:
> Find below my code and results.. Please suggest a solution because the results returned by locate are incorrect.
>
> :- lib(ic).
> solve_hr :-
>      X :: 10..35,
>      Y :: 10..20,
>      X+Y $> 20.3.
>
> Execute by following command::
> solve_hr,locate([X,Y],0.01)
>
> Answer(Incorrect)::
> ?- solve_hr, locate([X, Y], 0.01).
> X = X{0.0 .. 0.0054228417426558225}
> Y = Y{0.0 .. 0.0054228417426558225}
> There is 1 delayed goal.
> Yes (0.00s cpu, solution 1, maybe more)
>

I assume you think the answer is incorrect because

 > X = X{0.0 .. 0.0054228417426558225}
 > Y = Y{0.0 .. 0.0054228417426558225}

does not satisfy your model in solve_hr? The reason is the X and Y here, 
i.e. X and Y in

locate([X.Y], 0.01)

are *different* variables from the X and Y in solve_hr. To make them the 
same variable, you need to pass them out of solve_hr, e.g.

solve_hr(X, Y) :-
       X :: 10..35,
       Y :: 10..20,
       X+Y $> 20.3.

and call your query as

?- solve_hr(X,Y), locate([X, Y], 0.01).

Cheers,

Kish
Received on Thu Nov 20 2014 - 10:09:08 CET

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