Using decision variables as a condition for if statement


I want to ask if I can use a decision variable as a condition for “if statement” while writing a constraint during optimizing (I mean between cvx_begin and cvx_end)??? is CVX capable of this???

If you try it, you should get the error message “Disciplined convex programming error: Constraints may not appear in if/then statements.” Depending on your model, perhaps there is another way of accomplishing it? Will integer or binary variables let you formulate your model as a mixed integer DCP?

Mark is correct. This is not possible, so you have to find a way to express your model in a different fashion.