Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  fval not equal to f*x in cplexlp

    Posted 11/28/13 05:08 AM

    Originally posted by: Hubert_ETH


    I'm using Cplex 12.51 within Matlab to solve a LP and have problems with the solution Cplex is proposing.

    The optimal value fval is zero with f*x giving a pretty much higher value. If I solve the problem with Matlab's build in solver linprog, the solution is of much higher quality.

    When I put the solution from linprog as starting base for cplexlp, cplexlp still produces a non-optimal solution with the same issues, that optimal value is not equal objective function * optimal solution vector. 

    %% Initialization

    clear all;

     

    % load data

    load('f.mat')

    load('Aeq.mat')

    load('beq.mat')

    load('lb.mat')

    load('ub.mat')

     

    % options for cplexlp

    opt = cplexoptimset('cplex');

    opt.emphasis.numerical = 1;

    opt.diagnostics = 'on';

    opt.simplex.tolerances.markowitz = 0.99999;

    opt.lpmethod = 1;

    opt.exportmodel = 'model.sav';

     

    % options for linprog

    opt_linprog = optimoptions('linprog');

    opt_linprog.Display = 'off';

     

    %%

    % run linprog for finding solution

    [x_linprog,~,~,~] = linprog(f,[],[],Aeq,beq,lb,ub,[],opt_linprog);

     

    % run cplexlp with linprog solution as starting base

    [x,fval,exitflag,output] = cplexlp(f,[],[],Aeq,beq,lb,ub,x_linprog,opt);

     

    As I understand this could happen with barrier type solvers especially if the problem formulation is ill-conditioned. However this also happens if I force using the simplex type solver within Cplex.

    Exitflag is 1. Diagnostics are:

    LP Presolve eliminated 268 rows and 1011 columns.

    Reduced LP has 148 rows, 286 columns, and 626 nonzeros.

    Presolve time = 0.00 sec. (1.81 ticks)

    Initializing dual steep norms . . .

     

    Iteration log . . .

    Iteration:     1   Dual objective     =             0.000000

    Perturbation started.

    Iteration:    51   Dual objective     =             0.000000

    Iteration:   113   Dual objective     =             0.001084

    Iteration:   175   Dual objective     =             0.002105

    Removing perturbation.

     

    Dual simplex - Optimal:  Objective =  0.0000000000e+00

    Solution time =    0.01 sec.  Iterations = 202 (0)

    Deterministic time = 3.16 ticks  (472.01 ticks/sec)

     

    And solution quality if this helps:

    There are no reduced-cost infeasibilities.

    Maximum bound infeasibility        = 7.99361e-15

    Maximum Ax-b  residual             = 4.34097e-14

    Maximum c-B'pi residual            = 0

    Maximum |x|                        = 100

    Maximum |pi|                       = 0

    Maximum |red-cost|                 = 10

    Condition number of unscaled basis = 3.3e+02

     

    The model is attached as .sav as well as Matlab files.

    Thanks for any advice!


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: fval not equal to f*x in cplexlp

    Posted 11/29/13 03:59 AM

    I could not detect any error in CPLEX so far. What are solution vector and exit flag returned by linprog()?

    Moreover, what is the x vector that is returned by CPLEX? In particular, since your objective function contains only a single variable, what is the value of that variable in the solution that CPLEX returns?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: fval not equal to f*x in cplexlp

    Posted 11/29/13 04:47 AM

    Originally posted by: Hubert_ETH


    Exitflags for both linprog and cplexlp are 1.

    Optimal value for linprog is -2.7e4 , for cplexlp fval: 0

    Both solution vectors are feasible, however when I check the cplex solution it doesn't look like it is an optimal solution which is apparent when compared to linprogs. Further on the obj.funct. * solution vector results to 537.06 which is not equal to fval. (?)

    Could it be something with ill-contioned obj.function? Kappa results to 3.3e2, but I have no experience how bad this is.

    The x vector (and f) has 1297 entries. I've attached x, x_linprog,f as .csv files.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: fval not equal to f*x in cplexlp

    Posted 11/29/13 05:26 AM

    Originally posted by: Hubert_ETH


    I've also tried other problems with cplexlp, where it works just fine as expected.

    I've given this model also to other people who solved it on their machines with the same strange result.

    Also tried to remove equality constraints, to find out which constraint(s) could make problems with no results.

    Then I fixed the non-zero entries in the objective function to -1(it's a maximization problem) with no results.

    Any more advices? 


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: fval not equal to f*x in cplexlp

    Posted 11/29/13 06:03 AM

    I think the problem is that f, lb, ub are row vectors. According to the documentation of cplexlp they should be column vectors.

    Try passing f', lb', ub' to cplexlp.

    For historical reasons cplexlp() silently accepts row vectors but does strange things with them (as you just observed).


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: fval not equal to f*x in cplexlp

    Posted 11/29/13 06:16 AM

    Originally posted by: Hubert_ETH


    Thank you Daniel! That was indeed the problem!

    Already thought that I'm looking too far... 


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: fval not equal to f*x in cplexlp

    Posted 11/29/13 06:58 AM

    To avoid issues like this in the future you can set

    opt.read.datacheck = 1;

    This will produce an exception

    Error: f has incompatible dimensions

    in your case. In general it is recommended to set datacheck=1 during development. This adds several checks that are potentially expensive but can point to systematic or design problems in your code/model.


    #CPLEXOptimizers
    #DecisionOptimization