Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Error using cplexmiqp in matlab interface

    Posted Sat February 12, 2011 04:32 PM

    Originally posted by: Vincent.1


    Hi,

    I tried the cplexmiqpex.m example in matlab, and I found that if I remove the equality constraints Aeq and beq, matlab will give me an error saying that:

    ??? Error using ==> cplexmiqp at 199
    Error: H not a valid H matrix

    But if I add Aeq and beq back then it gives the correct answer. I would like to solve the mixed integer quadratic problem without any constraints. Could anyone help me with my problem? Thanks a lot in advance!

    Best regards,
    Vincent
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Error using cplexmiqp in matlab interface

    Posted Sat February 12, 2011 08:35 PM

    Originally posted by: John Cui


    Did you try to use [] to replace Aineq, bineq, Aeq, and beq in your matlab script if you don't want to add constraints in cplexmiqp?

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Error using cplexmiqp in matlab interface

    Posted Sat February 12, 2011 08:50 PM

    Originally posted by: Vincent.1


    Hi John,

    Thanks for your reply. I did what you said but it still gave an error. Here is the code of the example cplexmiqpex.m. I only change the constraints to []:
    function cplexmiqpex
    % Use the function cplexmiqp to solve a mixed-integer quadratic programming problem
    %
    % The MIQP problem solved in this example is
    %   Maximize  x1 + 2 x2 + 3 x3 + x4
    %             - 0.5 ( 33x1*x1 + 22*x2*x2 + 11*x3*x3 - 12*x1*x2 - 23*x2*x3 )
    %   Subject to
    %      - x1 +   x2 + x3 + 10 x4 <= 20
    %        x1 - 3 x2 + x3         <= 30
    %               x2      - 3.5x4  = 0
    %   Bounds
    %        0 <= x1 <= 40
    %        0 <= x2
    %        0 <= x3
    %        2 <= x4 <= 3
    %   Integers
    %       x4
     
    % ---------------------------------------------------------------------------
    % File: cplexmiqpex.m
    % Version 12.2
    % ---------------------------------------------------------------------------
    % Licensed Materials - Property of IBM
    % 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55
    % Copyright IBM Corporation 2008, 2010. All Rights Reserved.
    %
    % US Government Users Restricted Rights - Use, duplication or
    % disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
    % ---------------------------------------------------------------------------
     
    try
       % Since cplexmiqp solves minimization problems and the problem
       % is a maximization problem, negate the objective
       H = [33   6     0    0;
          6  22    11.5  0;
          0  11.5  11    0;
          0   0     0    0];
       f     = [-1 -2 -3 -1]';
       
       Aineq = [-1  1  1 10;
          1 -3  1  0];
       bineq = [20  30]';
       
       Aeq   = [0  1  0 -3.5];
       beq   =  0;
       
       lb    = [ 0;   0;   0; 2];
       ub    = [40; inf; inf; 3];
       ctype = 'CCCI';
       
       options = cplexoptimset;
       options.Diagnostics = 'on';
       
       [x, fval, exitflag, output] = cplexmiqp (H, f, [], [], [], [],...
          [], [], [], [], [], ctype, [], options);
     
       
       fprintf ('\nSolution status = %s \n', output.cplexstatusstring);
       fprintf ('Solution value = %f \n', fval);
       disp ('Values =');
       disp (x');
    catch m
       disp(m.message);
    end
    end
    


    Best,
    Vincent
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Error using cplexmiqp in matlab interface

    Posted Sun February 13, 2011 10:05 PM

    Originally posted by: John Cui


    I just checked cplexmiqp function in our current matlab connector, which need 4 input parameters at least,
    however, as you found, it should be extended to support 2 parameters as inputs, so we will extend it in the future release.

    Back to your problem, there is a work around to you: give zeros matrix and vector to Aineq and bineq when you call cplexmiqp without constraints.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Error using cplexmiqp in matlab interface

    Posted Mon February 14, 2011 02:53 AM

    Originally posted by: John Cui


    And also, I tried
    cplexmiqp(H,f,[],[])
    

    by cplex optimization studio 12.2.0.2, it works fine. Then which version cplex are you using?

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Error using cplexmiqp in matlab interface

    Posted Mon February 14, 2011 12:33 PM

    Originally posted by: Vincent.1


    Hi John,

    I did what you suggested yesterday and it worked. I was using cplex optimization studio 12.2. I just updated to 12.2.0.2 and the problem is gone. I really appreciate your help!

    Best regards,
    Vincent
    #CPLEXOptimizers
    #DecisionOptimization