Difference in declaring equality and inequality constraints in CVX?

Hello CVX Forum,

I currently am partaking in a course for convex optimization, in which we have some exercises with different constraints. I was just wondering whether there is further difference in declaring inequality constraints and equality constraints than just ‘=’ and ‘>=’?
To illustrate I have made one of the problems in cvx like so:

cvx_begin 
    variable x1
    variable x2
    minimize(x1^2+x2+4)
    subject to
        -x1^2-(x2+4)^2+16 >=0
        x1-x2-6>=0
cvx_end

Wherein the constraints for the function are two inequality constraints as can be seen in the exercise text here: https://imgur.com/a/xiCrG
I have solved the exercise by hand graphically and get the same result for the minimization by hand as by CVX, giving -4 as the optimal value.
Another exercise I have, with equality constraints, I have done like so:

cvx_begin
    variable x1
    variable x2
    minimize(x1^2+x2^2+5)
    subject to
        x1-x2+2==0
        3*x1+3*x2+3==0
cvx_end

Basically just wondering whether the declaration of the constraints is done right in either case?
The exercise text for the second exercise can be found here: https://imgur.com/a/aum9L
Thanks.

You have implemented both problems correctly.

1 Like