# Disciplined convex programming error: Cannot minimize a(n) concave expression

Here is my code.

ap_except0(1,1)=a_ij0(2,1)*p_k0(1,2)+a_ij0(3,1)*p_k0(1,3);
ap_except0(1,2)=a_ij0(1,2)*p_k0(1,1)+a_ij0(3,2)*p_k0(1,3);
ap_except0(1,3)=a_ij0(1,3)*p_k0(1,1)+a_ij0(2,3)*p_k0(1,2);
g_exp0=log2(Cg_k.ap_except0+noise);
fe_exp0=log2(Cg_e
(ap_except0+p_k0)+noise);

cvx_solver mosek
cvx_begin

variable p_k(1,3)
expressions g_exp_ub(1,3) fe_exp_ub(1,3) f_exp(1,3) ge_exp(1,3)

g_exp_ub(1,1)=g_exp0(1,1)+...
Cg_k(1,1)*(a_ij0(2,1)*(p_k(1,2)-p_k0(1,2))+a_ij0(3,1)*(p_k(1,3)-p_k0(1,3)))*log2(exp(1))/...
(Cg_k(1,1)*ap_except0(1,1)+noise);
g_exp_ub(1,2)=g_exp0(1,2)+...
Cg_k(1,2)*(a_ij0(1,2)*(p_k(1,1)-p_k0(1,1))+a_ij0(3,2)*(p_k(1,3)-p_k0(1,3)))*log2(exp(1))/...
(Cg_k(1,2)*ap_except0(1,2)+noise);
g_exp_ub(1,3)=g_exp0(1,3)+...
Cg_k(1,3)*(a_ij0(1,3)*(p_k(1,1)-p_k0(1,1))+a_ij0(2,3)*(p_k(1,2)-p_k0(1,2)))*log2(exp(1))/...
(Cg_k(1,3)*ap_except0(1,3)+noise);

sum_ap(1,1)=p_k(1,1)+a_ij0(2,1)*p_k(1,2)+a_ij0(3,1)*p_k(1,3);
sum_ap(1,2)=a_ij0(1,2)*p_k(1,1)+p_k(1,2)+a_ij0(3,2)*p_k(1,3);
sum_ap(1,3)=a_ij0(1,3)*p_k(1,1)+a_ij0(2,3)*p_k(1,2)+p_k(1,3);
sub_ap(1,1)=p_k(1,1)-p_k0(1,1)+a_ij0(2,1)*(p_k(1,2)-p_k0(1,2))+a_ij0(3,1)*(p_k(1,3)-p_k0(1,3));
sub_ap(1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cg_e*(a_ij0(1,3)*p_k(1,1)+a_ij0(2,3)*p_k(1,2))+noise);

result=0;
for k=1:K
result=result+g_exp_ub(1,k)-f_exp(1,k)-ge_exp(1,k)+fe_exp_ub(1,k);
end

minimize result
subject to
p_k >= 0;
sum(p_k) <= P_max;

cvx_end

My problem is that CVX thinks my objective function is concave.
But from the optimization problem in the graph, the objective function is convex.

Try add “expressions result” into your code. Because result is an expression too. And you initialize it as 0, if you don’t declare it expression, it might go wrong.

I tried your suggestion. But cvx still shows it’s concave.

This is my output.

Disciplined convex programming error:
Cannot minimize a(n) concave expression.

newobj( prob, ‘minimize’, x );

minimize result3

I changed my code.

ap_except0(1,1)=a_ij0(2,1)*p_k0(1,2)+a_ij0(3,1)*p_k0(1,3);
ap_except0(1,2)=a_ij0(1,2)*p_k0(1,1)+a_ij0(3,2)*p_k0(1,3);
ap_except0(1,3)=a_ij0(1,3)*p_k0(1,1)+a_ij0(2,3)*p_k0(1,2);
g_exp0=log2(Cg_k.ap_except0+noise);
fe_exp0=log2(Cg_e
(ap_except0+p_k0)+noise);

cvx_solver mosek
cvx_begin

variable p_k(1,3)
expressions g_exp_ub(1,3) fe_exp_ub(1,3) f_exp(1,3) ge_exp(1,3) result3

g_exp_ub(1,1)=(1-(Cg_k(1,1)*ap_except0(1,1)+noise)...
*pow_p(Cg_k(1,1)*(a_ij0(2,1)*p_k(1,2)+a_ij0(3,1)*p_k(1,3))+noise,-1))*log(2)*exp(1);
g_exp_ub(1,2)=(1-(Cg_k(1,2)*ap_except0(1,2)+noise)...
*pow_p(Cg_k(1,2)*(a_ij0(1,2)*p_k(1,1)+a_ij0(3,2)*p_k(1,3))+noise,-1))*log(2)*exp(1);
g_exp_ub(1,3)=(1-(Cg_k(1,3)*ap_except0(1,3)+noise)...
*pow_p(Cg_k(1,3)*(a_ij0(1,3)*p_k(1,1)+a_ij0(2,3)*p_k(1,2))+noise,-1))*log(2)*exp(1);

sum_ap(1,1)=p_k(1,1)+a_ij0(2,1)*p_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1,2)*p_k(1,1)+p_k(1,2)+a_ij0(3,2)*p_k(1,3))+noise);
f_exp(1,3)=log(2).*(Cg_k(1,3).*(a_ij0(1,3)*p_k(1,1)+a_ij0(2,3)*p_k(1,2)+p_k(1,3))+noise);

ge_exp(1,1)=log(2).*(Cg_e*(a_ij0(2,1)*p_k(1,2)+a_ij0(3,1)*p_k(1,3))+noise);
ge_exp(1,2)=log(2).*(Cg_e*(a_ij0(1,2)*p_k(1,1)+a_ij0(3,2)*p_k(1,3))+noise);
ge_exp(1,3)=log(2).*(Cg_e*(a_ij0(1,3)*p_k(1,1)+a_ij0(2,3)*p_k(1,2))+noise);

result3=0;
for k=1:K
result3=result3+g_exp_ub(1,k)-f_exp(1,k)-ge_exp(1,k)+fe_exp_ub(1,k);
end

minimize result3
subject to
p_k >= 0;
sum(p_k) <= P_max;

cvx_end

You didn’t provide your data. So I guess some data are <= 0 that are expected to be >= 0. You need to check that. By the way, I have an another bold guess: p_k0 rather than p_k should be inside pow_p() ??

Thank you very much. That’s what you suspect. My problem has been solved.