suppose there is a 0-1 matrix in 1*N like [0 0 1 1 0], i want to contrain minimum interval between 1. for example，the minimum distance between 1 is 2: [1 0 0 1] is great but [1 0 1] is not needed. how do i express this contraint in cvx
You can limit the number of 1s of every three adjacent elements to at most 1 , by limiting their sum to be smaller than 1. You might use a for-loop to do that or vectorize it to make it run faster.
thanks. and if this matrix isn’t a 0-1 matrix, i want to use 1 to represent not 0, and use 0 to represent 0. for example, i want to transfer [0.1 3 0 0.2 0 ] to [1 1 0 1 0] and then process it using methods you provide, how can i do?
i provide a code for matrix to vectorize
E is like
1 1 1 …
0 1 1 1 …
0 0 1 1 1…
The transfer you mentioned is not convex. But maybe your question is related to l0-norm. For the second question, searching "vectorize " using the search box of this forum might help.
Presuming all the elements to be transferred are nonnegative, as I think is the case, I think you can use
1-y in place of
y in the solution https://or.stackexchange.com/questions/4735/how-to-apply-big-m-to-model-the-logic-constraint-if-then-else/4773#4773 . If this is not quite right, you can make the needed adjustments.
You can declare
then enter the double-sided inequality constraint from the linked solution (replacing
1-y), and that will be a vectrorized double-sided constraint, with no for loops required.