# [eclipse-clp-users] How to define coordinates that solve a system of quadratic equations, then use in search?

From: Domain Admin <david_at_...151...>
Date: Wed, 12 Aug 2009 13:43:05 +0800
```A procedural question before the main question...

1) What's the recommended way of searching the recent archive of
eclipse-clp-users? There doesn't appear to be a dedicated search box, and
placing "eclipse-clp-users" in SF's searchbox doesn't seem to have any
effect, and since it's hosted by SF I can't use Google's site: constraint. I
couldn't find help in the FAQ for this project either.

2) I'm trying to define a problem, and haven't been able to find the right
guidance in the tutorial, examples, nor ref manual to tell me if it's
feasible in ECLiPSe or not. Here it is: There are a large number of colored
dots at integer coordinates throughout a 2D space. I'm only interested in
red dots that appear in an area defined by a set of linear or quadratic
equations. I would like to declare a set variable that is constrained by the
equations (using \$>= and so on), then declare a coordinate variable
constrained to be "in" the set, and then use that coordinate variable in a
search (e.g. "(red CoordVar)").

Ideally, the set or coordinate variables would be setup under a specialized
predicate (aka within a subroutine) so it could be reused easily.

I realize that I might have to map each 2D coordinate to a unique integer
value in order to get things working. (This is why I used ic_sets in my
earlier example.)

Tutorial 9.4, "Finding solutions of real constraints" provides an example of
a space defined by hyperplanes which is temptingly close to my problem, but
it's not clear whether the vars can be constrained in a subroutine nor how
to activate the delayed goals. Here's a first pass:

:- lib(ic).

setupScenario :-
assert( red([1,1]) ), /* within space of interest; should be one and only
solution */
assert( red([2,2]) ). /* not within space of interest */
/* imagine thousands more colored dot definitions here */

setupSpaceOfInterest(X, Y) :-
X #:: -4..4,
Y #:: -4..4,
4 \$>= X^2 + Y^2, 4 \$>= (X-1)^2 + (Y-1)^2, Y \$>= X.

findRedsInSpaceOfInterest :-
setupScenario,
setupSpaceOfInterest(X, Y),
findall([X,Y],red([X,Y]),CoordinatesOfAllRedsInSpaceOfInterest).

?- findRedsInSpaceOfInterest.
There are 13 delayed goals.
Yes (0.00s cpu)
```
Received on Wed Aug 12 2009 - 06:31:56 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 25 2019 - 09:14:48 CEST