I have an optimization problem to solve, which is a constrained least squares. I am trying to solve it using CVX toolbox in Python.
Here is the optimization problem:
$$\hat{H} = \arg \min_H \vert \vert A \: \text{vec}(H) - b\vert \vert_2^2$$ $$\text{subject to} \quad H^TH = I$$
Here $H \in \mathbb{R}^{p \times p}$ where $p = 2$.
Question is how to formulate it correctly in one of the CVX frameworks? Please bear in mind that I am comparatively new to CVX and still getting the hang of the syntax.
Given the quadratic constraint, I tried to do it this way
$$\hat{H} = \arg \min_H \: \textbf{tr}(I - H^TH)$$ $$\text{subject to} \quad A \: \text{vec}(H) = b$$
But this does not follow some DCP rules. The choice of using trace was to make sure the cost function is a scalar as required by CVX. How else can I formulate this? Please let me know if more clarifications are required!
Here is my code that I tried:
H1 = cp.Variable((nDim, nDim))
prob = cp.Problem(cp.Minimize(cp.trace(np.identity(nDim) - H1.T @ H1)),
[Phi @ cp.vec(H1) == cp.vec(B1)])
prob.solve()
If needed I can also update the code with some randomly generated matrices $A$ and $b$.