Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  cplex.Model.obj

    Posted 12/25/11 04:03 PM

    Originally posted by: PingLiu


    first, I run the same code for the 2 cases.
    cplex=Cplex('enr');cplex.addCols(f,[],lb,ub,ctype);
    cplex.addRows([-inf*ones(size(bineq,1),1);beq], [Aineq;Aeq], [bineq;beq]);
    


    then, I run different code for the 2 cases.
    (1)for case1,I got Cplex class (cplex1) by running the following
    cplex1=cplex;
    

    (2)for case2,I got Cplex class (cplex2)
    cplex.writeModel('enr.lp');
    cplex.readModel('enr.lp');cplex2=cplex;
    


    why is the cplex.Model.obj different in both of the Cplex classes?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: cplex.Model.obj

    Posted 12/27/11 06:48 PM

    Originally posted by: SystemAdmin


    Given your approach, there could be 2 reasons for the difference in objective values.

    Firstly, cplex1 essentially represents the model in memory and CPLEX would come with a certain optimal value for the same. cplex2, however is not the same model- it is the LP version of the model in memory. Since the LP format is a ASCII based format, certain variable values may be ever so slightly different in the higher orders of the decimals that could cause a difference in the solution path and the optimal value of the slightly different model, thus leading to the difference in objective values. To prevent this, you should write (and read) the model in the SAV format which is a binary format that preserves the numerical precision of the different co-efficients that are present in the model. Hence you should replace:
    
    cplex.writeModel(
    'enr.lp'); cplex.readModel(
    'enr.lp');cplex2=cplex;
    


    with
    
    cplex.writeModel(
    'enr.sav'); cplex.readModel(
    'enr.sav');cplex2=cplex;
    


    The second reason for the difference in objective values could be that CPLEX stops with the MIPGAP tolerance setting of (0.01%) in the default CPLEX parameter settings. Thus, any solution which is less than 0.01% from the optimal solution is considered optimal. Indeed, in the runs, if you check for the value of the relative mipgap tolerance of the solution (ans.miprelgap), it shows up as 9.9658e-005. Thus, it is possible that by writing out the model in a LP format, and then reading it again and solving it, the order of the variables could change leading to a different solution path with cplex2, and hence CPLEX could end up with a optimal solution with a slightly different relative mipgap which is also less than the 0.01% requirement. If you absolutely want to make sure that different Cplex object that represent the same model always have the same optimal value, then you will need to change the relative MIPGAP setting from its default value of 0.01% (1e-4) to 0 which will force CPLEX to always solve the model to absolute optimality. You should be able to change this setting by executing the following line of code:
    
    cplex.Param.mip.tolerances.mipgap.Cur=0;
    


    I hope this helps and explains the behavior.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: cplex.Model.obj

    Posted 01/03/12 05:00 PM

    Originally posted by: PingLiu


    thanks, I've solved this problem.
    BTW, how can I open the .sav files?
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: cplex.Model.obj

    Posted 01/03/12 05:56 PM

    Originally posted by: SystemAdmin


    > thanks, I've solved this problem.

    Thats good.

    > BTW, how can I open the .sav files?

    .sav files are binary files and thus only machine readable. You could open them using tools that open binary files, but if you want to see the models in a human readable model format, then you should write out the .lp files as well. Just make sure that while solving the models and transferring them between different steps and stages you use the .sav file and not the .lp file.
    #CPLEXOptimizers
    #DecisionOptimization