# DCP error：Illegal operation: {log-affine} + {concave}

(Louis Liu) #1

I run my Complementary Geometric Programming below but found a problem.
t11=300;
t21=400;
t31=600;
U1=120;
U2=80;
U3=40;
T0=100;
T3=500;
WC=10^5;
AT=15000;

cvx_begin gp quiet
variables A1 A2 A3 T1 T2 t12 t22 t32
minimize AT
subject to

``````    (T1+(-T0)+t12)/t11<=1;
(T2+(-T1)+t22)/t21<=1;
(T3+(-T2)+t32)/t31<=1;
(T1+U1*WC^(-1)*A1*T0)*(T0+U1*WC^(-1)*A1*t12)^(-1)<=1;
(T2+U2*WC^(-1)*A2*T1)*(T1+U2*WC^(-1)*A2*t22)^(-1)<=1;
(T3+U3*WC^(-1)*A3*T2)*(T2+U3*WC^(-1)*A3*t32)^(-1)<=1;
A1>0;
A2>0;
A3>0;
AT>0;
t12>0;
t22>0;
t32>0;
T1>0;
T2>0;
AT=A1+A2+A3;
``````

cvx_end

Error using + (line 83)
Disciplined convex programming error:
Illegal operation: {log-affine} + {concave}

Error in CGP (line 24)
(T2+(-T1)+t22)/t21<=1;

I have read the some critical information:

and the cvx handbook about GP.
But I can not deal with my problem…Need help!

(Mark L. Stone) #2

Your CVX program has multiple serious errors. First of all, I recommend you do some more reading on Geometric Programming, such as https://stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf . Then re-read the CVX User’s Guide Geometric Programming chapter http://cvxr.com/cvx/doc/gp.html .

Here are a few things you did wrong:

You should have included the statement
`AT=A1+A2+A3`
before the minimize command in which you used it. Because you set AT to 15000 before CVX was invoked, CVX treats `minimize AT` as being `minimize 15000` , which therefore amounts to a feasibility problem, in effect ignoring the vacuous objective. Nevertheless, this will not cause a CVX error message, but likely does not do what you want.

Your first constraint illegally adds a negative constant (-T0), which is therefore not a monomial, on the left hand side; it would be acceptable if it were (T0), which is positive, and hence a monomial. Your next 5 constraints are “illegal” as well. Your remaining constraints of `variable > 0` are illegal as well because the right-hand side must be a monomial, which requires the constant to be positive; and so would be accepted if a positive number were used instead of 0 on the right-hand side. You should use >= anyhow, so constraints such as `A1 >= 0.1` would be accepted.

(Louis Liu) #3

Thank you so much sir! After reading the CGP in tutorial, I revised my code. Besides I have a question: Can we use “/” to represent division instead of using *(-1)?

t11=300;
t21=400;
t31=600;
U1=120;
U2=80;
U3=40;
T0=100;
T3=500;
WC=10^5;
AT=15000;

cvx_begin gp
variables A1 A2 A3 T1 T2 t12 t22 t32
AT=A1+A2+A3;
minimize AT
subject to
(T1+t12)(t11+T0)^(-1)<=1;
(T2+t22)
(t21+T1)^(-1)<=1;
(T3+t32)*(t31+T2)^(-1)<=1;
(T1+U1 * WC^(-1) * A1 * T0) * (T0+U1 * WC^(-1) * A1 * t12)^(-1)<=1;
(T2+U2 * WC^(-1) * A2 * T1) * (T1+U2 * WC^(-1) * A2 * t22)^(-1)<=1;
(T3+U3 * WC^(-1) * A3 * T2) * (T2+U3 * WC^(-1) * A3 * t32)^(-1)<=1;

``````    A1>=0.1;
A2>=0.1;
A3>=0.1;
AT>=0.1;
T1>=0.1;
T2>=0.1;
t12>=0.1;
t22>=0.1;
t32>=0.1;
``````

cvx_end

Some errors:
Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {log-convex} .* {log-concave}

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

Error in CGP (line 25)
(T2+t22)*(t21+T1)^(-1)<=1;

Thank you a lot in advance!

(Mark L. Stone) #4

You can use / instead of *(-1).

You are not allowed to have a posynomial divided by a posynomial. or 1 divided by a posynomial. I’m not sure what your 4th to 6th constraints are (please use preformatted text on code (so that all the symbols appear), so I won’t comment on them.

When I mentioned 0.1 in my previous reply, that was an example of code which would be accepted. It’s up to you to make sure you use something appropriate for the problem you are trying to solve. Also, get in the habit of using >= or <= in CVX, rather than > or <. And don’t use the quiet option until you have your program all checked out and running correctly.

(Louis Liu) #5

Yeah, it is said: “while strict inequalities <, > are supported, they are treated as non-strict inequalities and should therefore be avoided.”. Consequently, I have revised my previous reply. Besides, all the variables in the problem actually are larger than 100.

Hope you give more comments. Thank you very much!

(Mark L. Stone) #6

I don’t have access to the paper, but the abstract says

An extension of geometric programming to handle rational functions of posynomials is presented. The solution technique consists of successive approximations of posynomials and solution of ordinary geometric programs. …

Rational functions of posynomials are not allowed in CVX, and I believe are not convex. That said, successive approximations of the original problem by problems which are allowable in CVX might be possible. I think if you are trying to do that, you are jumping in over your head, as you have not yet mastered the basics of geometric programming.

(Louis Liu) #7

All right, Thank you very much for your help!