I have this problem
max sum(u_i)
s.t
r_i^2<=A+M1(1-u_i)
where u_i={0,1},
r_i=sqrt([x_i-xd]^2+[y_i-yd]^2). This is the distance between the point (x_i,y_i) and (xd,yd)
The optimization variables are xd,yd and u_i.
The following is my formulation
function [xd,yd,u]=Fun3(Gamma,x,y)
global NofUsers
M1=1e4;
%cvx_begin
cvx_begin quiet
cvx_solver Mosek
variable u(NofUsers) binary
variables xd yd
maximize(sum(u))
for i=1:NofUsers
(norm([x(i) y(i)] - [xd yd]))^2 <=Gamma + M1 * (1-u(i));
%((x(i)-xd11)^2 + (y(i)-yd11)^2)^2 <=Gamma + M1 * (1-u(i))
end
cvx_end
% NofUsers_in=cvx_optval;
%NofUsers_in=sum(u)
end
When I run the code it gives me an error
Error using cvx/pow_cvx (line 142)
Disciplined convex programming error:
Illegal operation: {convex} .^ {2}
(Consider POW_P, POW_POS, or POW_ABS instead.)
Error in .^ (line 55)
z = pow_cvx( x, y, ‘power’ );
Error in ^ (line 9)
z = power( x, y );
Error in Fun3 (line 12)
(norm([x(i) y(i)] - [xd11 yd11]))^2 <=Gamma + M1 * (1-u(i));
Error in ProgPtLoctnFor1Density (line 70)
[xd,yd,u3]=Fun3(Gamma,x,y);