import cvxpy as cvx
import node
import math
import numpy as np
X = cvx.Variable()
Y = cvx.Variable()

sum=0

for i in range(100):
x =node.all_points[i][0]
y =node.all_points[i][1]
w=[x,y]
dis_pow =(np.square(X-x)+np.square(Y-y)+np.square(100))
r=math.log2(1+pow(10,8)/dis_pow)
sum= sum + r

This is my code,log2(m) in python must be real number, not AddExpression. node.all_points is a matrix of 100 points（location）. I don’t know how to solve this problem.

The objective function is not concave, so the problem is not convex, so not solvable by CVX. Actually, I believe the objective function is convex over the domain in your constraints.

If it can be handled by CVXPY at all, it would not be in the DCP mode. Perhaps it can be handled (with no assurance of finding global optimum) by DCCP, but that is out of scope of CVX and the CVX forum.

Thank you again. How can I improve this objective function to follow the DCP rule in this question?
Find a location (X,Y, 100) that maximizes the sum of the UAV’s transmission rates to the 100 nodes on the ground.
rate=log2(1+pow(10,8)/dis_pow)

It’s up to you to formulate a convex optimization problem. If your problem is non-convex, I recommend you use a non-convex solver, which can not be done from CVX.