for n=1:N
s0(n)=sqrt(norm((Qr_r(:,n)-wb(:,1)).^2)+(Hi-Hb)^2);
r0(n)=sqrt(norm((Qr_r(:,n)-wg(:,1)).^2)+Hi^2);
end
cvx_begin
variable Q(2,N)
variable r(1,N)
variable s(1,N)
expression rate_g(1,N)
expression D_ig(1,N)
expression D_bi(1,N)
expression D_ie(1,N)
expression R0(1,N)
expression D0(1,N)
expression E0(1,N)
for n=1:N
R0(n)=1+Pb_r(1,n)./noise_power*(C+A./(s0(n)r0(n))+B/(s0(n)^2r0(n)^2));
D0(n)=-Pb_r(1,n)./noise_power*(A./(s0(n)r0(n)^2)+2B./(s0(n)^2r0(n)^3));
E0(n)=-Pb_r(1,n)./noise_power(A./(s0(n)^2r0(n))+2B./(s0(n)^3*r0(n)^2));
rate_g(1,n)=1./(R0(n)*log(2))*D0(n)*r(1,N)+1./(R0(n)*log(2))*E0(n).*s(1,N);
end
for n=1:N
D_ig(1,n)=pow_pos(norm(Q(:,n)-wg),2)+Hi^2;
D_bi(1,n)=pow_pos(norm(Q(:,n)-wb),2)+(Hi-Hb)^2;
end
maximize sum(rate_g(1:N))*1/N

subject to
for n=1:N
pow_pos(norm(Q(:,n)-wb),2)+(Hi-Hb)^2+s0(n)^2-2*s0(n)*s(n)<=0;
end
for n=1:N
pow_pos(norm(Q(:,n)-wg),2)+Hi^2+r0(n)^2-2*r0(n)*r(n)<=0;
end
Q(:,1)==q0;
Q(:,N)==qf;
for n=1:N-1
norm(Q(:,n+1)-Q(:,n))<=30; %公式31c 约束条件
end

You haven’t provided a reproducible problem, because it is missing the input data. You haven’t shown the CVX or solver output, nor the argmax, Q, which apparently is the subject of your concern.

You need to be much clearer in describing in what way the results do not seem correct to you. In doing so, you should assume the forum readers have no a priori idea what your model corresponds to, or what kind of results make sense for whatever the real world application is. Coming up with a good or adequate model for your problem is your task. Forum readers might be able to help with CVX formulation or solver issues, but not determining what is a good optimization model for your purposes.

The initial trajectory is the first image, and I expect the optimized trajectory to be like the second image. The original objective function is the third graph, where r (n) and s (n) represent the distances from Q to base and Q to use, respectively. The rest are constants

I have no idea what results should be obtained, or why what you expect to be true should be true. if any other forum reader does, they are free to post. But I doubt that will be the case. Please reread the 2nd paragraph of my previous post.

What @Mark_L_Stone means is that we can try to help with questions such as: here is my reproducible CVX code with input data, here are my log outputs, here is why I think variables x,y,z have wrong values, what can I do about it?

We are unable to help with questions that have some code snippets on one end and some plots on the other end, because we simply have no clue what it all means.

Q represents the trajectory of the drone, base is the base station, use is the user. The model maximizes the data transmission from the base station to the user through the drone as a relay. The trajectory of the drone is divided into N time slots. R is the formula for transmission rate. d-ig(n) and d-bi(n) represent the distance between the drone and the user and the distance between the drone and the base station in the nth time slot, respectively. Since the original problem cannot be solved directly, we relax the original formula by setting r(n)>=d-ig(n), s(n)>=d-bi(n). The expected result is shown in the second graph because when I input the data from the first graph and the second graph into the original formula, the R in the second graph is larger.

I have ZERO understanding of the problem. However, you mentioned relaxing constraints. Are the unrelaxed version of those constraints satisfied in the solution you obtained from CVX? If not, then caveat emptor on using the results of the optimization.

Although there are important exceptions, as a general matter, when constraints are relaxed, the solution to the relaxed optimization problem does not necessarily satisfy the constraints of the original (unrelaxed) problem. If this were not the case, the whole field of "constrained optimization’; could be eliminated, because every constrained optimization problem could be relaxed to an unconstrained optimization problem.