The following cvx variable(s) have been cleared or overwritten: x_u y_u

I wrote the following code for simulating a successive convex optimization algorithm and I faced with the error:

The following cvx variable(s) have been cleared or overwritten:
x_u y_u
This is often an indication that an equality constraint was
written with one equals ‘=’ instead of two ‘==’. The model
must be rewritten before cvx can proceed.

The code:

clc; clear; close all;

L_it = 3;

N = 3; %time slots num.

k = 2;

H = 100;

P_bar_Ak = 1000; %mW

P_bar_u = 1000; %mW

V = 50; %m/s

T = 60; % second

beta0 = 10^(-6);

sig2 = 1.258*10^(-17);

alpha_hat = input_gen(k,N)

temp1 = rand(k,1);

temp2 = ones(1,N);

for i = 1 : k

P_Ak(i,:) = temp1(i)*temp2;

end

P_u = rand(1,N);

x_u = 3000*rand(1,N); %meter

y_u = 3000*rand(1,N); %meter

x_Ak = 3000*rand(k,1); %meter

y_Ak = 3000*rand(k,1); %meter

x_Bk = 3000*rand(k,1); %meter

y_Bk = 3000*rand(k,1); %meter

for i = 1 : length(x_Ak)

d(i,:) = ((x_u-x_Ak(i,1)).^2)+((y_u-y_Ak(i,1)).^2)+H^2;

d_Aku(i,:)=sqrt(d(i,:));

end

for i = 1 : length(x_Bk)

d(i,:) = ((x_u-x_Bk(i,1)).^2)+((y_u-y_Bk(i,1)).^2)+H^2;

d_uBk(i,:)=sqrt(d(i,:));

end

h_Aku = beta0*(d_Aku.^(-2));

h_uBk = beta0*(d_uBk.^(-2));

P_u_dot = repmat(P_u,k,1);

snr = (P_Ak.*P_u_dot.*h_Aku.*h_uBk)./((P_Ak.*h_Aku+P_u_dot.h_uBk+sig2)(sig2));

delta_k = 1./(P_Ak.*h_Aku);

eta_k = 1./(P_u_dot.*h_uBk);

delta_k_l = delta_k;

eta_k_l = eta_k;

delta_k_ll = rand(k,N);

eta_k_ll = rand(k,N);

for l = 1 : L_it

if l == 1
    
    lambda_k_l = delta_k_l + eta_k_l + (delta_k_l .* eta_k_l)*sig2;
    
    c_k_l = (1 + sig2*log2(exp(1))*eta_k_l)./((1 + lambda_k_l*sig2).*lambda_k_l);
    
    D_k_l = (1 + delta_k_l*sig2*log2(exp(1)))./((1 + lambda_k_l*sig2).*lambda_k_l);
    
    snr = 1./((delta_k_l+eta_k_l+(delta_k_l.*eta_k_l)*sig2)*(sig2));
    
    R_k_l = log2(1+snr);
    
end

if l~=1
    
    delta_k_l = delta_k_ll;
    
    eta_k_l = eta_k_ll;
    
    lambda_k_l = delta_k_l + eta_k_l + (delta_k_l .* eta_k_l)*sig2;
    
    c_k_l = (1 + eta_k_l*sig2*log2(exp(1)))./((1 + lambda_k_l*sig2).*lambda_k_l);
    
    D_k_l = (1 + delta_k_l*sig2*log2(exp(1)))./((1 + lambda_k_l*sig2).*lambda_k_l);
    
    snr = 1./((delta_k_l+eta_k_l+(delta_k_l.*eta_k_l)*sig2)*(sig2));
    
    R_k_l = log2(1+snr);
    
end

%% CVX Strart

cvx_begin

variables x_u(1,N) y_u(1,N) P_Ak(k,N) P_u_dot(k,N)

expression d1(k,N)

expression d1_uBk(k,N)


for i = 1 : length(x_Bk)
    
    d1(i,:) = ((x_u-x_Bk(i,1)).^2)+((y_u-y_Bk(i,1)).^2)+H^2;
    
    d1_uBk(i,:)=(d1(i,:));
    
end

h_uBk = (d1_uBk)/beta0;

eta_k_ll.*(P_u_dot) >= h_uBk;

for i = 1 : length(x_Ak)
    
    d1(i,:) = ((x_u-x_Ak(i,1)).^2)+((y_u-y_Ak(i,1)).^2)+H^2;
    
    d1_Aku(i,:)=(d1(i,:));
    
end

h_Aku = (d1_Aku)/beta0;

delta_k_ll.*P_Ak >= h_Aku;


R_LB = R_k_l - c_k_l.*(delta_k_ll - delta_k_l)-D_k_l.*(eta_k_ll - eta_k_l);

