0

I need to find algorithm that can check if system like this

x1 * k + b > y1, x2 * k + b > y2, ..., xn * k + b < yn

has solution(s) where i substitute x[i] and y[i] and unknown varialbes are k,b.

Dima Stoyanov
  • 121
  • 1
  • 11

2 Answers2

0

If only the last inequality is "<" and all the other ones are ">". Here is how to check:

Transform the system to: b > y1 - x1 * k, b > y2 - x2 * k, ..., b < yn - xn * k

And it is easy to see that whether the original system has solutions is equivalent to the system yn - xn * k > y1 - x1 * k, yn - xn * k > y2 - x2 * k, ... has solutions

And it is equivalent to yn - y1 > (xn - x1) * k, yn - y2 > (xn - x2) * k, ... has solutions or not.

Then you need to discuss the signs of xn - xk, whether they are zero, positive or negative, and you can further transform the system to simpler form. For example, if xn - x1 > 0 and xn - x2 <0, it will look like this: k < (yn - y1)/(xn - x1), k > (yn - y2)/(xn - x2), ...

And then it is easy to check whether the new simple system has solutions or not which is equivalent to the original system has solutions or not.

Consistency
  • 2,884
  • 15
  • 23
0

You question is equivalent to asking if the points are linearly separable (with one class of points corresponding to the inequalities with >, the others with <).

You can use the Perceptron Algorithm to find a separating line if one exists. That wikipedia page provides some alternative algorithms too.

Paul Hankin
  • 54,811
  • 11
  • 92
  • 118
  • Will the following algorithm be correct? I construct a minimal convex hull for both sets of points (for example, using the Graham algorithm) Further, if at least one point of the 1st hull lies in the second or in the abstract, then there are no solutions. And I will check as follows. Either two polygons intersect (which I can check by crossing all the segments in pairs), or one polygon completely lies in the other. Then we need to check whether point (for example, the 1st point of 1st poligon) lies in the second polygon. Well, for this, there are Poligon.contains(x,y) in Java. – Dima Stoyanov May 04 '17 at 16:08