5

I have a binary matrix n*m (0's and 1's). Problem is to cover all 1's with non-overlapping boxes whose elements are all 1.

Example:

1111
0110
0110

Box can be represent with coordinates and lengths in each coordinate (x,y,lx,ly). This example is covered with 2 boxes { (0,0,1,4), (1,1,2,2) }.

I'm looking how to find cover with minimal number of boxes.

Thanks

Ante
  • 5,350
  • 6
  • 23
  • 46

1 Answers1

0

This problem is called partition of rectilinear polyhedron. There is a good answer on similar question biziclop posted in a comment.

Idea of algorithm is to reduce problem to maximum matching of bipartite graph (vertices are possible cuts.)

3D

My original problem was same topic in 3D. That version is shown to be NP-complete :-/

After some research, I implemented solution based on heuristic described in papers by Anuj Jain:

Community
  • 1
  • 1
Ante
  • 5,350
  • 6
  • 23
  • 46