obj = sum((1/(2*N))*sum(alpha_hat.*R_LB));

maximize(obj);

subject to

x_u(1) = x_u(N);

y_u(1) = y_u(N);

for i = 1 : N-1
    ((x_u(i+1)-x_u(i)).^2)+((y_u(i+1)-y_u(i)).^2)<=((V*T/N)^2);
end

for i = 1 : k
    
    s_P_Ak = sum(P_Ak,2);
    
    s_P_Ak (i) <=(N*P_bar_Ak);
    
end

sum(P_u)<=(N*P_bar_u);

P_Ak >= 0;

P_u >= 0;

cvx_end

end

Thank you for your attention.

Just as the warning states, you are trying to impose equality constraints. They require == rather than = .

Change

x_u(1) = x_u(N);
y_u(1) = y_u(N);

to

x_u(1) == x_u(N);
y_u(1) == y_u(N);

Thanks for your answer. i did what you said and that error cleared but a new error occurred as below:
Undefined function ‘vec’ for input arguments of type ‘double’.
Error in cvxprob/extract (line 21)
dbcA = - sum( vec( dbcA ) );

Error in cvxprob/eliminate (line 23)
[ dbCA, cones, dir, Q, P ] = extract( prob, destructive );

Error in cvxprob/solve (line 18)
[ At, cones, sgn, Q, P, dualized ] = eliminate( prob, true, shim.dualize );

Error in cvx_end (line 88)
solve( prob );

Error in main2 (line 186)
cvx_end

If you using CVX 3.0beta, switch to CVX 2.2.

Something appears to be messed up with your CVX installation or MATLAB path. There should be
<cvx top directory>\functions\@cvx\vec.m % cvx method
and perhaps you are missing this following version, which is the one I think you need for double precision arguments.

function x = vec(X)
% x = vec(X)
%
% Y = VEC(x)  Given an m x n matrix x, this produces the vector Y of length
%   m*n that contains the columns of the matrix x, stacked below each other.
%
% See also mat.

% This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko
% Copyright (C) 2005 McMaster University, Hamilton, CANADA  (since 1.1)
%
% Copyright (C) 2001 Jos F. Sturm (up to 1.05R5)
%   Dept. Econometrics & O.R., Tilburg University, the Netherlands.
%   Supported by the Netherlands Organization for Scientific Research (NWO).
%
% Affiliation SeDuMi 1.03 and 1.04Beta (2000):
%   Dept. Quantitative Economics, Maastricht University, the Netherlands.
%
% Affiliations up to SeDuMi 1.02 (AUG1998):
%   CRL, McMaster University, Canada.
%   Supported by the Netherlands Organization for Scientific Research (NWO).
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA
% 02110-1301, USA
x = reshape(X,numel(X),1);

Hi
While we change the CVX version from cvx3 to cvx 2.2, the previous error was removed and the program was run, but the new error as following appeared:

Status: Failed
Optimal value (cvx_optval): NaN

The following error occurred converting from cvx to double:
Conversion to double from cvx is not possible.

Error in main2 (line 147)
d1_Aku(i,:)=(d1(i,:));

Declare d1_Aku to be an expression of the appropriate dimensions. http://cvxr.com/cvx/doc/basics.html#assignment-and-expression-holders

I suggest you carefully re-read the entire CVX user’s Guide so that yo uundrstnad the difference between expressions and constraints, and how to use them.

Hi
what is the problem with the line “eta_k_ll = h_uBk./(P_u_dot)” which h_uBk is cvx convex expression and P_u_dot is cvx real affine expression that I face with the following error:

Disciplined convex programming error:
Cannot perform the operation: {convex} ./ {real affine}

Error in ./ (line 19)
z = times( x, y, ‘./’ );

Error in main2 (line 147)
eta_k_ll = h_uBk./(P_u_dot);

Have you read the CVX Users’ Guide yet? it appears you have not, or at least didn’t understand it. There is no allowance for convex divided by affine.

Depending on the rest of the problem, the problem may or may not be convex, and maybe or maybe not it can be reformulated for CVX. If h_uBk is a quadratic, you can use quad_over_lin.

Yes I did. Now I changed the last relation to " eta_k_ll = h_uBk.*(inv_pos(P_u_dot))" but again the following error displayed.

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {convex} .* {convex}

Error in main2 (line 149)
eta_k_ll = h_uBk.*(inv_pos(P_u_dot));

How can I multiply two convex function?

Have you carefully read Why isn't CVX accepting my model? READ THIS FIRST! . it does not appear you have.

Dear Mark,
I am simulating an IEEE paper and in it, it is mentioned that the problem is simulated with CVX. so it is convex. If it is possible for you I send the problem defined in the article with my code to help me in order to solve my errors?

Perhaps you can email the authors requesting their CvX code.

Thanks alot for your help