Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Binary variable value returned through solution.get_values() equal to 0.999999

  • 1.  Binary variable value returned through solution.get_values() equal to 0.999999

    Posted 05/26/16 08:52 AM

    Originally posted by: MityaStiglitz


    Hello,

    I have a quick comment I would like to make. I have spent several days debugging because I was not aware that the API could return 0.999999 to represent value 1 for a binary variable. This was a problem for me because I was converting to int through int() later in my code and 0.9999999 got truncated to 0. The problem is that the output was mostly 1.0, but it could also happen (rarely) that it was 0.99999 so it was not obvious that the problem was at this stage of the program. It would really help if you could output only 1 or 0 when a user is expecting only these two options.

    Mitja


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Binary variable value returned through solution.get_values() equal to 0.999999

    Posted 05/30/16 01:27 AM

    This is intended behavior. You should not convert to integer values via int() but via round() (or via int(round())). The reason is that CPLEX is well allowed to return non-integer values for integer variables, depending on the value of CPX_PARAM_EPINT.


    #CPLEXOptimizers
    #DecisionOptimization