I am trying to solve the following problem. Suppose $A$ is an $m \times n$ matrix of integers with entries in $\{1, \dots, k\}$. There are two kinds of constraints on the entries of this matrix:
- For each integer, there are constraints on the number of times that integer can appear in each row and column. The integer $i$ must appear in each column no fewer than $c_i$ and no more than $C_i$ times, and in each row no fewer than $r_i$ and no more than $R_i$ times.
- For each integer $i$, it must appear in each row as part of a span - where that integer repeats for some length $l$. The length of the span must be between $s_i$ and $S_i$.
In my application, I have $m \approx 30$, $n \approx 50$, and $k \approx 10$. I tried modeling this using Google's ortools, and can generate a matrix that satisfies the constraints on the rows and columns (first bullet point), but am having trouble with the constraints on the span lengths. I came up with a solution but it runs for hours and does not find a feasible solution.
Is there a kind of problem in the literature which is similar to this? Could anyone give some pointers about how I can try to solve this?