15

I have k linear inequalities in n variables (0 < k < n). I don't particularly care what the solution set is, I only want to test whether or not it's empty - i.e. whether any assignment to my n variables satisfies the system. Anyone know a way to solve this?

Thanks!

GMB
  • 486
  • 6
  • 13
  • Use Fourier-Motzkin eliminaion for solving the system of inequalities... http://en.wikipedia.org/wiki/Fourier%E2%80%93Motzkin_elimination –  Sep 16 '12 at 23:13
  • By the dual theorem, I think that your problem is *equivalent* in difficulty to finding the optimal solution in a linear programming problem. So, I'd look to linear programming solvers for a solution. – nneonneo Feb 05 '13 at 13:34

5 Answers5

7

This can be done using a linear programming with a constant objective function. That is, only checking for feasibility of the program.

Shai
  • 111,146
  • 38
  • 238
  • 371
3

Use a SMT solver for the theory of linear arithmetic (Yices, Z3, ...). These programs are designed to find models for the input you specified. Of course, you can also benefit from the existing algorithms in other ways.

C-Otto
  • 5,615
  • 3
  • 29
  • 62
  • Hi, C-Otto, your answer sounds more interesting, can you give an example to do this (email: x2nudt@gmail.com)? – Frank Jul 16 '15 at 19:23
  • 2
    No, but starting with the search term 'SMT' should give you good guidance. – C-Otto Jul 17 '15 at 08:23
2

You could use Fourier-Motzkin elimination for solving the system of inequalities. You will need to know basic algebra to understand the solution though.

http://en.wikipedia.org/wiki/Fourier%E2%80%93Motzkin_elimination

Rouz
  • 1,247
  • 2
  • 15
  • 37
1

You just need to intersect the ranges. Here's how to in pseudocode:

// An array that has the ranges (inequalities) to test:
fromToArray = [[0, 10], [5, 20], [-5, Infinity]] 

currentRange = [-Infinity, Infinity];
for each pair myRange in fromToArray
   if currentRange[0] < myRange[0] 
          then currentRange[0] = myRange[0]
   if currentRange[1] > myRange[1] 
         then currentRange[1] = myRange[1]
   if currentRange[0] >= currentRange[1]    // from greater than to, so set is empty.
         then return "NO SOLUTION"
end for each

return "Solution is: " + currentRange 
Diego
  • 18,035
  • 5
  • 62
  • 66
0

Compute the determinant of the related matrix; if it is non-zero there's a unique solution; if it is zero, there are either infinitely many solutions or none - http://en.wikipedia.org/wiki/System_of_linear_equations

Alternatively, use Gaussian elimination - http://en.wikipedia.org/wiki/Gaussian_elimination

scibuff
  • 13,377
  • 2
  • 27
  • 30
  • 1
    Unfortunately, the matrix isn't square, so the determinant approach won't work. I'm not sure Gaussian elimination works in the traditional sense on inequalities - row subtraction and multiplication by negative scalars would both become illegal, since they would flip the inequality. – GMB Mar 01 '12 at 00:46
  • The determinant approach _will_ work. You just need to pad the matrix with zeros. – Brian B Apr 16 '12 at 19:04