# Wolfram Language™

## Optimal Floor Planning

Consider the problem of placing smaller rectangles within a larger rectangle of minimal perimeter with constraints on the relative placement, aspect ratio, spacing between and area of the smaller rectangles.

This example demonstrates use of the Wolfram Language for defining a function that uses NMinimize to solve floor-planning problems. The function uses vector inequalities, including a semidefinite inequality.

Describe the larger rectangle by Rectangle[{0, 0}, {H, W}] and each of the smaller ones by ri=Rectangle[{xi, yi}, {xi+wi, yi+hi}], i=1 n .

The relative placement can be described by two directed graphs, one for horizontal placement and one for vertical placement. If there is a edge ij, then ri should be to the left of (or below) rj.

For simplicity, assume that all rectangles should have an aspect ratio between and for and that the spacing between rectangles is .

Given these inputs and a list of the areas of the smaller rectangles, can define a function planFloor that finds the minimum perimeter of the larger rectangle.

show complete Wolfram Language input

Set up graphs for the relative placement of 10 smaller rectangles.

Require that the areas of all the smaller rectangles be 100, except for one that has area 400.

This optimizes the floor plan.

Show the optimal plan.

This shows that the area constraint is satisfied with equality.

Compare layouts when the areas are made random.