Re: [eclipse-clp-users] Time out issue with long integer

From: Edgaonkar, Shrirang <Shrirang.Edgaonkar_at_nttdata.com>
Date: Sat, 20 Dec 2014 00:23:31 +0000
Dear Joachim,

I solved the problem as follows:-
Solution with precision 0.01
:- lib(ic).
solve(N1, N2) :-
 N1 :: -4294967296 .. 4294967297,
 N2 :: -4294967296 .. 4294967297,
 
 N2 $= 100,
 
 (N1/N2) $> 3.5,
 
 search([N1,N2],0,input_order,indomain,complete,[]).
Output
N1 = 351
N2 = 100
There are 2 delayed goals.
Yes (0.00s cpu, solution 1, maybe more)
-----------------------------------------------------------------------------------------------------------------
 
Solution with precision 0.001
:- lib(ic).
solve(N1, N2) :-
 N1 :: -4294967296 .. 4294967297,
 N2 :: -4294967296 .. 4294967297,
 
 N2 $= 1000,
 
 (N1/N2) $> 3.5,
 
 search([N1,N2],0,input_order,indomain,complete,[]).
Output
N1 = 3501
N2 = 1000
There are 2 delayed goals.
Yes (0.00s cpu, solution 1, maybe more)
-----------------------------------------------------------------------------------------------------------------
Solution with precision 0.1
:- lib(ic).
solve(N1, N2) :-
 N1 :: -4294967296 .. 4294967297,
 N2 :: -4294967296 .. 4294967297,
 
 N2 $= 10,
 
 (N1/N2) $> 3.5,
 
 search([N1,N2],0,input_order,indomain,complete,[]).
Output
N1 = 36
N2 = 10
There are 2 delayed goals.
Yes (0.00s cpu, solution 1, maybe more)
--------------------------------------------------------------------------------------------------------------------
This approach of representing real (fraction) as a numerator/denominator will work for any complex situation and solver can solve this with correct results.
This converts indefinite real output to a definite one. If we can implement this in Eclipse it will be a great contribution. Please let me know your thoughts.

Thanks and Regards,
Shrirang Edgaonkar

________________________________________
From: Edgaonkar, Shrirang
Sent: 15 December 2014 10:53:06
To: Joachim Schimpf; eclipse-clp-users_at_lists.sourceforge.net
Subject: RE: [eclipse-clp-users] Time out issue with long integer

Dear Joachim,

Here is the problem. The following script runs with locate to give me a bounded real 2.5 .. 2.9.

Problem with locate

:-lib(ic).
solve(A1) :-
%%Domain
%%Constraints
(A1) + 1  $> (3.5),

%%Search
locate([A1],1e-1).

Output

?- solve(A1).
A1 = A1{2.5 .. 2.9723527865385617}
There is 1 delayed goal.
Yes (0.00s cpu, solution 1, maybe more)
----------------------------------------------------------------------------------


So I represent the same number as a fraction(A1/A2). Using search it will give me A1 and A2.. Outside the scope of eclipse, I calculate the fraction
to be 2.5000000005820766092701993438579. But I need a fraction close to 2.6 or 2.51 since that is my border value. Moreover, this approach also solves other complex constraints.

Solution with search
:-lib(ic).
solve(A1, A2) :-
%%Domain
A1 :: -2147483648 .. 2147483647,
A2 :: -2147483648 .. 2147483647,

%%Constraints
(A1/A2) + 1  $> (3.5),
%%Search
search([A1, A2],0,input_order,indomain_min,complete,[]).

Output
A1 = -2147483648
A2 = -858993459
There are 2 delayed goals.
Yes (0.00s cpu, solution 1, maybe more)

Operation outside eclipse system
A1/A2 = 2.5000000005820766092701993438579


Thanks and Regards,
Shrirang Edgaonkar
________________________________________
From: Joachim Schimpf [jschimpf_at_coninfer.com]
Sent: 13 December 2014 00:02:14
To: eclipse-clp-users_at_lists.sourceforge.net
Subject: Re: [eclipse-clp-users] Time out issue with long integer

On 12/12/14 03:51, Edgaonkar, Shrirang wrote:
> Dear Joachim,
>
> It would be great if the problem would be fixed. I read your email and
> understood. The large domain is due to the LONG range used in java as I am
> mapping it with variables in java. In few cases, I could be in a situation
> where the no of constraints are very less. The above bug fix will also help
> me in my approach for real numbers. Please see below.

As I mentioned in my earlier reply, you should simply use indomain_split, which
will give you the expected answer:

?- X :: -9223372036854775808 .. 9223372036854775807,
    X $> 115000000000,
    search([X], 0, input_order, indomain_split, complete, []).
X = 115000000001
Yes (0.00s cpu, solution 1, maybe more)



>
> On a separate note, please look at the following example. I read your posts
> on real numbers and understand the limitation to solve equations if the a
> finite solution is non existant.
>
> To counter the same, I have come up with the following solution.
...
>
> Please let me know your thoughts on this.

It's difficult to make a recommendation without knowing what kind of problem you
are actually trying to solve.


-- Joachim

------------------------------------------------------------------------------
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=164703151&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

______________________________________________________________________
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.
Received on Sat Dec 20 2014 - 00:23:54 CET

This archive was generated by hypermail 2.2.0 : Sat Dec 20 2014 - 15:13:12 CET