Unexpected error when solving SDP

Hi everyone, I just started to use CVX package. I found the unexpected error below.

Strangely enough, though, if I change the definition of F to be (ones(n)*1.01 - kron(tmpC, tmpC)) / 2 (which does not have any zero element, unlike the original F) then everything goes smoothly (though the dual SDP becomes infeasible). So I guess the problem has something to do with zero coefficient.

  • Update

The problem is solved by typing clear all and rerun the script. This ad-hoc solution is from http://ask.cvxr.com/t/error-function-subsindex-is-not-defined-for-values-of-class-struct/3803.

  • Error message:

    Status: Error
    Optimal value (cvx_optval): NaN
    
    Array indices must be positive integers or
    logical values.
    
    Error in cvx_sdpt3>solve (line 211)
            Avec{end}{end+1} = reshape( ( str_3 *
            str_2 ) * reshape( At(ti,:), nt, nv * m
            ), nt2 * nv, m );
    
    Error in cvx_solve (line 399)
                [ x, status, tprec, iters, y ] =
                shim.solve( At, b, c, cones, params
                );
    
    Error in cvx_finish
    
    Error in cvx_end (line 11)
        evalin( 'caller', 'cvx_finish' );
    
    Error in test0312 (line 17)
    cvx_end
    
  • Code

    n = 4
    tmpA = [1 1; 1 1]
    tmpB = [0 1; 1 0]
    tmpC = [1 -1; -1 1]
    F = (ones(n) - kron(tmpC, tmpC)) / 2
    D1 = kron(tmpA, tmpB)
    D2 = kron(tmpB, tmpA)
    
    cvx_begin sdp
        variable G(n,n) symmetric
        maximize(sum(sum(G.*F)))
    
        G.*F.*D1 <= eye(n)
        G.*F.*D2 <= eye(n)
    cvx_end
    
  • CVX Version

    CVX: Software for Disciplined Convex Programming       (c)2014 CVX Research
    Version 3.0beta, Build 1183 (dda2109)              Sun Dec 17 18:58:10 2017
    ---------------------------------------------------------------------------
    Installation info:
        Path: D:\software\matlab\cvx-w64\cvx
        MATLAB version: 9.4 (R2018a)
        OS: Windows 10 amd64 version 10.0
        Java version: 1.8.0_144

Cvx 2.2 + Mosek solve the problem easily.

Interior-point solution summary
  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: 8.0000000002e+00    nrm: 2e+00    Viol.  con: 2e-10    barvar: 0e+00  
  Dual.    obj: 8.0000000000e+00    nrm: 1e+00    Viol.  con: 0e+00    barvar: 1e-15
1 Like

Thanks for the test.
How can I get that version of CVX? Previously I downloaded from http://cvxr.com/cvx/download/, but cvx_version told me that it is v3.0 beta.

Update:
Interestingly, the .zip package is v3.0 beta, while the .tar.gz package is v2.2 for win64.

Update2:
Seemingly that does not help. Maybe it is because of my Matlab version being too old?

Update3:
The problem is solved by typing clear all and rerun the script. This ad-hoc solution is from http://ask.cvxr.com/t/error-function-subsindex-is-not-defined-for-values-of-class-struct/3803.

You can download CVX 2.2 at http://cvxr.com/cvx/download/