KA=vector of dimensions (k,1);
KB=vector of dimensions (k,1);
cvx_begin
variable alp(k,1) nonnegative;
variable bet(k,1) nonnegative;
expression x(k,1);
minimize(sum(bet))
subject to
x=KA.*alp+(ones(k,1)-alp).*KB;
diag(x*Stilde*x')<=ones(k,1)+bet;
alp<=1;
cvx_end
but I get the following error
Error using .* (line 46)
Matrix dimensions must agree.
Error in Prog2CVX (line 17)
x=KA.*alp+(ones(k,1)-alp).*KB;
I believe that I’m not using the variable alp correctly because if I fix the values of alp then everything goes smoothly. I will really appreciate some help. Thanks in advance.
With your code as written, and per my previous post, that will only work ifStilde is a scalar (nonnegative). Otherwise, it is dimensionally incompatible.
if Stilde is not a scalar, but rather, k by k, then you need to fix your formulation to what you want. You could change x*Stilde*x' to x'*Stilde*x but that would produce a scalar, which wouldn’t make sense with the RHS being a vector. So you need to figure out what constraint you really want.
At least theoretically this is dimensional coherent. if alp is a (k,1) vector and KA is a (k,3) matrix then KA.alp should return a (k,3) matrix where the first row of KA is multiplied by alp(1), the second row by alp(2) and the third row by alp(3). Analogously for (ones(k,1)-alp).KB . Therefore, x should be a matrix of dimensions (k,3) and then xStildex’ is a (k,k) matrix, so its diagonal is a (k,1) vector and I should be able to compare it to ones(k,1)+ bet which is a (k,1) vector.
But I think the problem is that CVX does not allow me to do the operation KA.*alp, correct me if I’m wrong.
Thanks both for the help! Using repmat it works but then I get the error “Only scalar quadratic forms can be specified in CVX”.
I’m starting to think that I cannot do what I need with this formulation. I can solve the problem using for cycles, but I was trying to vectorize everything in order to make it faster.
Thank you, this works perfect. But do you think it is possible to generalize it when Stilde is not the identity matrix, or in this case it is much more complicated?
I don’t know. Since temp*Stilde*temp' is a function of temp, but it seems that this function can’t be applied to 3 or bigger than 3-dimensional arrays in CVX . So, to fullfill your purpose, you can try do a linear transform for temp, so that Stilde become identity matrix.