I'm trying to implement the algorithm outlined in https://arxiv.org/abs/1211.5608 on a small scale. I have a linear operator $\mathcal{A}$ which is defined as $$\text{trace}(A^*_l(hm^*))$$ where $$A_l = \hat{b}_l\hat{c}_l^*$$, where $\hat{b}_l$ and $\hat{c}_l^*$ are columns and vectors of different matrices.

I've used this as a constraint to solve the problem

$$\min \|X\|_*$$ subject to $$\hat{y} = \mathcal{A}(X)$$

In CVXPY, I made the constraint:

constraints = [cp.trace(np.transpose((B_hat_star[:,col][:,np.newaxis]*np.sqrt(L)*C_hat[col,:])) @ X) == y_hat[col] for col in range(L)]

and this works. However, now I'm trying to make the constraint: $\|\hat{y} - \mathcal{A}(X)\|_2 \leq \delta$. I'm not sure how to enforce a norm constraint on a matrix that is defined with a for loop (as above). I've tried doing

constraints = [cp.norm([y_hat[col] - cp.trace(np.transpose((B_hat_star[:,col][:,np.newaxis]*np.sqrt(L)*C_hat[col,:])) @ X) for col in range(L)], 2) <= delta], but I get an error that says ValueError: setting an array element with a sequence.


CVXPY's norm atom won't accept a raw Python list as an argument; you need to pass it a CVXPY expression. Stack the list of scalars into a vector using the hstack atom, like so:

constraints = [cp.norm(
        y_hat[col] - cp.trace(
            np.transpose((B_hat_star[:,col][:,np.newaxis]*np.sqrt(L)*C_hat[col,:])) @ X)
        for col in range(L)
    ]), 2) <= delta]
| cite | improve this answer | |
  • $\begingroup$ thank you so much! $\endgroup$ – akonishi Jun 11 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.