Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

CPLEX Error 1004 in the CPLEX 12.2 API for MATLAB

  • 1.  CPLEX Error 1004 in the CPLEX 12.2 API for MATLAB

    Posted Mon November 14, 2011 09:07 PM

    Originally posted by: BerkUstun


    I am trying to solve a very simple MILP using the CPLEX 12.2 API in MATLAB but running into trouble.

    The error I encounter is:

    Error using ==> cplexlink122
    CPLEX Error 1004: Null pointer for required data.
    Error in ==> /home/software/cplex/cplex-12.2/cplex/matlab/@Cplex/Cplex.p>Cplex.solve at 640
    % Returns:

    Error in ==> /home/software/cplex/cplex-12.2/cplex/matlab/@Cplex/Cplex.p>Cplex.subsref at 2396
    640 % Returns:

    The MILP I am trying to solve has the following structure

    obj: 17x1 double
    lb: 17x1 double
    ub: 17x1 double
    rhs: 18.00
    lhs: 1.00
    A: http://1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
    ctype: 'BBBBBBBBBBBBBBBBB'
    Where lb = zeros(17,1) and ub = ones(17,1).

    The other fields of the MILP (DisplayFunc, Param) are unchanged. Also, the issue seems to be with CPLEX 12.2 since I can save this LP and solve it on another computer that runs MATLAB with the CPLEX 12.3 API.

    Anyone have an idea of what could be going wrong?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX Error 1004 in the CPLEX 12.2 API for MATLAB

    Posted Mon November 14, 2011 10:43 PM

    Originally posted by: John Cui


    Could you please attach your matlab code here?

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPLEX Error 1004 in the CPLEX 12.2 API for MATLAB

    Posted Mon November 14, 2011 11:03 PM

    Originally posted by: BerkUstun


    Hi John,

    I ended up figuring out what was going wrong in the process of trying to recreate the error.

    The issue was linked to the fact that I was using a struct() to create the Model part of my Cplex object. This was a little bit of a speedup compared to building the LP directly from LP.Model.

    In particular the following code will lead to an error in CPLEX 12.2:

    Model = struct()
    Model.obj = ones(5,1)
    Model.A = ones(1,5)
    Model.lhs = 1
    Model.rhs = Inf
    Model.ctype = char()
    Model.ub = ones(5,1)
    Model.lb = zeros(5,1)
    LP = Cplex
    LP.Model = Model;

    However this will work fine:

    LP = Cplex
    Model = LP.Model
    Model.obj = ones(5,1)
    Model.A = ones(1,5)
    Model.lhs = 1
    Model.rhs = Inf
    Model.ctype = char()
    Model.ub = ones(5,1)
    Model.lb = zeros(5,1)
    LP.Model = Model

    Thanks as always!
    #CPLEXOptimizers
    #DecisionOptimization