# Pow_abs,how can i modify the code

This is my code:
function [L_,P_] = location_Optimal(K,W,H_IC,CC,H_height,I_L,Beta,H_uc,H_iu,P_max,rou,Theta,UAV,p);

cvx_solver mosek
cvx_begin
cvx_quiet false;
variable L(1,2)
variable P(K)
expression I2(K)
expression I3(K)

``````for i=1:K
s_inter = 0;
for j =1:K
if i ==j
continue
else
s_inter =  p(j).*pow_abs((W(:,i)'*H_IC(:,j))+rou*sqrt(1./((real(H_height.^2)+square_pos(norm(L-CC)))...
*pow_abs(real(H_height.^2)+square_pos(norm(L-I_L(j,:))),(Beta/2)))).*W(:,i)'*H_uc'*Theta*H_iu(:,j),2)+s_inter;
end
end
I2(i) = log(real(s_inter+B*N_0))/log(2);
``````

This is the error:
Disciplined convex programming error:
Illegal operation: pow_abs( {convex}, {1.25} )

function y = pow_abs( x, p )
%POW_POS Power of absolute value.
% POW_POS(X,P) = ABS(X).^P.
% P must be real and greater than or equal to one.
%
% Disciplined convex programming information:
% POW_ABS(X,P) is convex and nonmonotonic, so X must be affine.
% P must be constant, and its elements must be greater than or
% equal to one. X may be complex.

I checked the introduction of the pow_abs function and found that there is no problem with my code, p can be a decimal, how can I change my code to make it work correctly?

The argument of `pow_abs` must be affine. The first argument of `pow_pos` must be convex (which includes affine as a special case).

``````       s_inter = 0;
for j =1:K
if i ==j
continue
else
a  = real(H_height.^2)+square_pos(norm(L-I_L(j,:)));
s_inter =  p(j).*pow_abs((W(:,i)'*H_IC(:,j))+rou*sqrt(1./((real(H_height.^2)+square_pos(norm(L-CC)))...
*pow_abs(real(H_height.^2)+square_pos(norm(L-I_L(j,:))),(Beta/2)))).*W(:,i)'*H_uc'*Theta*H_iu(:,j),2)+s_inter;
end
end
``````

val =

``````cvx convex expression (scalar)
``````

I check the The first argument of pow_pos is the a；It is a cvx convex expression.

Is the argument of `pow_abs` affine? Per the error message, it is convex, but not affine.

If I still want to use exponents, which function should I use?

It’s your problem, not mine. You should know what mathematical formulation you want, and it must follow CVX’s rules. You can see the available functions at http://cvxr.com/cvx/doc/funcref.html#built-in-functions . For any function_name of interest, `help function_name` provides the rules for allowable argument type.

I solved the previous problem, and there is a small problem, if I want to express 1./(xy), both x and y are convex, I found that prod_inv can’t express it, is there any other function that can express this form?

`prod_inv(x)` can be used if both `x` and `y` are positive and concave (or affine).

help prod_inv

prod_inv inverse of the product of a positive vector.
For a real vector, matrix, or X, prod_inv(X) returns 1.0 ./ PROD(X) if
the elements of X are all positive, and +Inf otherwise.

``````For matrices, prod_inv(X) is a row vector containing the inverse
product of each column of X. For N-D arrays, prod_inv(X) is an array of
inverse products taken along the first non-singleton dimension of X.

prod_inv(X,DIM) takes inverse products along the dimension DIM of X.

prod_inv(X,DIM,P), where P is a positive real constant, computes
prod_inv(X).^P. This is slightly more efficient than the equivalent
POW_POS(prod_inv(X),P).

Disciplined convex programming information:
prod_inv(X) is convex and nonincreasing in X; therefore, when used
in CVX specifications, its argument must be concave or affine.``````

Thank you very much！