Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IloIntVar and cplex.getValue

    Posted 06/03/10 02:11 AM

    Originally posted by: Jaeyoung


    Hi, all

    I am using "IloIntVar" as a variable in my c++ program.
    I set upper and lower bound with 1 and 0.

    The problem is a simple linear function with linear constraints (but hundreds of variables and constraints).
    After CPLEX solved, I use "cplex.getValue(X[i])" and CPLEX usually returns correct values.
    but at times it returns 0.9999999987, not 1 even though I set the variable as "ILOINT".
    It is true that "cplex.getValue" returns "IloNum"(double type), but I'm still expecting 1.00000.

    Is that normal? Should I use IloBoolVar? or set any other options?

    Any advice?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: IloIntVar and cplex.getValue

    Posted 06/03/10 05:37 AM

    Originally posted by: RodrigoLinfati


    I use:

    IloRound(cplex.getValue(x[i])
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: IloIntVar and cplex.getValue

    Posted 06/03/10 05:48 AM

    Originally posted by: SystemAdmin


    The returned value may suffer from round-off errors but it will be either almost 0 or almost 1.
    The correct way to solve your problem is to use IloRound() or ::round() as suggested in the other post.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: IloIntVar and cplex.getValue

    Posted 06/03/10 03:39 PM

    Originally posted by: Jaeyoung


    Thank you all of you. It's a great help. :)
    #CPLEXOptimizers
    #DecisionOptimization