Thank you so much!
the code can run smoothly
however what if I want the numbers in matrix a and s to be random decimals from 0 to 1, now the numbers in matrix a are the same number, and I want them to be four different decimals,what should i do?
yeah i know this function
but what should i write in the code?a and s is the decision variable I defined(
variable a(2,2) nonnegative
variable s(2,2) nonnegative )
do I need to add some restrictions?
i add the
0 <= a <= 1
0 <= s <= 1
however there are only four identical elements in the matrix,i want them be the different
thank you so much!
a and s are 2 by 2 matrix decision variables. There is nothing random about them. You want all elements of each matrix to be different? That is non-convex. So you will need to implement Big M logic constraints and decide on a tolerance for what constitutes “different” - search at https://or.stackexchange.com/ and seek further help there if necessary.
I have the same problem,please help me .here is my code
cvx_begin
variable beta1(1,2K);
expression x(1,2K);
expression y(1,2K);
expression R_K1_UAV(1,2K);
expression R_min_allo(1,2K);
expression sum_Bbeta(1,2K);
expression alpha(1,2K);
sum_Bki=zeros(1,2K);
sum_Aki=zeros(1,2*K);
z0=0;z3=0;z4=0;z5=0;
for k=1:1:2K
for i=1:1:2K
z0=z0+B(k,i)beta1(i);
z5=z5+A(k,i)P(i)(norm(h(i))^2);
end
sum_Bbeta(k)=z0;
sum_Aki(k)=z5;
lamd(k)=sigma./(P_UAV(norm(h(k))^2));
alpha(k)=P_UAV*(norm(h(k))^2)beta1(k)./(P_UAV(norm(h(k))^2)*sum_Bbeta(k)+sigma);
R_K1_UAV(k)=log2(1+(P(k)*norm(h(k))^2./(sigma+ sum_Aki(k))));
end
for k=1:1:2K
y(k)=log(alpha(k));
x(k)=log(beta1(k));
R_min_allo(k)=min(y(k),R_K1_UAV(2K-k+1));
z3=z3+exp(x(k));
end
for k=1:1:2K
for i=1:1:2K
z4=z4+B(k,i)exp(y(k));
end
end
maximize sum( R_min_allo);
subject to
for k=1:1:2K
log((sum_Bki(k)*exp(y(k))+exp(y(k))*lamd(k))./exp(x(k)))./log(2)<=0;
end
z3<=1;
cvx_end
Have you proven this is a convex optimization problem? It better be the case that y(k) = log(alpha(k)) is concave. That looks dubious to me. There might be plenty of other non-convexities as well.
In order to be a convex optimization problem, it needs to be jointly convex in all the optimization variables, which in your case are the elements of beta.
Let’s look at a simplex example: minimize sin(x)^2 with respect to x. That is not a convex optimization problem. Your claim is analogous to defining y = sin(x), and stating your problem is minimize y^2 , which is convex with respect to y. But it is not convex with respect to the optimization variable x.
Indeed, your rationale, were it valid, would enable convexification of any optimization problem. Have a non-convex objective? No problem, just define y = objective function, and voila it is convex with respect to y. Similarly with constraints. (Every optimization problem could even be made into a Linear Programming problem by that rationale.) That is of course nonsense. Expressions in CVX are just a shorthand way of making complicated formulas more understandable by writing them with placeholders (expressions) which hide.some of the complexity - they don’t change the inherent convexirty, or not, of anything.