What is the best design for dynamic assignment of locations for variable sized grid boxes to occupy?
This is actually an NP-complete problem 

You won't find an optimal way to pack your bins, but you can find a good way

Here's Joe Celko's take on it:

https://www.simple-talk.com/sql/t-sql-programming/bin-packing-problems-the-sql/