Data structureresearch
ASF-B*-tree
Also called automatically symmetric-feasible B*-tree, symmetry island B*-tree.
A B*-tree over the representatives of one symmetric set whose every packing is mirror-symmetric about the axis, used in analog placement by Lin and Lin and by Lin, Chang and Lin.
- Time
- O(n) delete · insert · pack · swapO(1) rotate
- Space
- O(n) extra
- Where
- n = the number of representatives (pairs plus self-symmetric cells)
- Model
- Word RAM
- Properties
- not concurrentnot externalnot persistent
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Po Hung Lin, Shyh Chang Lin, Yao Wen Chang, 2007
An ASF-B*-tree (automatically symmetric-feasible B*-tree) is a B*-tree over half of a symmetric set of an analog circuit: the right cell of each matched pair, and the right half of each cell that must sit on the axis. Its topic is analog sizing and layout, one of the five topics of this sub-area. The tree packs this half, and the other half is its mirror image, so every packing is symmetric by construction, as the symmetry constraint asks. Lin and Lin gave it in 2007 to keep a symmetric set together as one block, a symmetry island, in an annealing placer.
In plain words
Some blocks of an analog circuit come in matched pairs that must be mirror images about one vertical line, and some must sit on that line.
Draw only the right half. Keep the right block of each pair, and the right half of each block that sits on the line. Pack these pieces with a B*-tree, the usual tree for packing blocks: a left child goes to the right of its parent, and a right child goes on top of it. Then copy the drawing in a mirror to the left of the line.
The blocks that must sit on the line are kept on the chain from the root through right children. Those are exactly the pieces that touch the line. With that one rule, every tree the search can make gives a symmetric picture with no overlap, so the search never wastes time on broken trees.
The abstract type
A symmetric set with a vertical axis has pairs, each of two cells of equal size, and self-symmetric cells. The structure holds a placement of the group, and supports:
- PACK: the placement of all cells of the group, mirror-symmetric about , with its width and height.
- ROTATE: turn a pair (both cells) or a self-symmetric cell by 90 degrees.
- SWAP: exchange two representatives in the tree.
- DELETE and INSERT: move a representative to another place in the tree.
Every sequence of these operations leaves a tree whose packing is symmetric. In a placer the group is then one block of a larger floorplan, and its packing gives the shape of that block.
Representation
The tree has one node per representative. The representative of a pair is its right cell, of size . The representative of a self-symmetric cell of size is its right half, of size . Each node has a left child, a right child and a size. The packing rules are those of the B*-tree: the root has , the left child of has , and the right child has .
The rightmost branch is the root and its chain of right children. The tree is an ASF-B*-tree when every self-symmetric representative is on the rightmost branch. The axis is the line , and the nodes of the rightmost branch are exactly the representatives with . A pair representative may also be on the rightmost branch: then its two cells touch at the axis.
Operations
PACK(T) ▷ T is an ASF-B*-tree of representatives- 1
for each node b of T in preorder do - 2
x_b ← 0 if b is the root; x_p + w_p if b is the left child of p; x_p if b is the right child of p - 3
y_b ← the highest top among the placed nodes whose x-range meets [x_b, x_b + w_b), or 0 - 4
record the representative at (x_b, y_b) - 5
for each pair representative b: place its partner at (−x_b − w_b, y_b) - 6
for each self-symmetric b, x_b = 0: place the whole cell at (−w, y_b), width 2w, where w is the width of the half - 7
return the placement, the width 2 · max (x_b + w_b) and the height max (y_b + h_b)
Line L3 is the contour of the B*-tree page, which takes amortized time per node. The implementation searches all placed nodes, in time per node, which is simpler to check.
The moves keep the ASF rule:
- ROTATE swaps the width and height of the cell. For a self-symmetric cell of size , the half becomes .
- SWAP exchanges two labels, unless this would move a self-symmetric label off the rightmost branch.
- DELETE is the B*-tree deletion: while has two children, exchange it with its left child; then replace by its only child.
- INSERT makes the left or right child of , and the old child becomes the child of on the same side. A self-symmetric may only become the root (with the old root as its right child) or the right child of a node on the rightmost branch.
Example
Take a pair of size , a pair of size , and a self-symmetric cell of size (width by height). The representatives are (), (), and the half of (). The tree has the root , the left child of , and the right child of . The self-symmetric is the root, so it is on the rightmost branch. The preorder is .
| node | rule | right half | mirror | ||
|---|---|---|---|---|---|
| root | 0 | 0 | |||
| left of | 1 | 0 | |||
| right of | 0 | 2 |
The cell is , centered on the axis. The two cells of flank it, and the two cells of lie on top. The group fills , with area 12, which is the total area of the cells, so there is no gap. The tests confirm that 12 is the least area of any symmetric placement of this group.
A tree with the root and as the left child of is not an ASF-B*-tree: would be at , and its two halves would land at and , which is not one cell.
Correctness
The full proofs are in the correctness proof.
By the B*-tree rules, a right child has the of its parent, and a left child is further right. So every representative has , and exactly on the rightmost branch. The ASF rule thus puts every self-symmetric half on the axis, where it joins its mirror into one centered cell. The two cells of a pair have the same and mirror -ranges by line L5.
No two cells overlap. The representatives do not overlap, because line L3 puts each one above the placed nodes that share its -range. Their mirrors do not overlap for the same reason. A representative lies in and a mirror in , so they meet at most along the axis.
No placement of least area is lost. Take any symmetric placement, keep its right half, and compact it down and to the left. The self-symmetric halves stay at . By the theorem of Chang, Chang, Wu and Wu, the compact placement is the packing of a B*-tree, and its self-symmetric halves are at , so they are on the rightmost branch. So some ASF-B*-tree is as good. The tests check this on three groups by a search over a grid.
Lin, Chang and Lin also state that the packing is a symmetry island, one connected region. With the plain packing of lines L1 to L4, this does not hold for every tree. The proof file gives a tree whose packing puts a cell of a pair in a corner where it touches no other cell; the tests count 1 such tree out of 18 for the group of the example, and 3 out of 80 for a group of two pairs and two self-symmetric cells. A placer that needs one connected island must check it or pack the group in a way that keeps it.
Proof: Every packing of an ASF-B*-tree is symmetric and free of overlap, and the moves keep the tree an ASF-B*-treefull
Notation. A symmetric set has pairs, each of two cells of size , and self-symmetric cells of size . The representative of a pair is its right cell, of size . The representative of a self-symmetric cell is its right half, of size . All sizes are positive. The tree is a B*-tree over the representatives: the root has , a left child of has , and a right child has . The representatives are placed in preorder, and each takes the least that is at or above the top of every representative placed before it whose -range meets its own (line L3). The rightmost branch is the root and its chain of right children. The tree is an ASF-B*-tree if every self-symmetric representative is on the rightmost branch.
Lemma 1 (the axis is the rightmost branch). In the packing of a B*-tree, every representative has , and if and only if is on the rightmost branch.
Proof. By induction along the path from the root. The root has . A right child has the of its parent. A left child has . So for all, and exactly when every step of the path from the root goes to a right child.
Lemma 2 (no overlap among the representatives). No two representatives overlap.
Proof. Let be placed after . If their -ranges meet, line L3 gives , so is above . If they do not meet, they do not overlap.
Theorem 3 (symmetric and free of overlap). Let the tree be an ASF-B*-tree. Lines L5 and L6 place the left cell of each pair at and each self-symmetric cell at with its full width. Then the placement is mirror-symmetric about , and no two cells overlap.
Proof. Symmetry. The two cells of a pair have the same , and their -ranges and are mirror images about . A self-symmetric representative is on the rightmost branch, so by Lemma 1, and the full cell is centered on the axis.
No overlap. Cut each self-symmetric cell into its two halves; it is enough to show that no two of the pieces overlap. The pieces are the representatives, which lie in by Lemma 1, and their mirror images, which lie in . Two representatives do not overlap, by Lemma 2. Two mirror images do not overlap, because the mirror of an overlap would be an overlap of two representatives. A representative and a mirror image have -ranges whose interiors are in and , so they do not overlap.
Theorem 4 (no loss of area). For every placement of the group that is mirror-symmetric about a vertical axis, there is an ASF-B*-tree whose packing has a width and a height that are no larger.
Proof. Move the axis to . The two cells of a pair have the same and do not overlap, so they are on opposite sides of the axis; take the cell at as the representative. Together with the right halves of the self-symmetric cells, which are at , this is a placement of the representatives in without overlap. Compact it down and to the left, against and , until no representative can move. This does not increase the width or the height, and the self-symmetric halves stay at , because they cannot move left of it. Chang, Chang, Wu and Wu prove that each placement that is compact to the left and down is the packing of a B*-tree (the B*-tree page cites this). In that tree, the self-symmetric halves are at , so they are on the rightmost branch by Lemma 1, and the tree is an ASF-B*-tree. Mirroring the packing gives back a symmetric placement of the group that is no wider and no higher.
So a search over ASF-B*-trees loses no symmetric placement of least area. The tests check this consequence on three small groups by a search over a grid.
Theorem 5 (the moves keep the tree an ASF-B-tree).* ROTATE, SWAP, DELETE and INSERT, as defined on the page, map an ASF-B*-tree (minus the deleted node, between DELETE and INSERT) to an ASF-B*-tree.
Proof. ROTATE changes no link. SWAP is refused when it would put a self-symmetric label on a node off the rightmost branch, and it changes no link. DELETE of a node with two children first exchanges with its left child until has at most one child. A left child is not on the rightmost branch, so the label that moves up is a pair label, and the labels of the rightmost branch other than stay on it. Then is replaced by its only child , if any. If is on the rightmost branch and is its right child, the nodes below on the rightmost branch move up by one and stay on it. If is a left child, has no right child, so no self-symmetric label was below on the rightmost branch. If is off the rightmost branch, the rightmost branch does not change. INSERT of as the side child of makes the old child a child of on the same side, so every node keeps the kind of path from the root it had, except that is added on it; with empty, becomes the root and the old root its right child, which keeps the old rightmost branch below . A self-symmetric is inserted only as the root or as the right child of a node on the rightmost branch, so it lands on the rightmost branch.
What is not true: a packing need not be connected. Take a self-symmetric cell of size , a pair of and a pair of . The tree has the root , the right child of , and the left child of . The packing puts the half of at , at and at . The -range of meets no placed cell, so , and is at . It shares no boundary with any other cell, and neither does its mirror. So this packing of an ASF-B*-tree is symmetric but not one connected region. The tests check this tree, and they count 3 trees out of 80 with disconnected packings for a group of two pairs and two self-symmetric cells.
What is proved here: Lemmas 1 and 2 and Theorems 3 and 5, and Theorem 4 given the cited result on B*-trees. What is cited: the B*-tree theorem on compact placements, and the symmetry-island theorem of Lin, Chang and Lin, which the example above shows needs more than the plain contour packing. What is measured: that the least area over all ASF-B*-trees equals the least area of a grid search on three small groups, and the number of disconnected packings.
Complexity
| operation | time | extra space |
|---|---|---|
| PACK with the contour | amortized | |
| PACK by a search over placed nodes (the implementation) | ||
| ROTATE | none | |
| SWAP | with parent links, plus to test the rightmost branch | none |
| DELETE, INSERT | to relink, plus the swaps down a path and the test of the rightmost branch | none |
With pairs and self-symmetric cells, the tree has nodes, half of the cells of the group. So the search space is that of B*-trees on nodes, cut further by the ASF rule. For one group with two pairs and one self-symmetric cell, 18 of the 30 labeled trees are ASF-B*-trees, and with two pairs and two self-symmetric cells, 80 of 336.
Variants
- Hierarchical B-tree.* Lin, Chang and Lin treat each symmetry island as one node of a top-level B*-tree that also holds the free cells, and annealing perturbs both levels.
- Horizontal axis. Exchange the roles of and : the representatives are the upper cells, and the self-symmetric halves are kept on the leftmost branch (the root and its chain of left children), whose nodes all have .
- Sequence pairs. Symmetric-feasible sequence pairs keep symmetry with a condition on the two orders and a packing that solves the symmetry equations. They allow free cells between the cells of a group, which a mirrored half-tree does not.
- Common centroid. Devices that must also cancel gradients in both directions use a common-centroid layout, which a mirror placement does not give.
When to use it
Use it in an annealing placer for analog circuits when each symmetric set should stay together in one region, which shortens the wires between matched devices and makes their surroundings alike. Use symmetric-feasible sequence pairs instead when other cells may sit between the cells of a group.
Pitfalls
- A self-symmetric half off the axis. If a move puts a self-symmetric half as a left child, its two halves come apart, as in the example above. Every move must keep the ASF rule, or the packing must reject the tree.
- Odd widths. The half of a self-symmetric cell of odd width has a half-unit width. Keep the coordinates in half units, or double all coordinates, until the group is placed.
- Rotating a pair. Rotate both cells of a pair together, and rotate a self-symmetric cell as a whole: its half is after the turn, not .
- Assuming a connected island. The plain packing can leave a cell of a pair in a corner, apart from the rest of the group, as shown above. Check connectivity if the placer counts on it.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/asf-b-star-tree/. The authors are listed in prov/TQF55M.jsonl.
"""An ASF-B*-tree for one symmetric set of cells with a vertical axis at x = 0.
The group is a dict cells: name -> (kind, w, h), with kind "pair" for a
symmetric pair (two cells of size w x h, mirrored about the axis) and "self"
for a self-symmetric cell of size w x h (centered on the axis). The tree holds
one representative per entry: the right cell of a pair, of size w x h, and the
right half of a self-symmetric cell, of size w/2 x h.
As on the B*-tree page, the left child c of b has x_c = x_b + w_b, and the right
child has x_c = x_b. The tree is an ASF-B*-tree when every self-symmetric
representative is on the rightmost branch: the root and its chain of right
children, which is where x = 0.
"""
from fractions import Fraction
class ASFBStarTree:
def __init__(self, cells: dict, root=None, left=None, right=None) -> None:
self.cells = {b: (k, Fraction(w), Fraction(h)) for b, (k, w, h) in cells.items()}
if root is None:
# self representatives on the right chain from the root, pairs as a chain of left children
selfs = [b for b in self.cells if self.cells[b][0] == "self"]
pairs = [b for b in self.cells if self.cells[b][0] == "pair"]
order = selfs + pairs
self.root = order[0] if order else None
self.left = {b: None for b in order}
self.right = {b: None for b in order}
for a, b in zip(selfs, selfs[1:]):
self.right[a] = b
prev = selfs[-1] if selfs else None
for b in pairs:
if prev is not None:
self.left[prev] = b
prev = b
else:
self.root, self.left, self.right = root, dict(left), dict(right)
def rep_size(self, b) -> tuple:
k, w, h = self.cells[b]
return (w / 2, h) if k == "self" else (w, h)
def rightmost_branch(self) -> list:
out, b = [], self.root
while b is not None:
out.append(b)
b = self.right[b]
return out
def is_asf(self) -> bool:
on = set(self.rightmost_branch())
return all(b in on for b in self.left if self.cells[b][0] == "self")
def preorder(self) -> list:
out, stack = [], [self.root] if self.root is not None else []
while stack:
b = stack.pop()
out.append(b)
for c in (self.right[b], self.left[b]):
if c is not None:
stack.append(c)
return out
def pack(self) -> dict:
"""Pack the representatives as a B*-tree, then mirror them about x = 0.
Returns the rectangles (x, y, w, h) of the whole group, keyed by
(name, "R") and (name, "L") for a pair and (name, "S") for a
self-symmetric cell, with the width and the height of the group."""
if not self.is_asf():
raise ValueError("a self-symmetric representative is off the rightmost branch")
pos = {}
parent_x = {self.root: (None, None)}
for b in self.preorder(): # @line L1
w, h = self.rep_size(b)
p, side = parent_x[b]
if p is None: # @line L2
x = Fraction(0)
elif side == "left":
x = pos[p][0] + self.rep_size(p)[0]
else:
x = pos[p][0]
# @line L3: the highest top among the placed representatives whose x-range meets [x, x + w)
y = max((pos[c][1] + self.rep_size(c)[1] for c in pos if pos[c][0] < x + w and x < pos[c][0] + self.rep_size(c)[0]), default=Fraction(0))
pos[b] = (x, y) # @line L4
if self.left[b] is not None:
parent_x[self.left[b]] = (b, "left")
if self.right[b] is not None:
parent_x[self.right[b]] = (b, "right")
rects = {}
for b, (x, y) in pos.items():
k, w, h = self.cells[b]
if k == "pair": # @line L5: the partner is the mirror image
rects[(b, "R")] = (x, y, w, h)
rects[(b, "L")] = (-x - w, y, w, h)
else: # @line L6: a self-symmetric cell is its half and the mirror of its half
assert x == 0
rects[(b, "S")] = (-w / 2, y, w, h)
half = max((x + self.rep_size(b)[0] for b, (x, _) in pos.items()), default=Fraction(0))
height = max((y + self.rep_size(b)[1] for b, (_, y) in pos.items()), default=Fraction(0))
return {"rects": rects, "width": 2 * half, "height": height} # @line L7
# The moves of the annealing. Each keeps the tree an ASF-B*-tree.
def rotate(self, b) -> None:
k, w, h = self.cells[b]
self.cells[b] = (k, h, w)
def swap(self, a, b) -> None:
"""Exchange two labels. A self-symmetric label may only go to a node on
the rightmost branch."""
on = set(self.rightmost_branch())
for u, v in ((a, b), (b, a)):
if self.cells[u][0] == "self" and v not in on:
raise ValueError("this swap would move a self-symmetric representative off the rightmost branch")
m = {a: b, b: a}
def rn(z):
return m.get(z, z)
self.root = rn(self.root)
self.left = {rn(u): rn(c) for u, c in self.left.items()}
self.right = {rn(u): rn(c) for u, c in self.right.items()}
def _parent(self, b):
for u in self.left:
if self.left[u] == b:
return u, "left"
if self.right[u] == b:
return u, "right"
return None, None
def delete(self, b) -> None:
"""Remove b. A node with two children is first swapped down along its
left children, so the rightmost branch keeps its self-symmetric labels."""
while self.left[b] is not None and self.right[b] is not None:
c = self.left[b]
m = {b: c, c: b}
def rn(z):
return m.get(z, z)
self.root = rn(self.root)
self.left = {rn(u): rn(v) for u, v in self.left.items()}
self.right = {rn(u): rn(v) for u, v in self.right.items()}
child = self.left[b] if self.left[b] is not None else self.right[b]
p, side = self._parent(b)
if p is None:
self.root = child
elif side == "left":
self.left[p] = child
else:
self.right[p] = child
del self.left[b], self.right[b]
def insert(self, b, p, side: str) -> None:
"""Insert b as the side child of p; the old child becomes the child of b
on the same side. With p None, b becomes the root and the old root its
right child. A self-symmetric b may only go on the rightmost branch."""
if self.cells[b][0] == "self" and not (p is None or (side == "right" and p in set(self.rightmost_branch()))):
raise ValueError("a self-symmetric representative must be inserted on the rightmost branch")
self.left[b], self.right[b] = None, None
if p is None:
self.right[b], self.root = self.root, b
elif side == "left":
self.left[b], self.left[p] = self.left[p], b
else:
self.right[b], self.right[p] = self.right[p], b
test_asf_b_star_tree.py 193 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/asf-b-star-tree/. The authors are listed in prov/TQF55M.jsonl.
import itertools
import random
from fractions import Fraction
import pytest
from asf_b_star_tree import ASFBStarTree
def shapes(n: int):
"""Every binary tree with n nodes, as (left, right) nested tuples or None."""
if n == 0:
yield None
return
for k in range(n):
for a in shapes(k):
for b in shapes(n - 1 - k):
yield (a, b)
def all_trees(cells: dict):
names = list(cells)
for shape in shapes(len(names)):
for perm in itertools.permutations(names):
it = iter(perm)
left, right = {}, {}
def label(s):
if s is None:
return None
b = next(it)
left[b] = label(s[0])
right[b] = label(s[1])
return b
root = label(shape)
yield ASFBStarTree(cells, root, left, right)
def check_symmetric(t: ASFBStarTree, p: dict) -> None:
rects = p["rects"]
for (b, side), (x, y, w, h) in rects.items():
assert x >= -p["width"] / 2 and x + w <= p["width"] / 2 and y >= 0 and y + h <= p["height"]
if side == "R":
xl, yl, wl, hl = rects[(b, "L")]
assert (yl, wl, hl) == (y, w, h) and xl + wl / 2 == -(x + w / 2)
assert x >= 0
if side == "S":
assert x + w / 2 == 0
items = list(rects.values())
for i in range(len(items)):
for j in range(i + 1, len(items)):
x1, y1, w1, h1 = items[i]
x2, y2, w2, h2 = items[j]
assert x1 + w1 <= x2 or x2 + w2 <= x1 or y1 + h1 <= y2 or y2 + h2 <= y1
def connected(rects: dict) -> bool:
"""True if the cells form one region, joining two cells that share a piece of boundary of positive length."""
items = list(rects.values())
def touch(a, b):
x1, y1, w1, h1 = a
x2, y2, w2, h2 = b
if x1 + w1 == x2 or x2 + w2 == x1:
return min(y1 + h1, y2 + h2) > max(y1, y2)
if y1 + h1 == y2 or y2 + h2 == y1:
return min(x1 + w1, x2 + w2) > max(x1, x2)
return False
seen, stack = {0}, [0]
while stack:
i = stack.pop()
for j in range(len(items)):
if j not in seen and touch(items[i], items[j]):
seen.add(j)
stack.append(j)
return len(seen) == len(items)
GROUPS = [
{"a": ("pair", 2, 1), "b": ("pair", 1, 2), "s": ("self", 2, 2)},
{"a": ("pair", 1, 1), "s": ("self", 2, 1), "t": ("self", 4, 1)},
{"a": ("pair", 2, 1), "b": ("pair", 1, 1), "c": ("pair", 1, 3)},
{"a": ("pair", 1, 2), "b": ("pair", 2, 1), "s": ("self", 2, 1), "t": ("self", 2, 2)},
]
def test_every_asf_tree_packs_symmetric() -> None:
for cells in GROUPS:
n_asf = 0
for t in all_trees(cells):
if not t.is_asf():
with pytest.raises(ValueError):
t.pack()
continue
n_asf += 1
check_symmetric(t, t.pack())
assert n_asf > 0
def test_self_symmetric_half_is_on_the_axis_only_on_the_rightmost_branch() -> None:
# In a plain B*-tree packing, x = 0 holds exactly for the rightmost branch.
cells = {"a": ("pair", 1, 1), "b": ("pair", 2, 1), "c": ("pair", 1, 2), "d": ("pair", 3, 1)}
for t in all_trees(cells):
p = t.pack()
on = set(t.rightmost_branch())
for b in cells:
assert (p["rects"][(b, "R")][0] == 0) == (b in on)
def brute_min_area(cells: dict, xmax: int, ymax: int, step: Fraction) -> Fraction:
"""The least area of a symmetric placement of the group, by trying every
position of the right halves on a grid: a pair's right cell at x >= 0, a
self-symmetric half at x = 0."""
names = list(cells)
xs = [k * step for k in range(int(xmax / step) + 1)]
ys = list(range(ymax + 1))
pairs_spots = list(itertools.product(xs, ys))
best = None
choices = [pairs_spots if cells[b][0] == "pair" else [(Fraction(0), y) for y in ys] for b in names]
for choice in itertools.product(*choices):
r = []
for b, (x, y) in zip(names, choice):
k, w, h = cells[b]
r.append((x, y, Fraction(w, 2) if k == "self" else Fraction(w), Fraction(h)))
if all(a[0] + a[2] <= c[0] or c[0] + c[2] <= a[0] or a[1] + a[3] <= c[1] or c[1] + c[3] <= a[1] for a, c in itertools.combinations(r, 2)):
area = 2 * max(a[0] + a[2] for a in r) * max(a[1] + a[3] for a in r)
best = area if best is None else min(best, area)
return best
def best_tree_area(cells: dict) -> Fraction:
best = None
for t in all_trees(cells):
if t.is_asf():
p = t.pack()
area = p["width"] * p["height"]
best = area if best is None else min(best, area)
return best
def test_least_area_over_trees_equals_grid_search() -> None:
g1 = {"a": ("pair", 2, 1), "b": ("pair", 1, 2), "s": ("self", 2, 2)}
assert best_tree_area(g1) == brute_min_area(g1, 4, 4, Fraction(1)) == 12
g2 = {"a": ("pair", 1, 1), "s": ("self", 1, 1), "t": ("self", 3, 2)}
assert best_tree_area(g2) == brute_min_area(g2, 3, 4, Fraction(1, 2))
g3 = {"a": ("pair", 2, 1), "b": ("pair", 1, 1), "c": ("pair", 1, 3)}
assert best_tree_area(g3) == brute_min_area(g3, 4, 4, Fraction(1))
def test_a_packing_need_not_be_connected() -> None:
cells = {"r": ("self", 2, 3), "b": ("pair", 2, 1), "c": ("pair", 1, 1)}
t = ASFBStarTree(cells, "r", {"r": None, "b": "c", "c": None}, {"r": "b", "b": None, "c": None})
p = t.pack()
check_symmetric(t, p)
assert p["rects"][("c", "R")] == (2, 0, 1, 1)
assert not connected(p["rects"])
def test_random_moves_keep_the_tree_asf() -> None:
rng = random.Random(2009)
cells = {"a": ("pair", 2, 1), "b": ("pair", 1, 2), "c": ("pair", 3, 1), "s": ("self", 2, 2), "t": ("self", 4, 1), "u": ("self", 1, 3)}
t = ASFBStarTree(cells)
assert t.is_asf()
for _ in range(2000):
op = rng.randrange(3)
names = list(t.cells)
if op == 0:
t.rotate(rng.choice(names))
elif op == 1:
a, b = rng.sample(names, 2)
try:
t.swap(a, b)
except ValueError:
assert t.cells[a][0] == "self" or t.cells[b][0] == "self"
else:
b = rng.choice(names)
t.delete(b)
assert t.is_asf()
rest = [u for u in t.left]
if t.cells[b][0] == "self":
spots = [(None, "right")] + [(u, "right") for u in t.rightmost_branch()]
else:
spots = [(None, "right")] + [(u, s) for u in rest for s in ("left", "right")]
p, side = rng.choice(spots)
t.insert(b, p, side)
assert t.is_asf()
assert sorted(t.preorder()) == sorted(cells)
check_symmetric(t, t.pack())
History
Chang, Chang, Wu and Wu gave the B*-tree in 2000. Balasa and Lampaert had given symmetric placement with sequence pairs in the same year. Lin and Lin gave the ASF-B*-tree at DAC 2007, to place each symmetric set as one island. Lin, Chang and Lin put the islands into a hierarchical B*-tree in IEEE Transactions on CAD in 2009.
References
- P.-H. Lin and S.-C. Lin, Analog placement based on novel symmetry-island formulation, DAC 2007, pages 465 to 470, the definition of the ASF-B*-tree (one representative per pair and per self-symmetric cell, the self-symmetric ones on the rightmost branch), its packing and mirroring, and the symmetry-island theorem
- Po-Hung Lin, Yao-Wen Chang and Shyh-Chang Lin, Analog placement based on symmetry-island formulation, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 28(6), 791 to 804, 2009, the journal version, with the hierarchical B*-tree that holds each symmetry island as one node, and the experiments
- Yun-Chih Chang, Yao-Wen Chang, Guang-Ming Wu and Shu-Wei Wu, B*-trees, a new representation for non-slicing floorplans, Proceedings of the 37th Design Automation Conference, 458 to 463, 2000, the B*-tree, its packing, and the theorem that every placement compact to the left and down is the packing of a B*-tree
- Florin Balasa and Koen Lampaert, Symmetry within the sequence-pair representation in the context of placement for analog design, IEEE Transactions on Computer-Aided Design 19(7), 721 to 731, 2000, symmetric placement with sequence pairs, the approach that the ASF-B*-tree is compared with
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag TQF55M Edit this page History Report an error Markdown