I am working on a research and I have my variable (P_L) in the denominator. I am having challenges representing it in cvx and I keep getting the error:
Error using cvx/pow_cvx
Disciplined convex programming error:
Illegal operation: {real affine} .^ {-1}
(Consider POW_P, POW_POS, or POW_ABS instead.)
Error in .^ (line 55)
z = pow_cvx( x, y, ‘power’ );
Error in ^ (line 9)
z = power( x, y );
This is how I wrote the function:
(((c^2).(D1(kk).^2))(((2.P(1,kk)0.001)./(sigmaBw)).((4c^2)+((D1(kk).^2).(2piBw)^3)+2cD1(kk)))^-1
Perhaps you could have looked up the functions the error message suggested you consider instead?
Presuming P_L
is nonnegative, pow_p
could be used, or the most straightforward choice, inv_pos
. Either of them can take a vector argument, allowing you to sum over the output vector.
Perhaps you should re-read the CVX Users’ Guide.
1 Like
Thanks @Mark_L_Stone , that solved it.
However, whiles trying to solve this optimization problem:
cvx_begin
%cvx_solver SeDuMi
variable P(nLED,num_users)
maximize(sum((Bw * (log(1 + ((exp(1)) / (2 * pi)).*(P(1,:)*0.001 .* (H_A1.*R_pd).^2 / (sigma * Bw))))/(log(2)))+...
(Bw * (log(1 + ((exp(1)) / (2 * pi)).*(P(2,:)*0.001 .* (H_A2.*R_pd).^2 / (sigma * Bw))))/(log(2)))+...
(Bw * (log(1 + ((exp(1)) / (2 * pi)).*(P(3,:)*0.001 .* (H_A3.*R_pd).^2 / (sigma * Bw))))/(log(2)))+...
(Bw * (log(1 + ((exp(1)) / (2 * pi)).*(P(4,:)*0.001 .* (H_A4.*R_pd).^2 / (sigma * Bw))))/(log(2)))));
subject to
((inv_pos(P(1,kk)*0.001)*((c^2).*(D1(kk).^2))./(((2.*H_A1.^2)./(sigma*Bw)).*((4*c^2)+((D1(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D1(kk)))+...
(inv_pos(P(2,kk)*0.001)*((c^2).*(D2(kk).^2))./(((2.*H_A2.^2)./(sigma*Bw)).*((4*c^2)+((D2(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D2(kk)))+...
(inv_pos(P(3,kk)*0.001)*((c^2).*(D3(kk).^2))./(((2.*H_A3.^2)./(sigma*Bw)).*((4*c^2)+((D3(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D3(kk)))+...
(inv_pos(P(4,kk)*0.001)*((c^2).*(D4(kk).^2))./(((2.*H_A4.^2)./(sigma*Bw)).*((4*c^2)+((D4(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D4(kk))))<=0.1;
((inv_pos(P(1,kk)*0.001)*((c^2).*(D1(kk).^2))./(((2.*H_A1.^2)./(sigma*Bw)).*((4*c^2)+((D1(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D1(kk)))+...
(inv_pos(P(2,kk)*0.001)*((c^2).*(D2(kk).^2))./(((2.*H_A2.^2)./(sigma*Bw)).*((4*c^2)+((D2(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D2(kk)))+...
(inv_pos(P(3,kk)*0.001)*((c^2).*(D3(kk).^2))./(((2.*H_A3.^2)./(sigma*Bw)).*((4*c^2)+((D3(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D3(kk)))+...
(inv_pos(P(4,kk)*0.001)*((c^2).*(D4(kk).^2))./(((2.*H_A4.^2)./(sigma*Bw)).*((4*c^2)+((D4(kk).^2).*(2*pi*Bw)^3)/3)+2*c*D4(kk))))>=0.01;
end
cvx_end
I get the error:
Error using cvxprob/newcnstr
Disciplined convex programming error:
Invalid constraint: {convex} > {real constant}
Error in > (line 22)
b = newcnstr( evalin( ‘caller’, ‘cvx_problem’, ‘’ ), x, y, ‘>’ );
Error in OptSR_4APs (line 306)
(inv_pos(P(4,kk)0.001)((c^2).(D4(kk).^2))./(((2.H_A4.^2)./(sigmaBw)).((4c^2)+((D4(kk).^2).(2piBw)^3)/3)+2cD4(kk))))>=0.01;
which I understand to mean that my constraint is non-convex. However, I think my constraint is convex
Those constraints are non-convex. {convex} >= {constant}
is non-convex (inequality is going the wrong direction to be convex).
Please carefully read
Why isn't CVX accepting my model? READ THIS FIRST! .
You will not find your “thinking” as an acceptable convexity proof. And your thinking is incorrect in this case.
1 Like