<p>I was wondering if the following problem has been studied/has a name:</p>

<p>Given a matrix of numbers (may assume to be integers), find the smallest number of rules which define the matrix. Three kinds of rules may be used:</p>

<ul>
<li>row rules:     row[i, x] - the value of any cell in row i is x</li>
<li>column rules:  col[j, x] - the value of any cell in column j is x</li>
<li>cell rules:    cell[i, j, x] - the value of cell at [i,j] is x</li>
</ul>

<p>The rules have a precedence order: first cell rules are considered, then row rules, then column rules.</p>

<p>Example:</p>

<p>Given the 3 x 3 matrix:</p>

<pre><code>2 2 2
1 2 3
1 3 3
</code></pre>

<p>one set of rules which describe the matrix is:</p>

<pre><code>row[1,2], col[3,3], col[1,1], cell[2,2,2], cell[3,2,3]
</code></pre>

<p>Edit: I would be interested in getting opinions on what the complexity is of this problem. I have a polynomial time algorithm which does well enough for my use cases, but it would nice to know if the general case is not in P.</p>

CC BY-SA 3.0
2011-05-29T07:19:45.393Z
A slightly different way of thinking about the problem is that $row[i,x]$ means that *all* entries in row $i$ have value $x$, similarly for $col[j,x]$ *and*, rather than having a precedence order, simply have that later 'operations' override earlier ones. Thus your example could be given by $row[3,3], col[1,1], col[3,3], row[1,2], cell[2,2,2]$. Of course, this is a different problem than the one you state.
Dave Clarke
CC BY-SA 3.0
2011-05-29T07:31:38.827Z
The points being: 1) you probably mean "all" instead of "any", and 2) applying the rules in order rather than using the given precedence makes the problem more natural. Consider matrix $[1, 2, 3; 1, 2, 3; 1, 4, 4]$. With my scheme this is $col[1,1],row[3,4],col[2,2],col[3,3]$, but in your scheme I'm forced to apply the $row$ operation first.
Dave Clarke
CC BY-SA 3.0
2011-05-29T07:42:43.453Z
While this is not your problem, (or even Dave's reformulation) a related question where the only "rule" is the ability to cover a subrectangle, and the only "values" are 0 and 1, was considered by Applegate et al: http://www.cs.cornell.edu/~katrina/papers/acl.pdf
Suresh Venkat
CC BY-SA 3.0
2011-06-01T23:13:37.540Z
I think that Dave’s problem becomes equivalent to this problem if we add the (arguably unnatural) constraint to Dave’s problem that operations must appear in the order of col, row and cell.
Tsuyoshi Ito
<ds.algorithms><optimization><matrices>
Row/column overlay problem for filling in a matrix
ErikR
# Row/column overlay problem for filling in a matrix

(Asked by: username_0 on 2011-05-29)

I was wondering if the following problem has been studied/has a name:
Given a matrix of numbers (may assume to be integers), find the smallest number of rules which define the matrix. Three kinds of rules may be used:

row rules:     row[i, x] - the value of any cell in row i is x
column rules:  col[j, x] - the value of any cell in column j is x
cell rules:    cell[i, j, x] - the value of cell at [i,j] is x

The rules have a precedence order: first cell rules are considered, then row rules, then column rules.
Example:
Given the 3 x 3 matrix:
2 2 2
1 2 3
1 3 3

one set of rules which describe the matrix is:
row[1,2], col[3,3], col[1,1], cell[2,2,2], cell[3,2,3]

Edit: I would be interested in getting opinions on what the complexity is of this problem. I have a polynomial time algorithm which does well enough for my use cases, but it would nice to know if the general case is not in P.

**Tags:** ds.algorithms, optimization, matrices
> **Comments:**
> **username_1**: A slightly different way of thinking about the problem is that $row[i,x]$ means that *all* entries in row $i$ have value $x$, similarly for $col[j,x]$ *and*, rather than having a precedence order, simply have that later 'operations' override earlier ones. Thus your example could be given by $row[3,3], col[1,1], col[3,3], row[1,2], cell[2,2,2]$. Of course, this is a different problem than the one you state.  
> **username_1**: The points being: 1) you probably mean "all" instead of "any", and 2) applying the rules in order rather than using the given precedence makes the problem more natural. Consider matrix $[1, 2, 3; 1, 2, 3; 1, 4, 4]$. With my scheme this is $col[1,1],row[3,4],col[2,2],col[3,3]$, but in your scheme I'm forced to apply the $row$ operation first.  
> **username_2**: While this is not your problem, (or even Dave's reformulation) a related question where the only "rule" is the ability to cover a subrectangle, and the only "values" are 0 and 1, was considered by Applegate et al: http://www.cs.cornell.edu/~katrina/papers/acl.pdf  
> **username_3**: I think that Dave’s problem becomes equivalent to this problem if we add the (arguably unnatural) constraint to Dave’s problem that operations must appear in the order of col, row and cell.  

---

## 0 answers

