1

I have a IloBoolVarArray in a MIP problem. When the solver has finished, I parse this variables to double but sometimes I get values very small as 1.3E-008 instead 0. My question is: Why? Is it a parsing problem only? Internally the solver has used this value, so is not the result trustworthy?

Thanks a lot.

David Nehme
  • 21,379
  • 8
  • 78
  • 117
jonango
  • 197
  • 1
  • 9
  • Why do you need to convert a boolean value to double? Have you tried to compare the boolean value with `IloTrue` or `IloFalse`? – vcp Mar 10 '16 at 00:10
  • It's an experiment, because my objective function multiply a IloNumVarArray with a IloBoolVarArray and I'm getting some precision issues. I want to find the problem – jonango Mar 10 '16 at 00:47

1 Answers1

1

CPLEX works with double precision floating point data internally. It has a tolerance parameter EpInt. If a variable x has values

0 <= x <= EpInt, or
1-EpInt <= x <= 1

Then CPLEX considers the value to be binary. The default value for EpInt is 10^-6, so your seeing solution values of 10^-8 is consistent with default behavior of CPLEX. Unless you really need exact integer values, then you should account for this when you pull solutions from CPLEX. One particularly bad thing you could do in C++ is

IloBoolVar x(env);
// ...
cplex.solve();
int bad_value = cplex.getValue(x); // BAD
int ok_value = cplex.getValue(x) + 0.5; // OK

Here, bad_value could be set to 0 even if the CPLEX solution has an effective value of 1. That's because CPLEX could have a value of 0.999999 which would be truncated to 0. The second assignment will reliably store the solution.

In the latest version of CPLEX, you can set the EpInt to 0 which will make CPLEX only consider only 0.0 and 1.0 as binary. If you do really need exact values of 0 or 1, then you should keep in mind the domains CPLEX is designed to work. If you are trying to use it to solve cryptology problems for example, you might not get good results, even with small instances.

Community
  • 1
  • 1
David Nehme
  • 21,379
  • 8
  • 78
  • 117
  • So in certain cases, Would I have operations as 236.212 * 10^-6 ? I'm working with many values (but isn't big data), but when I was validating the solution, there are precision errors about 1E-2, so I was supposing that precision error, was being accumulating along the operations. Thank you so much. – jonango Mar 10 '16 at 19:32