Common operations
- Vector inequality x⪯0 is the same as
max(x) <= 0- you can also just broadcast and say
x <= 0 and let it figure it out
- element-wise positive or negative component:
pos or neg
- PSD: use the psd constraint built into the optimizer
- use
hstack to combine different things together
- use
inv_pos to take the reciprocal 1/x, which is convex if x>0.
Other tips
- To optimize only one or a few values in a matrix, I recommend making the whole matrix or vector a varible, and then use equality constraint in the solver
- We are NOT DCP if we have f(x)≤0 and g(x)≥0 where f,g are both convex. This is because the standard form requires negating g, which turns it into a concave constraint.
- You can’t make numpy arrays with one cp variable, unfortunately.