I've got the following problem,

I've got a fixed size square and within there are a fixed number of rectangles to be contained within it. I want the rectangles to cover the maximum amount of space within the square. The size of the rectangles is determined by a weighting. The higher the value of an individual weight of a rectangle, the bigger its surface area.

Assuming I have a predetermined weighting for all 9 rectangles, how do I derive at the coordinates (for their position in the square) and their dimensions (width and length).

this has had me puzzled, hope someone can help me out...thanks!!