- Mail actions: [ respond to this message ] [ mail a new topic ]
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]

From: Joachim Schimpf <jschimpf_at_...311...>

Date: Sat, 22 Nov 2014 14:55:59 +0000

Date: Sat, 22 Nov 2014 14:55:59 +0000

On 21/11/14 01:05, Edgaonkar, Shrirang wrote: > Dear Eclipse users group, > > I am working on solving constraints based on real numbers. Following is the > sample code with all the constraints and locate API to find the solution. > > :- module(test). > :- export hello/0. > :-lib(ic). > > hello :- > > A :: -9223372036854775808.0__9223372036854775807.0, > B :: -9223372036854775808.0__9223372036854775807.0, > C :: -9223372036854775808.0__9223372036854775807.0, > D :: -9223372036854775808.0__9223372036854775807.0, > > A $> B, > B $< C, > B + C $= 78, > ((D - B) * 45) / A $= 123.35, > > locate([A, B, C, D], 1e-1, lin), > > writeln(a=[A]), > writeln(b=[B]), > writeln(c=[C]), > writeln(d=[D]), > writeln("%%%%%%%%%%%%%%%%%%%%%%%%%"). > > Following is the output but the output is always in ranges and I need solution > that is a single set of real numbers. Please help me on how can I achieve this. > > Output > > a = [_436{16.8253096002924 .. 17.8537558438417}] > b = [_575{16.8253096002924 .. 17.8537558438417}] > c = [_714{60.1462441561583 .. 61.1746903997076}] > d = [_853{62.9453526935382 .. 66.7928843624611}] > %%%%%%%%%%%%%%%%%%%%%%%%% Your equations have infinitely many solutions, so it should not be surprising that ECLiPSe does not compute "a single set of real numbers". The locate-predicate doesn't help here, it's purpose it to separate a finite number of individual solutions (e.g. in the case of polynomials). To understand what the system is doing, consider a very simple example: ?- [A, B]::0.0..9.0, A+B $= 1. A = A{0.0 .. 1.0} B = B{0.0 .. 1.0} There is 1 delayed goal. Yes (0.00s cpu) Here, by just stating the constraints, you get a single set of ranges that contains all the infinitely many solutions. Values outside the ranges are guaranteed to contain no solutions. You can now use locate/2,3,4 to subdivide the ranges. But if the problem has infinitely many solutions, the union of all the alternative resulting ranges is the same as what you had without using the locate, and the number of alternatives depends only on locate's precision parameter: ?- [A, B]::0.0..9.0, A+B $= 1, locate([A, B], 0.3). A = A{0.25 .. 0.5} B = B{0.5 .. 0.75} There is 1 delayed goal. Yes (0.00s cpu, solution 1, maybe more) A = A{0.0 .. 0.25} B = B{0.75 .. 1.0} There is 1 delayed goal. Yes (0.00s cpu, solution 2, maybe more) A = A{0.75 .. 1.0} B = B{0.0 .. 0.25} There is 1 delayed goal. Yes (0.00s cpu, solution 3, maybe more) A = A{0.5 .. 0.75} B = B{0.25 .. 0.5} There is 1 delayed goal. Yes (0.00s cpu, solution 4) Your example is just like that, except that you get a larger number of smaller ranges. Note that, if you add more information, you will eventually get a single result: ?- A $> B, B $< C, B + C $= 78, (D - B) * 45 / A $= 123.35, D = 10.4, B = 0.3. A = 3.6846372111876766__3.6846372111876788 B = 0.3 C = 77.699999999999989__77.7 D = 10.4 There are 4 delayed goals. Yes (0.00s cpu) > > Thanks and Regards, > > Shrirang EdgaonkarReceived on Sat Nov 22 2014 - 14:56:10 CET

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