0

I am working on a linear problem to minimize. It is well-defined and uses numbers in range [0;1] mostly. The Excel's linear solver as well as Mathematica's LinearProgramming do find a solution, however as I see it violates one of my constraints in a badass manner:

The constraint has to equal EXACTLY 0 for my solution to be valid whereas both solvers put a number ~10E-17 there and treat it as satisfied. I tried manipulating with the accuracy but when I go under 10E-17 it states that the problem is not linear which is false. Automatic scaling also doesn't help.

I know it deals with the limited accuracy of floating point numbers used in computers. I would like to make sure whether I am doomed here or are there any tricks to overcome this issue.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Ghostwriter
  • 2,461
  • 2
  • 16
  • 18
  • 2
    At a higher level, could you explain why 10e-17 is not good enough? – Patricia Shanahan Oct 31 '15 at 12:21
  • I have an analytical solution for this problem for a small case. It is different from what the solver says and I believe it is the reason because I double-checked everything. I would like, however, to use the linear programming for bigger instances. – Ghostwriter Oct 31 '15 at 12:24
  • Some solvers have an exact mode, using arbitrary rational numbers. Very slow though. – harold Oct 31 '15 at 12:46
  • @harold: I've had a fair amount of success with QSopt_ex. "Exact mode" can be done by first solving in double precision, then checking (in exact arithmetic) whether an optimal basic solution has been attained. If not, move to some higher-precision, but still fixed-precision, floating-point arithmetic. You're probably still hosed if you have a very ill-conditioned optimal basis. – tmyklebu Nov 01 '15 at 00:02

1 Answers1

4

The linear programming solvers are almost certainly using IEEE 754 64-bit binary floating point. It stores the equivalent of 53 significant bits, equivalent to about 15.9 decimal digits. With that representation, exactness is not possible and finding a solution around 10e-17 is as good as you are going to get.

The first thing to do is to check whether the approximate solutions you will get with normal solvers are good enough for your real world problem. Remember that any measured physical quantity used as input is known with far less accuracy.

@harold indicated in a comment that "Some solvers have an exact mode, using arbitrary rational numbers. Very slow though.". If you really need exactness, looking for a solver with a rational number representation is your only solution.

Patricia Shanahan
  • 25,849
  • 4
  • 38
  • 75