Stockmeyer
Stockmeyer
Stockmeyer Algorithm
ECE 6133
Amanda Cummings
The Algorithm itself
The goal of the algorithm is to find the
optimal orientation of the blocks in the
floorplan for the minimal area.
Often used as a post-process to further
optimize the area objective
How it was implemented
Will use the example on pg 65 in the
book.
◦ Polish expression for the book example is “3-
7-H-5-1-V-8-2-H-V-4-V-6-V-H”.
◦ The slicing tree and the original floorplan:
Polish Expression
Postorder traversal
Assume that xyH means x is top and y is
bottom, and xyV means x is left and y is
right
◦ The area of the cut xyH has a width =
max(Wx , Wy) and a height = Hx + Hy
◦ The area of the cut xyV has a width = Wx +
Wy and a height = max(Hx , Hy)
Inputs into Stockmeyer Code
The input is a .ple file
◦ The first line has the polish expression of the
floorplan consisting of blocks starting a 0 and
the ‘-’ delimeter
◦ The rest of the lines contain the width and
height of a block separated by a space
2nd line has the width and height of block 0, 3rd line
has the width and height of block 1, etc.
Parse Input file
My code takes the polish expression
string out to parse
Then, it places all of the widths and
heights into a vector of pairs.
◦ wh[0].first = width of block 0
◦ wh[0].second = height of block 0
Start to build a Tree
Created a structure called node that will
be used to build a tree
While loop with the condition of the
polish expression string does not equal
null, then parse the string using the ‘-’
delimeter
◦ If the parse is an H or a V, then it is a root, and
special calculations need to happen
◦ Else create a leaf with NULL left and right
pointers
Connecting the root nodes to its
children
Postorder expression gives you
left,right,root:
Calculations Needed
First, sort width and height combinations
(stored in a vector) of the children according
to the root
◦ H sorts into decreasing widths
◦ V sorts into increasing widths
Calculate width and height combinations of
the root and store in a vector
◦ Store information of what child combinations
created the root combination in a separate
vector
Calculations (cont’d)
New Area and traversal
Once all of the width and height
calculations are done, sort through the
Main Root’s width and height
combinations to get the minimum area
Traverse back down the tree to change
the orientations of the leaves that is
needed to obtain the
Calculate the coorinates of the leaves
while traversing back down the tree
New Area and traversal (cont’d)
Plotting Floorplan
Not part of the Stockmeyer Algorithm!
Output the old coordinates, old width
and heights, and block number into a .txt
file
Output the new coordinates, new width
and heights, and block number into a .txt
file
Use Matlab to plot
Floorplan of Example
The blocks that rotated were 6, 2, 5 and 7
Results
# Blocks Original Area New Area % improvement Performance Time # Blocks Rotated Blocks rotated
5 65 65 0 0.009017778 1 0