Part of convex function is as follows, and it’s convex

I try to use CVX to solve this problem, but the solver always failed.

and this is my code:

function [q1,q2,optval_traj] = Trajectory(a1,a2,p1,p2,q1_pre,q2_pre,w)

global K N T noise H_min H_max v_max v_min d_min h_k h_m;

V1 = v_min*T/N;
V2 = v_max*T/N;

d1=zeros(K,N);

d2=zeros(K,N);

for k=1:K

d1(k,:)=sum_square_abs(q1_pre-w(:,:,k));

d2(k,:)=sum_square_abs(q2_pre-w(:,:,k));

end

temp=ones(K,1)*p1*(h_k*h_m)^2./d1.^2+ones(K,1) p2(h_k*h_m)^2./d2.^2;

I1=2

*ones(K,1)*h_m)^2./(log(2)

*p1*(h_k*d1.^3.*(temp+noise));

I2=2

*ones(K,1)*h_m)^2./(log(2)

*p2*(h_k*d2.^3.*(temp+noise));

cvx_begin

cvx_solver Mosek

variable R_traj

variable q1(3,N) nonnegative

variable q2(3,N) nonnegative

variable S1(K,N)

variable S2(K,N)

expression g1(K,N)

expression g2(K,N)

expression R1_lb(K,N)

expression R2_lb(K,N)

expression sum(K,N)

expression t1(K,N)

expression t2(K,N)

```
sum=ones(K,1)*p1*(h_k*h_m)^2./d1.^2+ones(K,1)*p2*(h_k*h_m)^2./d2.^2;
R1_lb=-I1.*S1-I2.*S2+log(sum+noise)/log(2);
R2_lb=-I1.*S1-I2.*S2+log(sum+noise)/log(2);
for k=1:K
for n=1:N
t1(k,n)=(q1_pre(:,n)-w(:,n,k))'*(q1(:,n)-q1_pre(:,n));
t2(k,n)=(q2_pre(:,n)-w(:,n,k))'*(q2(:,n)-q2_pre(:,n));
end
end
maximize (R_traj)
subject to
sum(a1.*(R1_lb-log(ones(K,1)*p2*(h_k*h_m)^2.*inv_pos(S2)+noise)/log(2))+...
a2.*(R2_lb-log(ones(K,1)*p1*(h_k*h_m)^2.*inv_pos(S1)+noise)/log(2)),2) >= N*R_traj;
S1 <= d1+2*t1;
S2 <= d2+2*t2;
for n=1:N-1
sum_square_abs(q1(:,n+1)-q1(:,n)) <= V2^2;
sum_square_abs(q2(:,n+1)-q2(:,n)) <= V2^2;
end
for n=1:N-1
sum_square_abs(q1_pre(:,n+1)-q1_pre(:,n))+2*sum((q1_pre(:,n+1)-q1_pre(:,n)).*(q1(:,n+1)-q1(:,n))) >= V1^2;
sum_square_abs(q2_pre(:,n+1)-q2_pre(:,n))+2*sum((q2_pre(:,n+1)-q2_pre(:,n)).*(q2(:,n+1)-q2(:,n))) >= V1^2;
end
-sum_square_abs(q1_pre-q2_pre)+2*sum((q1_pre-q2_pre).*(q1-q2)) >= d_min^2;
q1(:,1) == q1(:,N);
q2(:,1) == q2(:,N);
for n=1:N
H_min <= q1(3,n) <= H_max;
H_min <= q2(3,n) <= H_max;
end
```

cvx_end

optval_traj = cvx_optval;

end

I have tried many many methods, but still cannot solve it, so how to express the problem properly in CVX?

I really appreciate your generous help.