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

From: Thorsten Winterer <thorsten_winterer_at_...126...>
Date: Thu, 20 Nov 2014 10:38:26 +0100
Hello Yogesh,

the problem with your code is that the variables X and Y inside
solve_hr/0 have no connection to the variables X and Y in your locate/2
goal. Therefore, the variables in the goal are unconstrained, and a
range of 0.0 .. 0.0054228417426558225 is a valid solution.

Change your solve_hr predicate such that the variables that you
constrain in the body also appear in the head of the clause, e.g.:

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


Then you can call

?- solve_hr(A,B),locate([A,B],0.01).
A = 10
B = 11
Yes (0.00s cpu, solution 1, maybe more)


Cheers,
Thorsten


Am 20.11.2014 um 09:36 schrieb Choughule, Yogesh:
>
> 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)
>
>
> ______________________________________________________________________
> Disclaimer: This email and any attachments are sent in strictest
> confidence
> for the sole use of the addressee and may contain legally privileged,
> confidential, and proprietary data. If you are not the intended recipient,
> please advise the sender by replying promptly to this email and then
> delete
> and destroy this email and any attachments without any further use,
> copying
> or forwarding.
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
Received on Thu Nov 20 2014 - 09:38:34 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 22 2024 - 18:13:20 CET