Say I have a sequence [3,1,0,2], where each element is a decision variable, i.e. I decide upon an optimal sequence of numbers. Is there an appropriate way to convert this sequence to a 2D succession matrix without introducing too many auxiliary variables?
Example
[3,1,0,2] becomes
[[0, 0, 1, 0],
[1, 0, 0, 0],
[0, 0, 0, 0],
[0, 1, 0, 0]]
Read as "0 is followed by 2" for the first row, "1 is followed by 0" in the second row etc. I need this matrix as a decision variable, at the premise that it is equal to the sequence.
If it is any help, I work with Python, using OR-tools version V9.8