I am encountering this error in my simulation, I wrote the left part of the fourth constraint as BELTA,my objective function is set to maximize belta. please tell me where my error occurs.
Here is my equation and simulation code
clc;
clear;
load citys
load M_star
xb = 0;xe = 1000;%起始点和终点
vmax = 30; %m/s
T = 40;
N = 100;
num_SNs = 10;
Smax = 2;
H = 30;
delta_t = T/N;
V = vmaxdelta_t;
RL = zeros(Smax,N);
iter_num = 10;
Yu0 = zeros(1,N);
citys_co = zeros(Smax,N,2);
for n = 1:1:N
Xu0(n) = xb + (n - 1)(xe - xb)/(N - 1);
end
for ii = 1:Smax
for kk = 1:N
city_indices = M_star(ii, kk); % 获取第i个城市的序号
citys_co(ii,kk,1) = citys(city_indices, 1); % 获取城市的坐标
citys_co(ii,kk,2) = citys(city_indices, 2); %Y坐标
end
end
for iter=1:iter_num
cvx_begin
variable belta
variable x(1,N)
variable BELTA_1(1,N)
variable BELTA
variable qq(Smax,N)
maximize(belta)
subject to
% trajectory
x(1) = xb;
x(N) = xe;
for kk=1:N-1
square_pos(x(kk+1)-x(kk))<=(V)^2;
end
for ii = 1:Smax
for jj = 1:N
sum_inner = 0;
for jjj = ii+1:Smax
sum_inner = sum_inner + inv_pos(qq(ii,jj));
end
BELTA_1(jj,ii) = BELTA_1(ii,jj) + (pow_abs((x(jj) - citys_co(ii,jj,1)),2) - (pow_abs((Xu0(jj)-citys_co(ii,jj,1)),2)));
end
end
BELTA = sum(BELTA_1);
for ii = 1:Smax
for jj = 1:N
qq(ii,jj) <= pow_abs(Xu0(jj)-citys_co(ii,jj,1),2) + 2*(Xu0(jj)-citys_co(ii,jj,1))*(x(jj)-Xu0(jj));
end
end
BELTA >= belta;
cvx_end
end