CVX error when using "inv_pos" function

Hi everyone ,
I got an error message when I called “inv_pos” function in my code.
I just start learning how to use CVX , and I have no idea how to deal with the error.
I read the The DCP ruleset and other topics related to my problem in the forum , but I still can not get a answer.

Here is my CVX code :

``````% CVX Procedure
cvx_begin

variable TSPN_XY(length(Routing_Info)-2,2) % TSPN_XY is an array with (x,y) coordinate in each row
minimize(Total_Routing_Dist(TSPN_XY)) % Total_Routing_Dist is a function calculate the summary distance like norm([x2 y2]-[x1 y1])+norm([x3 y3]-[x2 y2]) ...
subject to
Total_Energy_Consumption = 0;
for i = 2:length(Routing_Info)-1 % TSPN_XY[1] is related to Routing_Info[2] , hence i start from 2 to (last_index_of_Routing_Info - 1) , we don't take first & last node (0,0) into consideration here
norm(Routing_Info(i,[1 2])-TSPN_XY(i-1,:)) <= TSPN_Radius; % constrain 1
if(i == 2)
UAV_Propulsion_Energy = Cal_UAV_propulsion_energy_consumption(norm(TSPN_XY(i-1,:)-[0,0])); % flying distance between (0,0) and first IoTD
else
UAV_Propulsion_Energy = Cal_UAV_propulsion_energy_consumption(norm(TSPN_XY(i-1,:)-TSPN_XY(i-2,:))); % flying distance current IoTD(i-1) and last IoTD(i-2)
end
D1 = (Routing_Info(i,1)-TSPN_XY(i-1,1))^2;
D2 = (Routing_Info(i,2)-TSPN_XY(i-1,2))^2;
D3 = 20^2;
Dist = D1+D2+D3;
IoTD_to_UAV_DataRate = Data_Rate(Dist);
UAV_Hovering_Energy = Cal_UAV_hovering_energy_consumption(Routing_Info(i,3)/IoTD_to_UAV_DataRate);
UAV_MEC_Energy = Cal_UAV_MEC_energy_consumption(Routing_Info(i,4));
Total_Energy_Consumption = Total_Energy_Consumption + UAV_Propulsion_Energy; %+ UAV_Hovering_Energy + UAV_MEC_Energy;
end
Total_Energy_Consumption = Total_Energy_Consumption + Cal_UAV_propulsion_energy_consumption(norm(TSPN_XY(length(Routing_Info)-1,:)-[0,0])); % add the flying energy consumption from last node back to (0,0)
Total_Energy_Consumption <= UAV_Energy_Budget; % constrain 2

cvx_end
``````

Below is the error message , it occurred when CVX executed at line31 , which called a user-defined function I wrote .

In cvxprob (line 28)
In cvx_begin (line 41)
In TSPN (line 14)
Error using cvx/pow_cvx
Disciplined convex programming error:
Illegal operation: pow_p( {convex}, {-1} )
Error in cvx/inv_pos (line 5)
y = pow_cvx( x, -1, ‘pow_p’ );
Error in Data_Rate (line 15)
DataRate = BW*(log2(1+(IoTD_Power*IoT_Channel_Power_Gain)inv_pos(DistNoise_Variance)));
Error in TSPN (line 31)
IoTD_to_UAV_DataRate = Data_Rate(Dist);

I called `inv_pos` at line 31 in my CVX code , I marked it with red lines in the screenshot.

(Sorry for squeezing the code in screenshot , because I am just new at the forum , and I can only update one media in a post.)

If you need more information or explanation of my problem , please feel free to let me know.
I will provide it as soon as possible.

I will be grateful if someone could help me

Where is `inv_pos`? You need to show clearly where the difficulty or error is, not just shows lots of stuff I have no idea how it relates to the difficulty.

help inv_pos

inv_pos Reciprocal of a positive quantity.
inv_pos(X) returns 1./X if X is positive, and +Inf otherwise.
X must be real.

`````` For matrices and N-D arrays, the function is applied to each element.

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

Hi Mark,
Thanks for your reply , and I apologize for not describing it clearly.

I just edited my post and showed where `inv_pos` is called.

I need to calculate an equation which puts optimization variable in denominator.

Reformulations are in my post Minimize log(1+1/x) where 0<x<inf . and in @Dexin_Wang’s post in that same thread at Minimize log(1+1/x) where 0<x<inf

Hi Mark,
The solution `log(1 + 1/x) = rel_entr(x,x+1) + rel_entr(x+1,x)` is pretty similar to my equation.
However , in my case , the the equation is like `B*log(1+P/(X*N)) ,where B,P,N are constant`.
I am not sure how to reformulate it into the form that you mentioned.

Thanks.

If

z = X*N/P;

then you have

log(1+P/(X*N)) = log(1+1/z)