How to Formulate Quadratic Convex Programming in CVX

Hello. I am a rookie to CVX. I am trying to formulate Quadratic Convex Programming which results to some convex hull in CVX. The convex hull mentioned before as listed as follows.
However, errors " Error using cvx/subsref (line 13)
Subscript indices must either be real positive integers or logicals. " always emerge while I directly formulate this problem in cvx. Does CVX validate to solve such Quadratic Convex Programming?
Snipaste_2018-07-11_20-27-55

where the bold variables above are constant variables.

Can you clearly write out the optimization problem you wish to enter in CVX? Pleas make it very clear what is input data and what are CVX (i.e., optimization, i.e., decision) variables.

Also show us your CVX code.

CVX can handle convex QPs. Convex QPs can always be entered in accordance with CVX’s rules…

here is the full formulation and code I made as follows

the next fig is code in matlab![12344|690x440]

where PAD is constant value
sin_CONV
cos_CONV
vv_CONV
v_s_CONV
v_c_CONV
are convex hull derived from (T-CONV) and (M-CONV)

vv_lb
vv_ub
cos_lb
cos_ub
sin_lb
sin_ub
are boundaries implemented in (22b) and (22c)

variable definition listed as follows:
cvx_begin
cvx_solver gurobi
%variable
variable Sg(nbus) complex
variable l(nbranch) nonnegative
variable v_mag(nbus,1) nonnegative
variable v_ang(nbus,1)
variable W(nbus,nbus) complex
variable wii(nbus,1) nonnegative
variable Sij(nbus,nbus) complex
%%conv_variable
variable vv_CONV(nbus,nbus) nonnegative
variable cos_CONV(nbus,nbus)
variable sin_CONV(nbus,nbus)
variable v_s_CONV(nbus,nbus)
variable v_c_CONV(nbus,nbus)

