# HOW CAN I solve the issue

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;
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

You haven’t told us what error is occurring.

Constraints need to use ==, not =. I have no idea whether you have other errors in your program.

Assignments using = need to have LHS which is an expression, not a CVX variable.

I changed my program, but I still get this error
Disciplined convex programming error:
Invalid constraint: {convex} >= {real affine}

b = newcnstr( evalin( ‘caller’, ‘cvx_problem’, ‘’ ), x, y, ‘>=’ );

BELTA >= belta;

clc;
clear;
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(Smax,N)
variable BELTA_2(1,N)
variable BELTA_3(1,N)
variable BELTA
variable qq(N)
variable sum_inner(Smax-1,N)
variable sum_inner_2(1,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 jj = 1:N
qq(jj) <= pow_abs(Xu0(jj)-citys_co(1,jj,1),2) + 2*(Xu0(jj)-citys_co(1,jj,1))*(x(jj)-Xu0(jj));
end

for jj = 1:N
for kk = 1:Smax
BELTA_1(kk,jj) = (pow_abs((x(jj) - citys_co(kk,jj,1)),2) - (pow_abs((Xu0(jj)-citys_co(kk,jj,1)),2)));
end
for jjj = ii+1:Smax
sum_inner(ii,jj) = inv_pos(qq(jjj,jj)');
end
end
BELTA_2 = sum(BELTA_1);
sum_inner_2 = sum(sum_inner);
for jj = 1:N
BELTA_3 = BELTA_2 - log(sum_inner_2);
end
BELTA = sum(BELTA_3)./N;
BELTA >= belta;

cvx_end
end

That inequality id going the wrong direction to b e convex.

Also, although not an error per se. You assigned BELTA with =, which makes it an expression, overriding its earlier declaration as a variable.