ERROR Not a square but I find the Usage is same as some examples

(李文生) #1

I just started using CVX, and when I try to run the following Program, it shows the error ‘not a square’ in the ’ 4 * A * C == -1’,but I can’t find the reason,could you give me a guide?
cvx_begin
variables A B C D E F
expression P(N)
for n=1:N
P(n)=A*(x(n)^2)+Bx(n)y(n)+C(y(n)^2)+Dx(n)+E*y(n)+F;
end

minimize( norm(P,2))
subject to
    B == 0
    
    4 * A * C == -1
    
    (E / (- 2 * C ))< MinY
    
    (D/(-2*A)) <= Xlr(i,2)
    
    (D/(-2*A)) >= Xlr(i,1)

cvx_end
error
Disciplined convex programming error:
Invalid quadratic form(s): not a square.
出错 * (line 36)
z = feval( oper, x, y );
出错 OSCA (line 135)
4 * A * C == -1

(Mark L. Stone) #2

The error message is because of the product of A with C. That is a non-convex “quadratic” term, and violates CVX’s DCP rules. Even if the Left Hand Side were convex, which it is not, nonlinear equalities are not allowed in CVX, because they are non-convex.

Can you please show us which examples have the same usage as your program?

(李文生) #3

Thank you for your explanation.
As for the example.hhhhh,I suddenly felt a little embarrassed.
Today I have seen an objective function: minimizing (wht)
and one of it’s constraints is W*h= A, which A is a constant.
At that time , I took my attention to the constants between both two ,and Ignoring the objective function between them. so In fact this two can’t be considered to be the same.

(Mark L. Stone) #4

if one of W and h were a constant, then W*h= A would be an affine( (linear) constraint, which is convex and allowed by CVX.

(李文生) #5

thank you,and I remembered another problem. When I executed the following statement
(E / (- 2 * C )) < MinY, I got an error ‘Cannot perform the operation: {real affine} ./ {real affine}’
I can’t understand why cvx can’t perform the operation,could you please give me some advice?

(Mark L. Stone) #6

If E and C are both CVX variables or expressions, which based on the error message they are, then the expression is non-convex, and is not allowed by CVX. Please carefully read the link in my first post of this thread. Also, you would benefit by reading and solving the exercises in " Convex Optimization" by Boyd and Vandenberghe https://web.stanford.edu/~boyd/cvxbook/ - that will require some effrort on your part.

(李文生) #7

Thank you again for your patient explanation.and I’ll read the link carefully:grinning::grinning: