# Disciplined convex programming error: Cannot perform the operation: {positive constant} ./ {convex}

Hi everyone,

I have the following optimization problem

the variable of interest here is “p” with dimensions of (J*K). When I apply cvx, I get the following error

Error using cvx/rel_entr (line 71)
Disciplined convex programming error:
Illegal operation: rel_entr( {positive constant}, {convex} ).

I have searched in the forum and found that I need to rewrite my objective function in form of -log(concave function), if I got it correctly. So, now I am using

rel_entr(1, \gamma c *B/( \gamma c *B + \chi SINR))

but it seems it doesn’t work either since I am getting the following error

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {positive constant} ./ {convex}

Error in ./ (line 19)
z = times( x, y, ‘./’ );

Error in * (line 36)
z = feval( oper, x, y );

Error in / (line 15)
z = mtimes( x, y, ‘rdivide’ );

Any idea would be greatly appreciated.

Moreover, the constraint is in the form of log2(1 + ax). Is it acceptable for cvx since (1+ax) is not concave.

2 Likes

Could someone please give me a hint?

it is not the most efficient process for you to post error messages or problem or code fragments, without showing what everything really is. The reformulation I showed you with rel_entr was predicated on SINR being input data, i.e., a numerical MATLAB variable, not a CVX variable or expression.

You don’t show the code which resulted in this error message. So i I don’t know what is defined or defined as what.

help rel_entr

rel_entr Scalar relative entropy.
rel_entr(X,Y) returns an array of the same size as X+Y with the
relative entropy function applied to each element:
{ X.*LOG(X./Y) if X > 0 & Y > 0,
rel_entr(X,Y) = { 0 if X == 0 & Y >= 0,
{ +Inf otherwise.
X and Y must either be the same size, or one must be a scalar. If X and
Y are vectors, then SUM(rel_entr(X,Y)) returns their relative entropy.
If they are PDFs (that is, if X>=0, Y>=0, SUM(X)==1, SUM(Y)==1) then
this is equal to their Kullback-Liebler divergence SUM(KL_DIV(X,Y)).
-SUM(rel_entr(X,1)) returns the entropy of X.

Disciplined convex programming information:
rel_entr(X,Y) is convex in both X and Y, nonmonotonic in X, and
nonincreasing in Y. Thus when used in CVX expressions, X must be
real and affine and Y must be concave. The use of rel_entr(X,Y) in
an objective or constraint will effectively constrain both X and Y
constraints X >= 0 or Y >= 0 to enforce this.


As you can see, SINR needs to be concave

I still have no idea what’s what. I don’t know what is input data, what are decision (a.k.a. optimization a.k.a. CVX) varaibles or CVX expressions. That distinction is crucial.

1 Like

You may need to be a bit patient. It seems that I answer most of the question on this forum, as a volunteer. I do have other things I need to do, so you may have to wait for hours or possibly days to get replies in some cases.

Sorry! I didn’t mean that. I just wondering if someone else got the same error and knows how to solve that.
It’s awesome to see that people like you spend their time voluntarily to help others. I DO appreciate your time and help. Sorry again!

Hi Mark,

Here is my code. Would you please be so kind as to take a look at my code and tell me what I should do to get rid of this error?Thanks in advance!
The error that I get shows up in the line that I have defined cvx_expression_H1 which is concave.
I write out the log2(convex function) in the objective function as -log2(cvx_expression_H1) = rel_entr(1,cvx_expresion_H1). I am not sure if I am doing it correctly though.

For running this code you need some other data, but I don’t know how I can upload them here.

%%%%
the error that I get is either
Error using cvx/pow_cvx (line 144)
Disciplined convex programming error:
Illegal operation: pow_p( {convex}, {-1} )

Error in cvx/inv_pos (line 5)
y = pow_cvx( x, -1, ‘pow_p’ );

or
Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {convex}

Error in * (line 36)
z = feval( oper, x, y );

Which error occurs when you run the code shown? I Which line of code is the error occurring on? Did you check the reported error against your code, examining the argument? You can just type any CVX expression and hit return, and CVX will tell you what kind of expression ti is. Obviously you are violating CVX’s rules, so the first thing you need to do is provide that your optimization problem formulation is convex.

1. Which error occurs when you run the code shown?
the error that I get is either
Error using cvx/pow_cvx (line 144)
Disciplined convex programming error:
Illegal operation: pow_p( {convex}, {-1} )

Error in cvx/inv_pos (line 5)
y = pow_cvx( x, -1, ‘pow_p’ );

when I use cvx_expression_H0 or

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {real affine} .* {convex}

Error in * (line 36)
z = feval( oper, x, y );

when I use cvx_expression_H1.

1. I Which line of code is the error occurring on?
The error that I get shows up in the line that I have defined cvx_expression_H1 which is concave.
I write out the log2(convex function) in the objective function as -log2(cvx_expression_H1) = rel_entr(1,cvx_expresion_H1). I am not sure if I am doing it correctly though.

2. You can just type any CVX expression and hit return, and CVX will tell you what kind of expression ti is.
Thanks, I didn’t know that. However, when I type the CVX expression and hit return it comes with lots of undefined variable of functions!

Same advice as on other question. You have a problem which does not appear to be convex. If it not convex, here is no reformulation which will be accepted by CVX. The burden is on you to prove your optimization problem is convex.

2 Likes

Thank you so much for your feedback. I will double check the convexity then.