0

I am new to cvx and get an error in solving the following convex problem:

enter image description here

In the above formulation, L=|E|, 'p' and 'm' are given positive real indices. Here is my code:

cvx_begin
    variable x(L,L);
    maximize(sum(sum(m(1:L,1:L).*(1-x(1:L,1:L))+(p(1:L,1:L).*x(1:L,1:L)))))
    subject to
    for j=1:L
        x(j,j)==1;
        sum(x(j,:))<=C;
    end
    for i=1:L
        for j=1:L
         0<=x(i,j)<=1;
        end
    end
cvx_end

I guess there is something wrong with the first part of the code (objective function) which makes the following disciplined convex programming error:

Error using  +  (line 29)
Disciplined convex programming error:
Invalid operations:
    {invalid} + {0}
    {0} + {invalid}

However, I do not know how to fix it.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
fhm
  • 57
  • 1
  • 11
  • I just tried this and did not get an error. What version of CVX do you have? – KQS Feb 17 '16 at 02:42
  • @user1877862 It is version 3.0beta running on matlab R2014a. I should note that some values of 'p' and 'm' might be zero (or positive). does it make defect? – fhm Feb 17 '16 at 06:46
  • 0 or positive are fine. Are any values `Inf` or `NaN`? That could cause the error you're seeing. – KQS Feb 17 '16 at 07:34
  • Yes, there was an 'Inf' value. excluding that, the code is working now. Thank you – fhm Feb 17 '16 at 15:35
  • @user1877862 I am required to add another constraint that is `x_i,j + x_j,k - x_i,k ≤ 1, ∀i,j,k∈E:k>i,j≠i,k`, I've added this using three `for` loops and two `if` to include `~=`, but this makes the `x` values to be negative after the problem is solved (cvx disregards my second constraint). how can I accomplish this in its right form? – fhm Feb 19 '16 at 15:42

0 Answers0