Miriam_C
(Miriam C)
March 19, 2024, 9:38am
1
How can i calculate the square of the norm of the variable vector?
By the way, I previously tried the square_pos function,
i.e., square_pos(norm(wj))
but it does not return the suqare of the norm of the vector wj, instead it always gives me 1 no matter what value wj has.
Miriam_C
(Miriam C)
March 19, 2024, 9:41am
2
Moreover, when i use square or .^2, it tells me it is “Disciplined convex programming error:
Illegal operation: square( {convex} ).”
Miriam_C
(Miriam C)
March 19, 2024, 9:42am
3
This is the error of square_pos(norm(wj))
You should be using square_pos
, and it should work correctly. So something is screwed up or conflicting in your CVX installation or MATLAB session.
Try reinstalling a newly downloaded CVX 2.2 in a fresh MATLAB session.
As shown in the figure, i think the output result of function square_pos in cvx is wrong,can you help me?
[微信截图_20230503151420]
pow_pos(norm(wj),2)
and
pow_p(norm(wj),2)
should also work.
1 Like
Erling
(Erling D.Andersen)
March 20, 2024, 6:18am
6
I would do
norm(wj) <= constant
rather than
pow_pos(norm(wj),2) <= constant^2
The squaring does no good in this case.
@Erling That is not applicable here because there is a sum of norm squared terms.
Erling
(Erling D.Andersen)
March 20, 2024, 12:06pm
8
Sorry, about that. Ignore my post then.
\sum_{i=1}^n \|x_i\|^2\leq p
is
\|[x_1;\ldots;x_n]\|_2\leq \sqrt{p}
The difference should be irrelevant for typical nice problems but for more nasty problems the second formulation has some advantages: possibly shorter CVX model without adding in a loop, only one long cone instead of 2n short ones (somewhat better at least for Mosek), value of order \sqrt{p} rather than p , and personally I prefer u rather than (\sqrt{u})^2 .
Mea culpa. Yes, the arguments can be stacked into one vector.