num_points=10;Np=20;alpha1和g0都为常数
hk_jiaodu为[N,1]的已知数组
hk(:,j,i)为[N,num_points-1,Np]的存储数组
variables q(3,Np);
expression temp1;
expression temp2;
expression temp3;
expression temp4;
expression temp5;
for j=1:num_points-1
for i=1:Np
temp1=norm(q(:,i)-location(:,j));
temp5=sqrt(temp1);
temp4=inv_pos(temp5);
temp2=pow_pos(temp4,alpha1)/g0;
temp3=sqrt(temp2);
hk(:,j,i)=temp3.*hk_jiaodu;
end
end
报错信息sqrt( {convex} ),请问如何解决
sqrt(1/norm)
by itself is not convex, So I think your only hope is if it is used in such a way as to allow a broader refromulation. I.e., you must first prove that the overall optimization problem is convex.
尊敬的Mark先生,非常感谢您的回复,我知道sqrt(1/norm)本身非凸,所以我尝试将其分开,可是sqrt(norm)也会报错,即原代码的temp5=sqrt(temp1)部分会报错sqrt({convex});请问如果仅考虑使这一部分可以被cvx许可,我应该怎么修改
Please read the link again. You will only be able to formulate this in CVX if the optimization problem is convex.
Do you actually need the sqrt
? For example, if the constraint is sqrt(1/norm(x)) >= 2
, you can reformulate it as 1 >= 4*norm(x)
. If you don’t have a situation such as this which allows a reformulation, you are out of luck with CVX.
好的,我理解了,我会尝试一下问题的转化,非常感谢您的帮助