Illegal operation: log( {convex} ) in a certain convex constraint

Hi everyone. There is a constraint as below:

This constraint only has two variables: Sk,j[n] and qj[n].
Obviously, the first part Rk.m[N] is a quadratic term repect to qj[n]. And the constant Ak,j[n] >= 0. Thus, the first part Rk.m[N] is concave. The second part which has the -log function is certainly concave. In conclusion, this constraint is convex.

But when I use cvx, it always says: Illegal operation: log( {convex} ). I understand that in cvx, we should make sure the formula within the log function should be concave. But I have no idea how to write the above convex constraint legally.

Thanks in advance!


Thanks for visiting this forum.

Presuming you are willing for S_{k,j}[n] to be implicitly constrained to be positive, I think you can adapt the formulation in the 3rd entry of the Entropy table in the Conic Modeling Cheatsheet

Hi Mark. Thanks so much for your help! The document you provide is certainly helpful. But I think it only works when there is only one variables. However, in my constraint, there are more than one variables.

The picture below illustrates what I mean: as you can see, the right part of the picture prove the idea you provide. But when I try to extend the model to mulitiple-variables case. A (x1x2) appears in the new constraints. Isn’t it?

Thanks again for your kind help!

Hi Mark, I mean, when there is a (x1*x2) in my constraint, it will have a error: Invalid quadratic form(s): not a square. Isn’t it?

If you want to do logarithm of sum of inverses, like on the right side of your scan, there are better ways. See for two of them.

Oh, Thanks so much Michal. It seems a great way to adjust the model. I will try as soon as possible. Thanks again!

1 Like

Hi,LIAO YUAN.I think your problem is from communication of Multi-UAV.I also meet the same problem now,could you please tell me how do you deal with it.I will appreciate you if you could show me the code about this problem.

Hi Alice. Yes, you are right. It is certainly about UAV communication. I had emailed to the author, Wu Qingqing ( and he provided related code,

sum(assignment1.*( GP1_R_lb(:,: ) + log( 1 - inv_pos( (S2(:,: ) + H^2)./( ones(K,1)p2 ) + 1 ) )/log(2) ) + …
( GP2_R_lb(:,: ) + log( 1 - inv_pos( (S1(:,: ) + H^2)./( ones(K,1)*p1 ) + 1 ) )/log(2) ),2 ) >=t_traj;

I tested it and it works well! Please refer to the code above. By the way, really nice to hear that we focus on the same research area hahaha.


Please conduct private communications via the forum message function, not by public posts.

I’m sorry for breaking the rules of the forum, I am new here,I’m not familiar with some of the functions of the forum, I am not sure how to utilize the forum message function,for example,I want to leave you a message. What should I do.I’m sorry for the inconvenience.

Click on the name of the forum member. then click on message.

cvx will reject the form as variable multiplication,the Variables are coupled,maybe divided it into two subproblrm then Overall optimization? kan wo zi liao,liao yuan.

Hi Yuan Liao, I have the similar problems with yours and I didn’t understand your codes well, can I have more details about this problem? Thank you very much!

1 Like

Hi panyu, thanks so much for your communication. The code above is all from the author. In my side, it actually works well. Could u please provide a more specific description of your problem?

1 Like

Hi Yuan Liao, I have the similar problems with yours and I didn’t understand your codes.I want to know how to expression image in cvx.And tin codes, What do p1 and p2 stand for?Thank you very much!

Could you please send the code to email? I will be very grateful!

Hello, Yuan Liao. I’m focusing on the same research area with you. Recently I meet the same problem with you. Could you please send me the related code to email? I will be very grateful to you! My email is

Hello, I encountered the same problem as you when solving the multi UAV problem, but I don’t understand the code you refer to. Could you please send me a complete reference code? My email is

How to solve the objective function in images with cvx?

image in the objective function can be entered into CVX using a first-order Taylor expansion.
image is a concave function that is fed into CVX and keeps reporting the error log(convex ).
How to equivalently translate the objective function to the type recognized by CVX? Can you give me the cvx statement after the equivalent conversion? Thanks a lot!

As mentioned in the previous link,
The first approach there is:

variables t y1 y2
t >= log_sum_exp([0 y1 y2])
eta1/(Ps*gamma0) >= exp(-y1)
eta2/(Ps*gamma0) >= exp(-y2)

Then use t in place of -log(...)