1

Given a matrix $A \in \mathbb{R}_{+}^{n \times m}$ where $m \geq n$.

I want to convert it into a form where there is a single $1$ per row yet no more than a single $1$ per column.
The logic is convert the highest sum of values into 1.

For instance, for $A = \begin{bmatrix} 0.3 & 0.25 & 0.9 \\ 0.6 & 0.1 & 0.03 \end{bmatrix}$ the output will be $B = \begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}$.

So I'm after maximizing $\sum_{i, j} \left( A \otimes B \right)$ (where $\otimes$ is the element wise multiplication) under the constraints that $ {B}_{i, j} \in \left\{ 0, 1 \right\}$, $ \sum_{i} {B}_{i, j} = 1 \; \forall j$ and $\sum_{j} {B}_{i, j} \leq 1 \; \forall i$.

The problem arises when the maximum of several columns happens at the same row:

$$A = \begin{bmatrix} 0.8 & 0.25 & 0.9 & 0.5 \\ 0.6 & 0.1 & 0.03 & 0.55 \\ 0.23 & 0.33 & 0.2 & 0.45 \end{bmatrix}$$

I am not after an optimal solution. I'm OK with a greedy solution which is fast and near optimal.

Is this problem known? Are there known greedy algorithms for the case of large matrices?

SilvioM
  • 1,339
  • 4
  • 13
Avi T
  • 113
  • 3

1 Answers1

0

Your problem can be shown to be NP-hard.

reduction from weighted maximum matching

Here is a greedy solution:

Step 0: Start with $B = \{0\}_{m\times n}$ and let $A' = A$

Step 1: Select the maximum value in the matrix $A'$ $$(i,j) \leftarrow \arg\max_{i,j} ~A'$$ Step 2: If $A'[i,j] == 0$ then STOP; else, put a mark in $B$ and clear the row and column in $A'$ i.e, $$B[i,j] = 1 \text{ and } A'[i:~] = A'[~:j] = 0$$ Step 3: Go to Step 1

codeR
  • 1,983
  • 7
  • 17