1

I need to place N rects on a 2-dimensional grid with constraints.

For the each rect height/width and placing limitations($x_{min}$-$x_{max}$) are known.

The problem is to place all rects on a grid with no intersections that every rect's bottom left $x$ is in rect's $x_{min}$-$x_{max}$.

I've implemented the naive solution where I just iterating over rects and incrementing $x$ by some fixed step while checking for intersections. If no place found then I increment $y$ and iterate again.

The question: I'm sure that there are algorithms/data structures that will help me to solve this task faster, but I do not know where to start.

somebody32
  • 13
  • 2

1 Answers1

1

I suggest you use a constraint solver, like Minion. The following paper shows that they are effective for a related problem:

My thanks to András Salamon for pointing to this information.

You could also try using a SAT solver.

D.W.
  • 159,275
  • 20
  • 227
  • 470