Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  rounding error when objective value is querried

    Posted 05/26/11 12:23 PM

    Originally posted by: Iannis


    Dear All,

    I am using concert technology to model and solve small MIPs.

    When I use the
    getObjValue()
    
    function I get a rounding error.
    Specifically:
    SPsol[ js].solve();              // SPsol is IloArray<IloCplex>, js is double.
    oval = SPsol[ js].getObjValue(); // oval is IloNum
    env.out() << " subproblem objective: " << oval << endl;
    


    The output of this is as follows:
    Tried aggregator 2 times.
    MIP Presolve eliminated 3 rows and 4 columns.
    MIP Presolve modified 1 coefficients.
    Aggregator did 3 substitutions.
    Reduced MIP has 8 rows, 12 columns, and 22 nonzeros.
    Reduced MIP has 5 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Probing time =    0.00 sec.
    Tried aggregator 1 time.
    Presolve time =    0.01 sec.
    Found feasible solution after 0.01 sec.  Objective = 368246.1571
    Probing time =    0.00 sec.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: dynamic search.
    Parallel mode: deterministic, using up to 2 threads.
    Root relaxation solution time =    0.00 sec.
     
            Nodes                                         Cuts/ 
       Node  Left     Objective  IInf  Best Integer     Best Node    ItCnt     Gap
     
    *     0+    0                       368246.1571                      2     --- 
    *     0+    0                       -79693.0000                      2     --- 
          0     0  -287553.2524     2   -79693.0000  -287553.2524        2  260.83%
    *     0+    0                      -275644.5000  -280015.1250        3    1.59%
          0     0        cutoff        -275644.5000                      4    0.00%
    Elapsed real time =   0.01 sec. (tree size =  0.00 MB, solutions = 3)
     
    Implied bound cuts applied:  1
    Flow cuts applied:  1
     
    Root node processing (before b&c):
      Real time             =    0.00
    Parallel b&c, 2 threads:
      Real time             =    0.00
      Sync time (average)   =    0.00
      Wait time (average)   =    0.00
                              -------
    Total (root+branch&cut) =    0.00 sec.
     
     subproblem objective: -275645
    


    So CPLEX finds the right value, but when I use
    getObjValue()
    
    I take a rounded version. This is because in other MIPS it rounds down when the decimal digit is less than .5.
    Do I need to change the output format?

    Thank you in advance.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: rounding error when objective value is querried

    Posted 05/26/11 03:07 PM

    Originally posted by: SystemAdmin


    Try putting a format specifier in the cout line, telling C++ to give you a couple of decimal places. I think that will do it. If not, try declaring oval as double rather than IloNum. The getObjValue method is not doing the rounding.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: rounding error when objective value is querried

    Posted 05/27/11 12:52 PM

    Originally posted by: Iannis


    Thank you Paul! It did the job.
    #CPLEXOptimizers
    #DecisionOptimization