Disciplined convex programming error: Cannot perform the operation: {real affine} .* {convex}

Is sum(El,2) <= h accepted by CVX? If so, everything is fine.

If sum(El,2) <= h is not accepted by CVX, can you prove that sum(El,2) is a convex function of the CVX (optimization) variables?

Well, approximating the electrical energy consumption by biquadratic or piecewise affine function I still used

 sum(El,2) 
still as function of Tz and s and that constraint was definitely accepted by CVX.
Of course, in those cases El was written as follows
 El(:,i) =  Chiller{i}.Model.c1*Ech(:,i).^4 + ...
        + Chiller{i}.Model.c2*Ech(:,i).^2 + ...
        + Chiller{i}.Model.c3;
or

El_PWA(:,i) = max(kron(Chiller{i}.Model.M,Ech_PWA(:,i)’)+kron(Chiller{i}.Model.Q,ones(1,M)));

I don’t understand what you are doing and where your problem is. Please indicate very clearly what you want to get accepted by CVX but is not accepted by CVX, and show you have proven that that is convex with respect to the CVX variables.

Ok, I try to recap what has ben recurring each time I run the code. I’m given this type of error:


Why is it a “Disciplined convex programming error”? I guess it’s due to the fact that the ratio of two functions is almost never convex, but El-as said by my superviosr- is convex in the domain we’re actually considering. Thanks to optimization variables I can express Ech (energy requird to the chiller), and in turn El is computed as a function of Ech. Are there any suitable CVX functions in order to model thoroughly this formulation without receiving any error meassge by CVX? Is there a way to write down constraints which enable El to be convex only on a restricted domain? I’m not able to proceed since I get stuck on this type of error and I 'm not able to figure out anything.
The code is the one I’ve posted some comments above. In the end, when I try to run the following concerning the absorbed electricity

 y0:sum(El,2)  <= h 
CVX shows this message
.
So, the question is: how can I model the original formulation with suitable CVX functions in order to be recognized by the system?

Thanks in advance,
Paolo

It usually is difficult or impossible to model in CVX functions which are convex on only a portion of their domain, although there are some exceptions, such as inv_pos which basically removes the non-convex portion of the function.

As for El, the expression (line of code) El(:,i)=.... is rejected by CVX. Therefore, El is never “defined”, and therefore you receive an error message when you try to use it later in your code.

Do you have a proof, rather than just “your supervisor said”, that the function you are trying to model is convex over the specified domain? There have been many erroneous convexity claims made on this forum.

Sorry Mark, you mean the convexity of El or of the cost function?

All constraints and the objective function must be convex. If CVX accepts a constraint or objective, that proves it’s convex. Otherwise, you need to prove it.

I’m sorry you are struggling, but I strongly suspect there is no way CVX can accept this problem. As the FAQ states, it doesn’t matter if you can prove convexity in other ways. If you can’t build your expressions according to the DCP rules, CVX simply can’t solve it. CVX does not claim to work with all convex problems, and it never will.

Ok Michael , I do trust you, the point is the I was assigned this task being previously guaranteed by my supervisor that there’s a way to model this equation thanks to special CVX functions. I texted once again this week and I’ve been replied he managed to model this using these functions, but of course he wants me to solve by my own. It’s been almost one month since I got stuck upon this issue, but so far all the times I thought I found the way, I had to start all over again. I’ve tried to use Taylor-MacLaurin Approximation but the results were completely wrong, because they don’t match at all with my previous ones.
I’m only asking if there’s a proper way to model ratio among two affine functions, I’ve tried commands pow_pos and inv_pos but I was given error all these times, if you could suggest me any other command different from these latter I’d be really really grateful.``

Thank you all anyway for making yourselves available,
Paolo De Bella

If your professor is asking you to figure this out, then it’s probably not the best for us to be doing your work for you. However, please feel free to tell your professor that the author of CVX thinks that he ought to have helped you out weeks ago. :wink:

I have same problem in my code, %convex optimization for optimizing allocated powers (P1 and P2)

cvx_begin quiet
cvx_solver mosek
variable P(2,1)   %optimization variables
R_min = 1;   % 1 bits/Hz (minimum transmission rate)
maximize(Mn-mu_n*(1+exp(-an*(gnx*(P(1)+P(2))-bn))))
subject to
 R1 = log2(1+(P(1)*hix)./(P(2)*hix)+Ni);
 R2 = log2(1+(P(2)*hjx)./(Nj));
 R3 = log2(1+(P(1)*hjx)./((P(2)*hjx)+Nj));
 R1 >= R_min;
 R2 >= R_min;
 R3 >= R1+R2;
 qmx*(P(1)+P(2)) <= Gamma_m;
 mu_n >= 0;
 cvx_end

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

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

Error in nov22 (line 41)
R1 = log2(1+(P(1)*hix)./(P(2)*hix)+Ni);

I believe that is non-convex as written, Why isn't CVX accepting my model? READ THIS FIRST!

However, can you expionentiate to produce
(1+(P(1)*hix)./(P(2)*hix)+Ni) >= 2^R_min
then multiply through the denominator with all signs being what they need to be? I don;t knwo whether that will work out.

Thank you and sorry for inconvenience,
P(1,1) and P(2,1) are optimizing variables, i have done whatever you say but problem with R3 which is (R1+R2 ), now same error occured with R3, what should i do with? and one more problem while doing this, after optimizing P(2,1) is always zero when i considered R3 as R_min for checking, problem will solved or not…like this
P =

0.0034
0.0000

value of K:0.017166
value of P(1):0.003387
value of P(2):0.000000
value of gnx:1.328718
value of Phi_ERn:23.262592
value of updated mu_n:0.023263
value of j:9.000000

Have you shown that R3 >= R1+R2 is convex or transformable into a convex constraint?

i tried but it is always P(1,1) / P(2,1) form, they are not separating
(P(1,1)*hjx) >= (1+(P(1,1)*hix))*inv_pos((P(2,1)hix)+Ni)+(P(2,1)hjx)(inv_pos(Nj))((P(2,1)*hjx)+Nj);
like this

If I fixed Rth as a constant value but one optimizing variable is always zero, what does it mean?, is it not considering the constraint or anything or does it mean it is considering only one variable by taking one variable right side

I don;t even know what problem you are solving if not all constraints have been successfully entered into and accepted by CVX. Any constraint which is not accepted by CVX is “ignored” by CVX and not part of the problem which it provides to the solver.

Have you carefully read and thought about this yet? Why isn't CVX accepting my model? READ THIS FIRST!

Firstly thanks a lot for your support,
Sir author is using successive convex approximation in which objective function is convex and objective function is transformed by updating value. I also provided you my algorithm in previous question, i have seen you have discussed this problem 3 years ago,’’ [A concave maximization problem with Disciplined convex programming error: {invalid} .* {real affine} or {negative constant} "
this is my objective function
maximize(Mn-mu_n*(1+exp(-an*(gnx(1,t)(P(1,1)+P(2,1))-bn))))
(Mn,an,bn are constant value, mu_n is nonnegative variable (10^-6) ,P(1,1) & P(2,1) are optimizing variable and gnx is array of 10 random value
Getting error,
Disciplined convex programming error:
Cannot perform the operation: {invalid} .
{log-convex}
In one program it runs easily but by changing some parameter it is showing like that, please help me, and only because of you i have an hope to solve problem.

Read Illegal operation: {invalid} + {mixed real affine/constant} and see whther that gives you some things to look at and think about.

I have not understood what you told here