CVX_SDP Index exceeds matrix dimensions problem

(Jie Zhang) #1

Hi, everyone, I have an optimization problem,

which is obtained by convex relaxation.
Then, I write code in matlab based on CVX as follows:

clc;clear all
M = 50;
R = rand(M,M);
R = RR’;
c0 = rand(M,1);
i = sqrt(-1)
as = rand(M,1) + i
lambda = 10;
Alength = rand(M,1);
R = R + i*R;
invRnn = inv®;
Bmax = 1;

cvx_begin sdp
variable B(M,1)
variable b(M,1)
variable t(M,1)
minimize ( sum(c0.(2.^B)) )
subject to
[invRnn + diag(b) invRnn
as; as’*invRnn as’invRnnas-lambda] >= zeros(M+1, M+1)
sum(B) <= Bmax
for i = 1:M
% b(i,1) >= (2^B(i)-1)^2/Alength(i)^2;
[1, t(i); t(i), b(i,1)*Alength(i,1)^2] >= 0
t(i) >= 2^B(i,1)-1
% b >= ((2.^B-1)./Alength).^2

But I cannot get the solution, matlab always give me an error message as

So who knows how to correct the error? Thanks in advance.

CVX Index exceeds matrix dimensions?
SDP programming problem in CVX
How to write my power constraint in CVX?
(Jie Zhang) #2

How to write this constraint in CVX

Actually, b, B, A are vectors of dimension M.

I try to write like this:
for i = 1:M
% b(i,1) >= (2^B(i)-1)^2/Alength(i)^2;
[1, t(i); t(i), b(i,1)*Alength(i,1)^2] >= 0
t(i) >= 2^B(i,1)-1
But CVX gives me the error message as

Who can tell me why? Thanks in advance.

(Denis Rosset) #3

You probably triggered a bug in CVX (I encountered something similar once). Can you shorten your program by setting M as small as possible, replacing calls to rand by explicit matrices, remove constraints… and still trigger the bug?

If you provide a shorter test case that exhibits the problem, it’s easier to identify the bug.

Or, if you just care about results, move things around, reformulate, change the type of constraints, until CVX works correctly.

(Michael C. Grant) #4

I’m having a lot of trouble reproducing this issue, honestly. But one thing that does seem to be in common across all the instances of this is that it involves a combination of semidefinite variables and log/exp/power functions. If anyone can offer a reliable, fully self-contained way to reproduce this problem, I can keep looking for a solution.

(Jie Zhang) #5

Hello, everyone. I have an optimization problem as follows

Then, I wrote the codes in MATLAB, as follows

Why matlab always shows the error like this

I don’t understand the reason, because I have checked that there is not problem with matrix dimension.
So who can give me advice? thanks very much.

(Jie Zhang) #6

Hope someone can give advice on solving this problem. Thanks a lot. Awaiting…


Hi, everybody,

I’m trying to solve a problem with CVX in SDP mode such as follows:

cvx_begin sdp
variables Ps(N) Psi(N);
variable W11(N,N) hermitian toeplitz;
variable W22(N,N) hermitian toeplitz;
minimize -(sum(log(1+Psi.*r1)))
subject to
[W11, diag(Psi);diag(Psi), W22]>=0;

where N is a constant, r1 is constant vector.

When N<=16, it can work. However, when N beomes larger (e.g. N=32), it will fail. The errors are listed as follows:

??? Index exceeds matrix dimensions.

error in ==> cvxprob/eliminate (line 170)
P = P( :, colX ) + P( :, cols ) * temp;

eroor in ==> cvxprob/solve (line 14)
[ At, cones, sgn, Q, P, dualized ] = eliminate( prob, true );

error in ==> cvx_end (line 77)
solve( prob );

error in ==> test0 (line 154)

I cann’t find out what’s wrong with it. Can anybody help me? Thanks a lot.

The index is beyond the matrix dimension
(Jie Zhang) #8

Hi, have you known the reason behind your problems? I have a similar problem, see CVX_SDP Index exceeds matrix dimensions problem. Maybe you can help me.

(Michael C. Grant) #9

I’m going to merge these common issues into a single thread.

Error: inner matrix dimension must agree in cvxprob/eliminate
(Michael C. Grant) #10

Just to reiterate what I said above: I’m having trouble reproducing this issue. I need a complete, self-contained example—no missing data that I have to guess about! And preferably, one that is as small as possible. If someone can offer that up, I’d be grateful, as would (I suspect) those who are suffering from this bug! Thank you!

(Barry) #11

Hi, have you solved your problem?

(Traba Cool Ass) #12

Hi everyone!
I encountered the same problem but I have some information that might help you guys resolve this issue and fix the bug.

So, I tried to minimize the following function:

under the constraint Ax=b. I tried to do this with the following MATLAB code:

clear all;
close all;

n = input(‘n=’);
p = input(‘p=’);

A = rand(p,n);
x0 = rand(n,1);
b = A*x0;

variable x(n)
minimize (-sum(log(x)))
subject to

I tried to do this for various combinations of n and p. I noticed that the minimization was completed successfully every time p was smaller than 2n. When p was bigger than 2n I also got the same error message as you guys, that is:

Index exceeds matrix dimensions.

Error in cvxprob/eliminate (line 179)
P = P( :, colX ) + P( :, cols ) * temp;

Error in cvxprob/solve (line 18)
[ At, cones, sgn, Q, P, dualized ] = eliminate( prob, true, shim.dualize );

Error in cvx_end (line 88)
solve( prob );

Error in ConvexOptimization3 (line 13)

I use MATLAB R2015a in Ubuntu 16.04 LTS. You are welcome to try this code by yourselves and see if this information about the p and n parameters helps you find the bug.