Arranging Rectangles within a given area

Hi all,

I have a tricky problem. I’m hoping someone can point me in the right direction.

The problem:
Given a variable number of rectangles which each have their own dimension, and an area with a fixed dimension to place them in, how can I calculate where they can be positioned?

The rectangles that I’m fitting can change size, but they must remain proportionality the same to their original dimension. Also, each rectangle has a certain ratio which it maintains with the other rectangles (based on it’s total dimensions, so if I want them to be 2:1, I could have something like 10x10(=100) and 25x2(=50)).

Anyone have any ideas or starting points for me?

Thanks.