Consider a large rectangle frame, as we want to fill it with small rectangles with variable sizes. How to calculate the best match of inner objects to minimize empty spaces inside the main frame?
Alternatively, consider that the rectangle height is variable, how to re-arrange inner elements to minimize the main frame height.
An example is drawn in the following image. How to re-arrange the order (but not rotate) to fir the rectangle in the frame with minimum height (smallest possible frame).