Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  create a LP file

    Posted 09/04/15 01:11 AM

    Originally posted by: PingLiu


    I am using the following code to create a LP file for a problem, why is the LP(attached) different from the original problem defined by Aeq, Aineq, beq, bineq, lb, ub, ctype? For example, the bounds in LP file has 71 variables, but the actual problem has only 38 vars. CPLEX version is 12.6.2 (64 bit), MATLAB version is R2011b. OS is windows 7 64 bit.

    options = cplexoptimset('cplex');

    options.Display = 'on';

    options.exportmodel = 'model.lp';

    [x, fval, exitflag, output] = cplexmilp (f', Aineq, bineq', Aeq, beq',...

    [ ], [ ], [ ], lb', ub', ctype, [ ], options);

    ***************************************************************************

    If I am using another method to create the lp file, then the error would be generated.

    cplex=Cplex('enr');

    cplex.Model.sense = 'minimize';

    cplex.addCols(f',[],lb',ub',ctype);

    cplex.addRows([-inf*ones(length(bineq),1);beq'], [Aineq;Aeq], [bineq';beq']);

    cplex.writeModel('enr.lp');

    -------------------------------------------

    Error using vertcat
    The following error occurred converting from double to single:


    Error using single
    Attempt to convert to unimplemented sparse type

    Error in
    C:\IBM\ILOG\CPLEX_Studio1262\cplex\matlab\x64_win64\@Cplex\Cplex.p>Cplex.addRows
    (line 2502)

    Error in
    C:\IBM\ILOG\CPLEX_Studio1262\cplex\matlab\x64_win64\@Cplex\Cplex.p>Cplex.subsref
    (line 3975)

    Error in CplexSol (line 32)
        cplex.addRows([-inf*ones(length(bineq),1);beq'], [Aineq;Aeq], [bineq';beq']);


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: create a LP file

    Posted 09/04/15 03:09 AM

    As described in the reference documentation for cplexmilp() all data passed into this function must be double precision. The data you are passing is only single-precision. If you pass double precision data instead

    [x, fval, exitflag, output] = cplexmilp (double(f'), double(Aineq), double(bineq'), double(Aeq),  double(beq'),...
                    [ ], [ ], [ ], double(lb'), double(ub'), ctype, [ ], options);

    things should work as expected.

    Same goes for using the class API: all functions expect double precision data arguments.


    #CPLEXOptimizers
    #DecisionOptimization