with objective function:
%objective
minimize sum( sum( c_cost .* [(real(Sg) * mpc.baseMVA).^2 (real(Sg) * mpc.baseMVA) ones(size(real(Sg)))]) )
%constraints
subject to
PAD = pi/4;
for ii = 1 : nbus
Sg(ii) - complex( Pd(ii), Qd(ii) ) == conj(Y(ii,:)) *( wii(ii,1).*ones(nbus,1) - W(ii,:).’ ); %(16e)
wii(ii,1) == vv_CONV(ii,ii); %(22a)
vmin2(ii) <= wii(ii,1)<= vmax2(ii); %(16c)
Pmin(ii) <= real(Sg(ii,1)) <= Pmax(ii) %(16d)
Qmin(ii) <= imag(Sg(ii,1)) <= Qmax(ii); %(16d)
%vv_CONV
vv_CONV(ii,ii) >= v_mag(ii).*v_mag(ii);
vv_CONV(ii,ii) <= ( Vmax(ii) + Vmin(ii))*v_mag(ii) - Vmax(ii)*Vmin(ii);
end
for ii = 1: nbranch
fn = mpc.branch(1,ii);
tn = mpc.branch(2,ii);
Sij(fn,tn) == conj(Y(fn,tn))*wii(fn,1) - conj(Y(fn,tn))*W(fn,tn); %(16f)
Sij(tn,fn) == conj(Y(fn,tn))*wii(tn,1) - conj(Y(fn,tn))*W(fn,tn); %(16g)
tan(-PAD)*real(W(fn,tn)) <= imag(W(fn,tn)) <= tan(PAD)*real(W(fn,tn)); %(16i)
real(W(fn,tn)) == v_c_CONV(fn,tn) %(22b)
imag(W(fn,tn)) == v_s_CONV(fn,tn) %(22c)
Sij(fn,tn) + Sij(tn,fn) == complex( mpc.branch(ii,BR_R), mpc.branch(ii,BR_X) )*l(ii); %(22d)
Sij(fn,tn)*conj(Sij(fn,tn)) <= wii(fn,1)*l(fn,tn); %(22e)

       %CONV
       cos_CONV
       cos_CONV(fn,tn) <= 1 - ( 1 - cos(PAD) )./ (PAD^2)*((v_ang(fn)) - (v_ang(tn))).^2;
       cos_CONV(fn,tn) >= cos(PAD);
       
      % sin_CONV
       sin_CONV(fn,tn) <= cos(PAD/2)*( (v_ang(fn)) - (v_ang(tn)) - PAD/2) + sin(PAD/2);
       sin_CONV(fn,tn) >= cos(PAD/2)*( (v_ang(fn)) - (v_ang(tn)) + PAD/2) - sin(PAD/2);
       
       %vv_CONV
       vv_CONV(fn,tn) >= Vmin(fn)*v_mag(tn) + Vmin(tn)*v_mag(fn) - Vmin(fn)*Vmin(tn);
       vv_CONV(fn,tn) >= Vmax(fn)*v_mag(tn) + Vmax(tn)*v_mag(fn) - Vmax(fn)*Vmax(tn);
       vv_CONV(fn,tn) <= Vmin(fn)*v_mag(tn) + Vmax(tn)*v_mag(fn) - Vmin(fn)*Vmax(tn);
       vv_CONV(fn,tn) <= Vmax(fn)*v_mag(tn) + Vmin(tn)*v_mag(fn) - Vmax(fn)*Vmin(tn);
       % second boundary initialization
       vv_lb(ii) = min(  (Vmin(fn)*Vmin(tn) + Vmin(tn)*Vmin(fn) - Vmin(fn)*Vmin(tn)), ( Vmax(fn)*Vmin(tn) + Vmax(tn)*Vmin(fn) - Vmax(fn)*Vmax(tn) )  );
       vv_ub(ii) = max(  ( Vmin(fn)*Vmax(tn) + Vmax(tn)*Vmax(fn) - Vmin(fn)*Vmax(tn) ),  ( Vmax(fn)*Vmax(tn) + Vmin(tn)*Vmax(fn) - Vmax(fn)*Vmin(tn))   );
       cos_ub(ii) = 1 - ( 1 - cos(PAD) )./ (PAD^2)*(PAD).^2 ;
       cos_lb(ii) = cos(PAD);
       sin_ub(ii) = cos(PAD/2)*( PAD - PAD/2) + sin(PAD/2);
       sin_lb(ii) = cos(PAD/2)*( PAD + PAD/2) - sin(PAD/2);
       %v_c_CONV
       v_c_CONV(fn,tn) >= vv_lb(ii)*cos_CONV(fn,tn) + cos_lb(ii)*vv_CONV(fn,tn) - vv_lb(ii)*cos_lb(ii);
       v_c_CONV(fn,tn) >= vv_ub(ii)*cos_CONV(fn,tn) + cos_ub(ii)*vv_CONV(fn,tn) - vv_ub(ii)*cos_ub(ii);
       v_c_CONV(fn,tn) <= vv_lb(ii)*cos_CONV(fn,tn) + cos_ub(ii)*vv_CONV(fn,tn) - vv_lb(ii)*cos_ub(ii);
       v_c_CONV(fn,tn) <= vv_ub(ii)*cos_CONV(fn,tn) + cos_lb(ii)*vv_CONV(fn,tn) - vv_ub(ii)*cos_lb(ii);
      %v_s_CONV
       v_s_CONV(fn,tn) >= vv_lb(ii)*sin_CONV(fn,tn) + sin_lb(ii)*vv_CONV(fn,tn) - vv_lb(ii)*sin_lb(ii);
       v_s_CONV(fn,tn) >= vv_ub(ii)*sin_CONV(fn,tn) + sin_ub(ii)*vv_CONV(fn,tn) - vv_ub(ii)*sin_ub(ii);
       v_s_CONV(fn,tn) <= vv_lb(ii)*sin_CONV(fn,tn) + sin_ub(ii)*vv_CONV(fn,tn) - vv_lb(ii)*sin_ub(ii);
       v_s_CONV(fn,tn) <= vv_ub(ii)*sin_CONV(fn,tn) + sin_lb(ii)*vv_CONV(fn,tn) - vv_ub(ii)*sin_lb(ii);
       real(W(fn,tn)) == v_c_CONV(fn,tn); %(22b)
       imag(W(fn,tn)) == v_s_CONV(fn,tn); %(22c)
       
   end
 cvx_end

Unfortunately, I have no idea what you’re doing or trying to do. You have not provided a reproducible problem, complete with all input data needed to run it. It appears that your objective function is quadratic, but without input data, I can not determine whether it is convex. Can you express it in a standard form, real(Sg)'*Q*real(Sg), where Q is symmetric positive semidefinite?

I haven’t had the energy to figure out what your constraints are. Are you sure they are convex? If they are, they must be entered in accordance with CVX’s DCP rules.