Here is my cvx code piece. The optimization variable in this equation is vk.
cvx_begin
variable vk(nTX,d(k))
expression part2
expression Nj
for j=1:K
if j~=k
Nj = 0;
for i=1:K
if i~=j && i~=k
Nj = Nj + norm(h{j,i}'*V{i})^2 + sigma_n2 * norm(U(j))^2;
end
end
part2 = part2 + w(j) * norm(h{j,k}'*vk)^2 / Nj;
end
end
maximize(2*w(k)*log2(norm(h{k,k}'*vk)) - part2)
(vk).^2 <= P(k);
h{k,k}'*vk > 0;
cvx_end
I get the following error:
??? Error using ==> cvx.pow_cvx at 142
Disciplined convex programming error:
Illegal operation: {convex} .^ {2}
(Consider POW_P, POW_POS, or POW_ABS instead.)
Error in ==> cvx.power at 55
z = pow_cvx( x, y, ‘power’ );
Error in ==> cvx.mpower at 9
z = power( x, y );
Error in ==> z_run_cvxopprecoder_randomchannel at 290
part2 = part2 + w(j) * norm(h{j,k}’*vk)^2 / Nj;
I tried to use other functions but I didn’t help. I think the problem needs to be formulated in a different way. The function I am trying to optimize can be found in the following paper: http://www.ee.ucla.edu/~yuezhao/ZDGP_Allerton12.pdf - The equation number is (14).
Thanks for your useful answer, I tried your suggestion and it works. However I encountered another problem with using “log” function. The new version of the code is as below:
cvx_begin
variable vk(nTX,d(k))
expression part2
expression Nj
for j=1:K
if j~=k
Nj = 0;
for i=1:K
if i~=j && i~=k
Nj = Nj + sum_square_abs(h{j,i}'*V{i}) + sigma_n2 * sum_square_abs(U{j});
end
end
part2 = part2 + w(j) * sum_square_abs(h{j,k}'*vk) / Nj;
end
end
maximize(2*w(k)*log(h{k,k}’*vk)/log(2) - part2)
sum_square_abs(vk) <= P(k);
((h{k,k}’*vk))) > 0;
cvx_end
I get the following error:
??? Error using ==> cvx.log at 64
Disciplined convex programming error: Illegal operation: log( {complex affine} ).
Is there an equivalent formulation for the objective function?
Thanks in advance.
What are you expecting here? Taking the logarithm of a complex value isn’t just non-convex, it is not well defined. Solve your modeling problem and you will likely have your answer.
i have one more doubt .i have an equation b=(aij)./(1-aij) inside cvx block , where b and aij are symmetric variable matrix ,while i was trying to implement that equation i am getting below mentioned error Cannot perform the operation: {real affine} ./ {real affine}. i understand why i am getting that error but don’t know how to solve it .
thanks
chakravarthy
i tried to solve it by b==inv_pos(inv_pos(aij)-1) (equivalent form of aij./(1-aij)). then i am getting errors Illegal operation: pow_p( {convex}, {-1} ) and Error in cvx/inv_pos (line 5) ; y = pow_cvx( x, -1, ‘pow_p’ );
I am new at cvx and I am actually facing the same challenge in my codes.
My optimization problem is very long, but the problem is at line 142 , => i.e, for i = 1:N
Here is the error I got:
Error using cvx/pow_cvx (line 142)
Disciplined convex programming error:
Illegal operation: {convex} .^ {2}
(Consider POW_P, POW_POS, or POW_ABS instead.),
I tried the above expression and none of them worked out. Any help would be appreciated.
Do you know that the cvx_expression you are squaring is always nonnegative? if so, you can use square_pos(cvx_expression)). If not, have you proven the problem is convex?
Thanks for your kind attention to this matter. By mathematical proof, I am sure my problem is convex and it is in GP mode. However, using "square_pos (cvx_expression) " as you suggested couldn’t fix the error. May be, I should try to find another way that can meet cvx solver’s rule sets. Many thanks.