Setup
I have a non-empty set of elements $U$ that are arranged spatially.
I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements.
I would like to also partition $U$ into $N$ non-empty, disjoint subsets, $B_j$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements.
Finally, I'd like to require that for every subset $A_i$, and $B_j$ that $\lvert A_i \cap B_j \rvert = 1$.
Concrete example
Consider a 3 x 3 grid of elements. The first partition would consist of one subset for each row. The second partition would consist of one subset for each column. Every element would then only exist in exactly one subset of each partition.
This is of course not the only solution. One could have a partition consisting of the upper left three elements, antidiagonal elements and lower-right three elements. The second partition would then consist of the top right three elements, diagonal elements, and lower left three elements.
My goal
I would like to identify a process where I provide the set $U$ and parameter $M$ and the first and second partitions are produced.
As a modification to that first goal, to find an optimal partition that minimizes the aggregate distance between elements within all subsets.
My intuition is that this is a variant of set cover, and could be modeled via ILP, but I want to open this up to get other opinions on how to approach this.
Clarifications
- What do you mean by "Each subset is only allowed to contain neighboring elements"?
Every element in the subset is within a fixed distance of at least one other element in the subset. Assume some distance metric to measure distance.
- What do you mean by "the aggregate distance between elements within all subsets"?
Given the elements in a subset, construct a weighted complete graph. Each edge has weight equal to the distance between the elements. Find the minimum spanning tree. Take the sum of the edges. Call that $d(S)$.
Goal is to minimize $\sum_i d(A_i) + \sum_j d(B_j)$