# Re: [eclipse-clp-users] how to generate *well-spaced* but accurate solutions using 'locate'

From: Solly Brown <sollyb_at_...25...>
Date: Sat, 25 Apr 2009 19:46:39 +1000
```One further question: Is there a simple way of introducing randomness
into the way ECLiPSe finds solutions?

The 'hierachical' approach (calling locate with low precision, and then
again with high precision) seems to work for producing a smaller number
of well-spaced solutions... but it always gives the same set of solutions.

Ideally I need a small number of well-spaced solutions which are more or
less randomly distributed.

Cheers, Solly

Solly Brown wrote:
> Hi all,
>
> I have a question about the best way to use the 'locate' predicate in a
> real-valued domain where there are infinitely many solutions.
>
> In my domain I want to find a limited number of solutions (say 10-20)
> which are well-spaced apart -- basically a 'representative sample' of
> the infinite number of solutions possible.
>
> As a simple example, say I want to find positions (x,y) which lie on the
> circle x^2+y^2=5. Ideally, I want to be able to find a (semi-random)
> selection of solutions (say, 10 of them) spaced roughly evenly around
> the circle.
>
> Using locate and backtracking doesn't work too well, because if I
> specify a high precision then it has a huge number of solutions to wade
> through. But if I lower the precision (in order to get fewer solutions)
> then the resulting solutions are too coarse (the range of values is too
> 'approximate', and I need exact values).
>
> So... any hints on the best way to tackle this problem? Should I attack
> this in a hierarchical fashion: find 10 solutions with a low precision
> value, and then run 'locate' again within these intervals at a higher
> precision value? Or is there a smarter way of doing it, or perhaps some
> builtin I have missed? I'm not terribly familiar with ECLiPSe so any
> advice would be greatly appreciated.
>
> Thanks,
>
> Solly
>
>
>
> ------------------------------------------------------------------------------
> Crystal Reports &#45; New Free Runtime and 30 Day Trial
> Check out the new simplified licensign option that enables unlimited
> royalty&#45;free distribution of the report engine for externally facing
> server and web deployment.