Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  difference between cplexmilp and cplex.solve();

    Posted 04/29/13 12:56 PM

    Originally posted by: yanzhi


    I use two methods to solve a simple MILP problem, but the results of x and cpxsol.x are different, I am wondering what's the reason. can anyone give me a clue? thanks a lot.

    x is obtained from method 1:

    Aeq=[];beq=[];

    options = cplexoptimset('cplex');cplexoptimset('Display','on');

    [x,fval,exitflag,output] = cplexmilp(f,Aineq,bineq,[],[],[],[],[],lb,ub,ctype,[],options );

    cpxsol.mat is obtained from method 2:

     cplex=Cplex('');
        cplex.Model.sense = 'minimize';
        cplex.addCols(f,[],lb,ub,ctype);
        cplex.addRows([-inf*ones(size(bineq,1),1);beq], [Aineq;Aeq], [bineq;beq]);

    cplex.solve();
    cpxsol=cplex.Solution;


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: difference between cplexmilp and cplex.solve();

    Posted 04/29/13 07:11 PM

    Originally posted by: John Cui


    You can export both model to LP files, then compare with these 2 LP files to find out the difference.

    The first way, you need to set a parameter(exportmodel) in cplexoptimset function.

    {code}

    options = cplexoptimset('cplex'); options.exportmodel = 'debug1.lp'

    {code}

    The second way, you just use cplex.exportModel("debug2.lp");

    John Cui


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: difference between cplexmilp and cplex.solve();

    Posted 04/29/13 07:27 PM

    Originally posted by: yanzhi


    thank you for your reply.

    actually, I did it and compared them.

    the myModel.lp is generated through the first way, and the enr.lp is from the 2nd way.

    but I didn't find any difference between them.

    however, in the solution , there are differences , for example, x(22) compared with cpxsol.x(22) or x(24) with cpxsol.x(24).

    and I check the constraints, and found that the solution from the first way did meet the requirements of the problem, but the 2nd way didn't.

    so I'm still confused.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: difference between cplexmilp and cplex.solve();

    Posted 04/30/13 05:39 AM

    I cannot reproduce this problem here. What version of CPLEX and matlab do you use? Which operating system?

    EDIT: Could you please also provide the log output for the two solves? To get the log output for the cplexmilp run replace this line
    options = cplexoptimset('cplex');cplexoptimset('Display','on');
    by
    options = cplexoptimset('Diagnostics', 'on');


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: difference between cplexmilp and cplex.solve();

    Posted 04/30/13 11:41 AM

    Originally posted by: yanzhi


    the cplex version is 12.4, matlab is 7.11.0(R2010b).

    operating system is windows 7.

    the log file for  cplexmilp method is

    {Tried aggregator 1 time.
    MIP Presolve eliminated 123 rows and 111 columns.
    MIP Presolve modified 6 coefficients.
    Reduced MIP has 60 rows, 63 columns, and 181 nonzeros.
    Reduced MIP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Probing time =    0.00 sec.
    Tried aggregator 1 time.
    Reduced MIP has 60 rows, 63 columns, and 181 nonzeros.
    Reduced MIP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time =    0.09 sec.
    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.08 sec.

            Nodes                                         Cuts/
       Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap

    *     0     0      integral     0     5321.4324     5321.4324       31    0.00%
    Elapsed real time =   0.20 sec. (tree size =  0.00 MB, solutions = 1)

    Root node processing (before b&c):
      Real time             =    0.11
    Parallel b&c, 2 threads:
      Real time             =    0.00
      Sync time (average)   =    0.00
      Wait time (average)   =    0.00
                              -------
    Total (root+branch&cut) =    0.11 sec.}

    the log file for cplex.solve(); method is

    {Default variable names x1, x2 ... being created.
    Default row names c1, c2 ... being created.
    Tried aggregator 1 time.
    MIP Presolve eliminated 123 rows and 111 columns.
    MIP Presolve modified 6 coefficients.
    Reduced MIP has 60 rows, 63 columns, and 181 nonzeros.
    Reduced MIP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Probing time =    0.00 sec.
    Tried aggregator 1 time.
    Reduced MIP has 60 rows, 63 columns, and 181 nonzeros.
    Reduced MIP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time =    0.00 sec.
    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 Bound    ItCnt     Gap

    *     0     0      integral     0     5321.4324     5321.4324       31    0.00%
    Elapsed real time =   0.00 sec. (tree size =  0.00 MB, solutions = 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.}


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: difference between cplexmilp and cplex.solve();

    Posted 05/02/13 03:34 AM

    Sorry, I could not reproduce the problem here. Neither with 12.4 nor with 12.5.0.1 (the latest version). I also looked at the code directly but could not find anything that would explain this weird behavior.

    The matlab script I used was this:

    function problem(varargin)
    try
       load('Aineq.mat');
       load('bineq.mat');
       load('ctype.mat');
       load('f.mat');
       load('lb.mat');
       load('ub.mat');
       Aeq=[];beq=[];

       fprintf('------------------------------ Solve 1 --------------------------\n');
       options = cplexoptimset('Diagnostics', 'on');
       [x,fval,exitflag,output] = cplexmilp(f,Aineq,bineq,[],[],[],[],[],lb,ub,ctype,[],options );

       fprintf('------------------------------ Solve 2 --------------------------\n');
       cplex=Cplex('');
       cplex.Model.sense = 'minimize';
       cplex.addCols(f,[],lb,ub,ctype);
       cplex.addRows([-inf*ones(size(bineq,1),1);beq], [Aineq;Aeq], [bineq;beq]);
       cplex.solve();
       cpxsol=cplex.Solution;

       x - cpxsol.x
    catch m
       display m;
       throw (m);
       clear all;
       clear classes;
    end

    The vector that is printed by that in the end is all-zero.
    Can you try to run this script at your place? Does it produce a non-zero vector in the end?

    Could you try to upgrade to CPLEX 12.5.0.1 and see if the problem still exists with that new version?


    #CPLEXOptimizers
    #DecisionOptimization