I am a beginner for CVX and I am trying to solve the below problems, however, I get a wrong message of " Cannot perform the operation norm( {mixed convex/constant}, 2 ),出错 UAV (第 196 行) s1_2=norm([1,x])-x;"

cvx_begin quiet
cvx_precision high %定义优化为高精度
variable q1(2,1) %定义了两个优化变量
variable q2(2,1)
expression x

subject to
pmax=2000;
p0=580.65;
p_ind=790.671;
U_tip=200;
v0=4.03;
d0=0.3;
tho=1.225;
s=0.05;
A=0.79;
v1=norm([(q1(1)-q1_loc(1,n-1)),(q1(2)-q1_loc(2,n-1))])*inv_pos(deta_T);
v2=norm([(q2(1)-q2_loc(1,n-1)),(q2(2)-q2_loc(2,n-1))])*inv_pos(deta_T);
% v1=sqrt((q1(1)-q1_loc(1,n-1))^2+(q1(2)-q1_loc(2,n-1))^2)*inv_pos(deta_T);
% v2=sqrt((q2(1)-q2_loc(1,n-1))^2+(q2(2)-q2_loc(2,n-1))^2)inv_pos(deta_T);
%x=pow_pos(v1,2)inv_pos(2v0^2);
x=pow_pos((v1
inv_pos(sqrt(2)*v0)),2);
s1_2=norm([1,x])-x;

Apparently, x is a convex expression and is not affine. (Note: you haven’t shown us what x is.) The argument of `norm must be affine.

I don’t know whether as reformulation consistent with CVX’s rules exists, because I don’t know what x is, and I don’t know how you intend to use s1_2.

Your first task is to prove your optimization problem is convex.

Mark,thank you very much for your reply. Next, I will rephrase my question more precisely.
“x=pow_pos((v1inv_pos(sqrt(2)v0)),2);"
While ‘x’ is the expression above, which is equivalent to replacing this expression with ‘x’ to make the norm formula more concise; ‘s1_2’ is a parameter introduced to turn this constraint( P_1=p0
(1+3
v1^2/(U_tip^2))+p_indsqrt(s1_2)+0.5d0thosAv1^2*inv_pos(deta_T);)into a convex constraint, and later, a first-order Taylor expansion will be applied to ‘s1_2’ to also make it a convex constraint. However, due to the current error, I am unable to process the subsequent formulas.
‘x’ is not affine, so if I want to use ‘norm’, what kind of processing can be done on ‘x’ to make it comply with CVX’s rules? I would be extremely grateful if I could receive your reply again.”

Do your convexification on norm(expression), so that CVX never is presented with norm of a non-affine expression. Perhaps your convexification will produce an expression which doesn’t even involve norm. How you convexify, or whether you convexify is up to you. There are tools for non-convex optimization, for instance under YALMIP.

Okay, thank you very much for your reply.
Do you mean that I should first convexify s1_2, turning it into a convex function, and then substitute it into the expression for P_1=p0*(1+3* v1^2/(U_tip^2))+p_indsqrt(s1_2)+0.5 d0tho sA v1^2*inv_pos(deta_T)

As an example, norm([x^2,1/y]) is equal to sqrt(x^4+1/y^2). So convexify the latter. Then CVX never sees norm of anything.

I am not telling you how to convexify. That is up to you. it’s your optimization problem, which you presumably understand; whereas I have no idea what you are doing.

Okay, I will try to work on it, thank you very much for your idea, which might be very helpful to me.

Hi,Mark! According to your suggestion, I have linearized the non-convex part of s1_2 and successfully resolved the “norm” issue. However, I am now encountering a new error as follow.
错误使用 +
Disciplined convex programming error:
Illegal operation: {convex} + {concave}

出错 UAV (第 204 行)
P_1=p0*(1+3pow_pos(v1,2)/(U_tip^2))+p_inds1+0.5d0thosA*pow_pos(v1,2)*inv_pos(deta_T);

pmax=2000;
p0=580.65;
p_ind=790.671;
U_tip=200;
v0=4.03;
d0=0.3;
tho=1.225;
s=0.05;
A=0.79;
v1=norm([(q1(1)-q1_loc(1,n-1)),(q1(2)-q1_loc(2,n-1))])*inv_pos(deta_T);
v2=norm([(q2(1)-q2_loc(1,n-1)),(q2(2)-q2_loc(2,n-1))])*inv_pos(deta_T);
% v1=sqrt((q1(1)-q1_loc(1,n-1))^2+(q1(2)-q1_loc(2,n-1))^2)*inv_pos(deta_T);
% v2=sqrt((q2(1)-q2_loc(1,n-1))^2+(q2(2)-q2_loc(2,n-1))^2)inv_pos(deta_T);
%x=pow_pos(v1,2)inv_pos(2v0^2);
% x=pow_pos((v1
inv_pos(sqrt(2)*v0)),2);
% s1_2=norm([1,x])-x;
v1_k=sqrt((q1_r(1)-q1_loc(1,n-1))^2+(q1_r(2)-q1_loc(2,n-1))^2)*inv_pos(deta_T);
v2_k=sqrt((q2_r(1)-q2_loc(1,n-1))^2+(q2_r(2)-q2_loc(2,n-1))^2)*inv_pos(deta_T);

    v11=v1_k^2*inv_pos(2*v0^2)+v1_k*(v1-v1_k)*inv_pos(v0^2);
    s1_2=norm([1,v11])-pow_pos(v1,2)*inv_pos(2*v0^2);
    %s1_2 = sqrt(1+v1^4/(4*v0^4))-v1^2/(2*v0^2);%s^2[n]
    s1=sqrt(s1_2);
    P_1=p0*(1+3*pow_pos(v1,2)/(U_tip^2))+p_ind*s1+0.5*d0*tho*s*A*pow_pos(v1,2)*inv_pos(deta_T);

How can I address the issue of adding a ‘convex’ and a ‘concave’ function? I look forward to your reply.

You address the issue by forming a convex optimization problem for CVX to solve. It appears your attempted convexification didn’t actually make things convex. the input data values can matter in determining convexity or concavity. For example the sign of a matters if y is a convex expression in a*y.