Algorithmadvanced
Voronoi critical area extraction
Also called Papadopoulou-Lee critical area, L-infinity Voronoi critical area.
Papadopoulou and Lee's method that computes critical area for all defect sizes at once from an L-infinity Voronoi diagram of the layout polygons.
- Time
- O(F k^2) averageO(n^5) buildO(F k) query
- Space
- O(F k) extra
- Where
- F = the number of faces built; k = the largest number of vertices of a face; n = the number of rectangles
- Model
- Word RAM
- Properties
- deterministicexactofflineiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Evanthia Papadopoulou, D. T. Lee, 1999
Voronoi critical area extraction computes the critical area for shorts of a layout layer at every defect size at once. Papadopoulou and Lee observed in 1999 that, for square defects, a point is a critical centre for radius exactly when its distance to the second nearest net is at most . That distance is a piecewise linear function over the second order Voronoi diagram of the layout, so one diagram gives for all , and the average critical area under the defect size density in closed form. This page builds the needed structure for axis-parallel rectangles by incremental insertion, proves that it is exact, and cites Papadopoulou and Lee for the plane sweep that handles general rectilinear polygons.
In plain words
A particle of dust that lands on a chip can join two wires that should stay apart. Whether it does depends on where its centre falls and how big it is. The critical area is the size of the set of landing spots that cause a short.
The direct way is to pick a size, grow every wire by that size, and measure where grown wires of different nets overlap, again for every size.
This method asks instead, for each point of the chip, how big a particle centred there must be to touch two different nets. That number is the distance to the second closest net. The method cuts the chip once into pieces where that distance is a simple slope. Then the critical area for any size is a sum of clipped piece areas, and the average over all sizes is a sum of exact integrals.
The problem
Input. Axis-parallel rectangles , , each with a net label , at least two nets, and a window that is an axis-parallel rectangle. Rectangles may overlap; rectangles of the same net count as connected. The defect of radius at is the square , and defect radii have Stapper's density with peak (on the critical area page), with survival function , which is for and for .
Distances. The distance from to is
because a point of a product of intervals can be chosen coordinate by coordinate. The distance to a net is , and the critical radius is the second smallest value among the , one value per net.
Output. The function , which is the critical area for shorts, as a structure that answers each exactly, and the average
where the second form follows by exchanging the two integrals (Tonelli's theorem, the integrand is nonnegative).
The algorithm
A face is a convex polygon with a state : is the nearest net on , and and are affine functions of , or , equal on to the distance to the nearest net and to the second nearest net. Splitting a face by an affine function means cutting its polygon by the line into the parts with and .
VORONOI-CRITICAL-AREA(rectangles, W, r0)- 1
faces ← {(W, none, +∞, +∞)} - 2
for each rectangle R of net M, in any order - 3
g_1, …, g_5 ← a − x, x − b, c − y, y − d, 0 ▷ δ_R = max of these - 4
for each face (P, ν, h1, h2) - 5
if some g_k ≥ (M = ν ? h1 : h2) at every vertex of P then keep the face; continue - 6
split P into parts Q on which one g_k is the maximum; let g be that piece on Q - 7
if ν = none: the state of Q is (M, g, +∞) - 8
else if M = ν: split Q by g − h1; where g ≤ h1 set h1 ← g - 9
else split Q by g − h1 and g − h2: - 10
where g ≤ h1: (ν, h1, h2) ← (M, g, h1) - 11
where h1 ≤ g ≤ h2: h2 ← g - 12
where g ≥ h2: no change - 13
A(r) = Σ over faces of area(P ∩ {h2 ≤ r}) ▷ one clip per face - 14
Ā = Σ over faces of ∫ area(P ∩ {h2 ≤ r}) f(r) dr ▷ quadratic pieces, closed form - 15
return faces, A, Ā
Line L6 splits by , then each part by minus the current maximum, and so on, which leaves at most 16 parts, usually one or two. Line L5 is a quick test: if one piece is already at least at all vertices, then on all of , because an affine function that is nonnegative at the vertices of a convex polygon is nonnegative on it.
Line L14 uses one fact about a convex polygon and an affine : between two consecutive values of at the vertices of , the area of is a quadratic in . So three exact areas fix each quadratic, and has a closed form: on the integrand is a polynomial, and on the terms are , and , whose integrals are rational functions and a logarithm. Above the largest vertex value the whole face counts, with weight at that value.
The implementation works in exact rational arithmetic. All lines it cuts by are differences of two affine pieces with coefficients in , so the vertices have small denominators.
Example
The layout is , and , three nets, in the window of area 24. The build leaves 42 faces, and the values of at their vertices are , , and .
Some critical radii: at , in the middle of the gap between and , the distances to , and are , and , so . At , inside , they are , and , so : a defect centred on a wire must reach the next net. At , inside , as well.
The structure gives for , and
These fit one formula. The pair regions are with : , with : , and with : , inside for . Each of the three pairwise overlaps and the triple overlap is the square of area , so inclusion and exclusion gives
and for . With only the tail of is used:
For this is and for it is , the values the program returns.
Correctness
The full proof shows the following.
Squares and distances. The square meets if and only if . So it meets net if and only if , and it shorts two nets if and only if . Hence is the critical area of the definition. This is the observation of Papadopoulou and Lee.
Invariant. After the first rectangles are inserted, the faces are convex, have disjoint interiors and cover , and on each face and , where the distances use only the inserted rectangles. A new rectangle of net changes only , to . The proof checks the three cases of lines L8 to L12, using that before the insertion when .
Exact output. After all insertions on every face, so line L13 is the exact area. Line L14 is exact up to the floating point evaluation of the closed forms, by the quadratic lemma: the area of grows at a rate equal to the length of the chord divided by , and that chord length is affine between consecutive vertex values.
What is not proved here. Papadopoulou and Lee build the second order diagram of general rectilinear polygons by a plane sweep and integrate over trapezoids. This page proves only the rectangle case with the incremental build. For their construction and its bounds, see their paper.
Proof: The incremental second order L-infinity structure gives the exact critical area for shorts of rectanglesfull
Setting. The layout is a finite list of closed axis-parallel rectangles with net labels , and is a closed axis-parallel rectangle. A defect of radius centred at is the closed square . For a net and a set of inserted rectangles, , with . The critical radius is the second smallest entry of the list over all nets, with one entry per net. The critical area for shorts is .
Lemma 1 (distance to a rectangle). for .
Proof. For , . The choices of and are independent and is nondecreasing in each argument, so the minimum is . The distance from to is , since at most one of and is positive. The same holds for , and the maximum of the two expressions is the formula.
Lemma 2 (shorts and the critical radius). meets if and only if . Hence meets rectangles of two different nets if and only if , and .
Proof. if and only if some has . Since is compact, the minimum is attained, so this holds if and only if . The square meets net if and only if , and it meets two different nets if and only if at least two entries of the list are at most , which is the case if and only if the second smallest entry is at most .
Lemma 3 (pieces). Let be affine and a convex polygon. Line L6 splits by , then each part by , and so on, where is the piece recorded on the part, starting with . The resulting parts are convex, have disjoint interiors, cover , and on each part the recorded piece equals .
Proof. Splitting a convex polygon by a line gives two closed convex polygons whose union is the polygon and whose interiors are disjoint; if the line misses the interior, one part is the whole polygon. By induction on , after the splits by the recorded piece on each part is on that part: on the part where the old stays and is ; on the part where the new piece is , which is . After the recorded piece is the maximum.
Lemma 4 (vertex test). If an affine satisfies at every vertex of a convex polygon , then on . So if one piece of has at every vertex of , then on .
Proof. Every point of is a convex combination of its vertices, and an affine function maps a convex combination to the same combination of values. The second claim applies this to and uses .
Invariant. Let be the first inserted rectangles. After their insertion:
- the faces are convex polygons with disjoint interiors whose union is ;
- on each face with state and for every point of the face, and ;
- and are affine on the face or ; when the state is .
Base. For the one face is and all distances are .
Step. Insert of net , and write and . The new distances are and for . Fix a face . Part 1 holds after the step because every operation splits a convex polygon into convex parts that cover it, by Lemma 3 and the remark in its proof. For part 2 and part 3, consider the cases.
Quick test, . By Lemma 4, on , so and nothing changes. Quick test, . By Lemma 4, on . Then , because by part 2. So , and the nearest net is still with . Nothing changes.
Otherwise the face is split by Lemma 3 into parts on which is one affine piece. On a part :
- $\nu = $ none. This happens only for the first rectangle, since after it every point has a finite distance to its net. All , so is the only finite distance: the state is correct.
- . , and every other net has , so is still nearest and is unchanged. Splitting by gives the part , where , and the part , where nothing changes. Both are affine.
- . Before the step , by part 2.
- Where : for every . So is nearest with , and the second smallest is , since all the other entries are . The state is correct.
- Where (or ): because . Since , stays nearest. The other entries satisfy , so . The state is correct.
- Where : , and for the other , with equality for the net that attained (if that net is , then there and ). So and nothing changes.
Each case sets and to affine functions on its part, so part 3 holds. This completes the step.
Theorem 1 (exact critical area). After all rectangles are inserted, every face satisfies on its polygon, and line L13 returns exactly.
Proof. By the invariant, on each face and the nearest net is , so the second smallest entry of the list is , which is . Since there are at least two nets, is finite everywhere. The faces cover and their boundaries have zero area, so . By Lemma 2 the left side is . Each term is the area of the convex polygon , computed exactly by one split and the shoelace formula in rational arithmetic.
Lemma 5 (quadratic pieces). Let be a convex polygon and affine, not constant, with vertex values (distinct values only). Then is for , equal to for , and a polynomial of degree at most 2 on each . If is constant on with value , then for and for .
Proof. Rotate coordinates so that with the first coordinate. Then , where is the length of the chord . For strictly between and , no vertex lies on the line , so the line crosses the same two edges of for all such . The crossing points depend affinely on along those fixed edges, so their distance is affine in there. Its integral is quadratic on , and is continuous. Below the chord is empty, above all of is included. The constant case is direct.
Theorem 2 (average). Let be a density of the defect radius with survival function . Then , and line L14 computes each term exactly up to rounding in the closed forms.
Proof. The first equality is Theorem 1 summed under the integral; all terms are nonnegative. By Lemma 5, on the function is the unique polynomial of degree at most 2 through its values at , and , which the implementation computes exactly and interpolates. Above , contributes . For Stapper's density, and for are , , and , which are the closed forms used, with each interval split at .
Remark (general polygons). For rectilinear polygons that are not unions of a few rectangles, a polygon can be cut into rectangles of the same net, and the theorems apply unchanged, since only net distances enter. Papadopoulou and Lee (IEEE TCAD 18(4), 1999) compute the same function from the second order Voronoi diagram of the polygons, built by a plane sweep, and integrate over trapezoids. Their construction and its running time are not proved here.
Complexity
Every line the build cuts by is the zero set of a difference of two functions from the set of the affine pieces of the distance functions, so there are such lines. The faces are unions of cells of their arrangement inside , so , and an insertion touches each face once, at a cost proportional to its size. The sum of the face sizes is at most the number of edges of the arrangement, , so the build takes operations on rationals of bounded size in the worst case. This bound is crude. On random layouts with and rectangles the implementation leaves , , and faces, about ; most of them are fragments of larger regions of the diagram, which could be merged when their states are equal.
Once built, at one radius costs one clip per face, . The average costs clips per face, . The method answers all radii from one build, where direct shape expansion pays a full union of rectangles for every radius.
Properties
- Exact. is a rational number computed without error for rational inputs. Only the logarithms of the average are floating point.
- All sizes at once. The structure does not depend on or on ; a new size distribution needs only line L14.
- Square defects. The result is the critical area for square defects. A disk of radius lies inside the square of radius and contains the square of radius , so the disk critical area lies between and .
- Union, not sum. A centre that shorts three nets is counted once, as the definition requires; summing pair areas would count it three times.
- Shorts only. Opens need a different distance, the size a defect needs to cut a net, which Papadopoulou treated in later work.
Variants and improvements
- Plane sweep. Papadopoulou and Lee compute the second order diagram by a sweep line and split its regions into trapezoids where the distance is linear, then integrate per trapezoid.
- Segments of any orientation. Their 2001 paper on the Voronoi diagram of segments extends the method to non-rectilinear layouts.
- Higher order diagrams. Papadopoulou's later work uses higher order and Hausdorff Voronoi diagrams for defects that must touch several shapes, such as via blocks and opens.
- Monte Carlo. Dropping random defects and counting faults estimates with error that shrinks as the inverse square root of the sample size; it handles any defect shape and any fault rule but gives no exact . See Monte Carlo integration.
- Shape expansion. Growing all shapes by and intersecting nets, as in the union test of the implementation, gives for one at a time. Its cost grows with the number of radii sampled.
When to use it
Use it when the critical area for shorts is needed for many defect sizes or for several size distributions, on rectilinear layouts, and the square defect model is acceptable. Use Monte Carlo when the defect shape or the fault rule is unusual, and shape expansion when only one or two radii matter.
Pitfalls
- Disks versus squares. The square model overestimates the disk critical area, by at most the factor between and . Calibrate the defect density with the same model.
- Nets, not shapes. The second nearest net matters, not the second nearest rectangle. Two touching rectangles of one net would give everywhere near them if treated as different sites.
- Window edges. Shapes just outside still count as near nets. Include them, or the area near the border is too small.
- Divergent averages. With Stapper's tail, a formula for one pair extended to all diverges; the window cap keeps the average finite. The structure applies that cap by itself.
- Fragmented faces. Without merging, the incremental build leaves many more faces than the diagram has regions. That costs time, not accuracy.
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/voronoi-critical-area-extraction/. The authors are listed in prov/VXSKTK.jsonl.
"""Critical area for shorts of axis-parallel rectangles under square (L-infinity) defects.
The layout is a list of rectangles (x1, y1, x2, y2, net) with x1 < x2 and y1 < y2,
and the window is (X1, Y1, X2, Y2). Coordinates are ints or Fractions; all geometry
is exact. A defect of radius r centred at p is the square p + [-r, r]^2.
build_faces computes the second order L-infinity Voronoi structure of the nets inside
the window by incremental insertion of rectangles. It returns convex faces, and on each
face the distance h1 to the nearest net and the distance h2 to the second nearest net
are affine functions. h2 is the critical radius, so the critical area for shorts is
A(r) = sum over faces of the area where h2 <= r.
An affine function is a tuple (a, b, c) meaning a*x + b*y + c. None stands for +infinity.
"""
import math
from fractions import Fraction
def evaluate(f, p):
return f[0] * p[0] + f[1] * p[1] + f[2]
def minus(f, g):
return (f[0] - g[0], f[1] - g[1], f[2] - g[2])
def split(poly, f):
"""Split a convex polygon by the line f = 0.
Returns (part with f <= 0, part with f >= 0). A part with zero area is None.
"""
vals = [evaluate(f, p) for p in poly]
if all(v <= 0 for v in vals):
return poly, None
if all(v >= 0 for v in vals):
return None, poly
neg, pos = [], []
n = len(poly)
for i in range(n):
p, q = poly[i], poly[(i + 1) % n]
vp, vq = vals[i], vals[(i + 1) % n]
if vp <= 0:
neg.append(p)
if vp >= 0:
pos.append(p)
if (vp < 0 < vq) or (vq < 0 < vp):
t = vp / (vp - vq)
x = (p[0] + t * (q[0] - p[0]), p[1] + t * (q[1] - p[1]))
neg.append(x)
pos.append(x)
return neg, pos
def area(poly):
s = 0
n = len(poly)
for i in range(n):
x1, y1 = poly[i]
x2, y2 = poly[(i + 1) % n]
s += x1 * y2 - x2 * y1
return abs(Fraction(s)) / 2
def distance_pieces(rect):
"""The five affine pieces whose maximum is the L-infinity distance to the rectangle."""
a, c, b, d = (Fraction(v) for v in rect[:4])
return [(-1, 0, a), (1, 0, -b), (0, -1, c), (0, 1, -d), (0, 0, 0)]
def surely_at_least(pieces, h, poly):
"""True if max(pieces) >= h on all of poly, shown by one piece >= h at every vertex."""
for g in pieces:
if all(evaluate(minus(g, h), p) >= 0 for p in poly):
return True
return False
def by_piece(poly, pieces):
"""Split poly into convex parts, each with the piece that is the maximum on it."""
parts = [(poly, pieces[0])]
for g in pieces[1:]:
nxt = []
for q, m in parts:
low, high = split(q, minus(g, m))
if low is not None:
nxt.append((low, m))
if high is not None:
nxt.append((high, g))
parts = nxt
return parts
def insert(faces, rect):
net = rect[4]
pieces = distance_pieces(rect) # @line L3
out = []
for poly, nu, h1, h2 in faces: # @line L4
if nu == net and surely_at_least(pieces, h1, poly): # @line L5
out.append((poly, nu, h1, h2))
continue
if nu != net and h2 is not None and surely_at_least(pieces, h2, poly):
out.append((poly, nu, h1, h2))
continue
for q, g in by_piece(poly, pieces): # @line L6
if nu is None:
out.append((q, net, g, None)) # @line L7
elif nu == net:
low, high = split(q, minus(g, h1)) # @line L8
if low is not None:
out.append((low, nu, g, h2))
if high is not None:
out.append((high, nu, h1, h2))
else:
low, high = split(q, minus(g, h1)) # @line L9
if low is not None:
out.append((low, net, g, h1)) # @line L10
if high is not None:
if h2 is None:
out.append((high, nu, h1, g))
else:
mid, top = split(high, minus(g, h2))
if mid is not None:
out.append((mid, nu, h1, g)) # @line L11
if top is not None:
out.append((top, nu, h1, h2)) # @line L12
return out
def build_faces(rects, window):
X1, Y1, X2, Y2 = (Fraction(v) for v in window)
faces = [([(X1, Y1), (X2, Y1), (X2, Y2), (X1, Y2)], None, None, None)] # @line L1
for rect in rects: # @line L2
faces = insert(faces, rect)
return faces
def critical_area(faces, r):
"""Exact critical area for shorts at defect radius r."""
r = Fraction(r)
total = Fraction(0)
for poly, _, _, h2 in faces:
if h2 is None:
continue
low, _ = split(poly, (h2[0], h2[1], h2[2] - r)) # @line L13
if low is not None:
total += area(low)
return total
def survival(t, r0):
"""P(R >= t) for Stapper's radius density r/r0^2 below r0 and r0^2/r^3 above."""
if t <= r0:
return 1.0 - t * t / (2.0 * r0 * r0)
return r0 * r0 / (2.0 * t * t)
def moment(k, lo, hi, r0):
"""Integral of r^k f(r) over [lo, hi] for Stapper's density, with 0 <= lo <= hi."""
total = 0.0
a, b = lo, min(hi, r0)
if a < b:
total += (b ** (k + 2) - a ** (k + 2)) / ((k + 2) * r0 * r0)
a, b = max(lo, r0), hi
if a < b:
if k == 0:
total += r0 * r0 * (1.0 / (2 * a * a) - 1.0 / (2 * b * b))
elif k == 1:
total += r0 * r0 * (1.0 / a - 1.0 / b)
else:
total += r0 * r0 * math.log(b / a)
return total
def average_critical_area(faces, r0):
"""The integral of A(r) f(r) dr under Stapper's density with peak r0.
On one face the area where h2 <= r is quadratic in r between consecutive vertex
values of h2, so each piece is found exactly from three values and integrated
in closed form.
"""
r0 = float(r0)
total = 0.0
for poly, _, _, h2 in faces:
if h2 is None:
continue
vals = sorted(set(evaluate(h2, p) for p in poly))
whole = area(poly)
for lo, hi in zip(vals, vals[1:]):
mid = (lo + hi) / 2
ys = []
for r in (lo, mid, hi):
low, _ = split(poly, (h2[0], h2[1], h2[2] - r))
ys.append(area(low) if low is not None else Fraction(0))
# Quadratic through (lo, y0), (mid, y1), (hi, y2), as c0 + c1 r + c2 r^2.
h = (hi - lo) / 2
c2 = (ys[0] - 2 * ys[1] + ys[2]) / (2 * h * h)
c1 = (ys[2] - ys[0]) / (2 * h) - 2 * c2 * mid
c0 = ys[1] - c1 * mid - c2 * mid * mid
flo, fhi = float(lo), float(hi)
total += float(c0) * moment(0, flo, fhi, r0) + float(c1) * moment(1, flo, fhi, r0) + float(c2) * moment(2, flo, fhi, r0) # @line L14
total += float(whole) * survival(float(vals[-1]), r0)
return total
def voronoi_critical_area(rects, window, r0):
"""Build the faces once; return them, the function r -> A(r) and the average."""
faces = build_faces(rects, window)
return faces, (lambda r: critical_area(faces, r)), average_critical_area(faces, r0) # @line L15
def linf_distance(p, rect):
x, y = p
return max(rect[0] - x, x - rect[2], rect[1] - y, y - rect[3], 0)
def critical_radius(p, rects):
"""Distance from p to the second nearest net, computed directly."""
best = {}
for rect in rects:
d = linf_distance(p, rect)
if rect[4] not in best or d < best[rect[4]]:
best[rect[4]] = d
ds = sorted(best.values())
return ds[1] if len(ds) > 1 else None
def face_of(faces, p):
"""A face whose closed polygon contains p."""
for face in faces:
poly = face[0]
n = len(poly)
sign = 0
inside = True
for i in range(n):
(x1, y1), (x2, y2) = poly[i], poly[(i + 1) % n]
cr = (x2 - x1) * (p[1] - y1) - (y2 - y1) * (p[0] - x1)
if cr != 0:
s = 1 if cr > 0 else -1
if sign == 0:
sign = s
elif s != sign:
inside = False
break
if inside:
return face
return None
test_voronoi_critical_area_extraction.py 191 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/voronoi-critical-area-extraction/. The authors are listed in prov/VXSKTK.jsonl.
import math
import random
from fractions import Fraction
from voronoi_critical_area_extraction import (
area,
average_critical_area,
build_faces,
critical_area,
critical_radius,
evaluate,
face_of,
split,
survival,
voronoi_critical_area,
)
def union_area(rects):
"""Exact area of a union of closed rectangles (x1, y1, x2, y2), by coordinate compression."""
xs = sorted(set(v for r in rects for v in (r[0], r[2])))
total = Fraction(0)
for xa, xb in zip(xs, xs[1:]):
spans = sorted((r[1], r[3]) for r in rects if r[0] <= xa and r[2] >= xb)
length = Fraction(0)
cur_lo = cur_hi = None
for lo, hi in spans:
if cur_hi is None or lo > cur_hi:
if cur_hi is not None:
length += cur_hi - cur_lo
cur_lo, cur_hi = lo, hi
else:
cur_hi = max(cur_hi, hi)
if cur_hi is not None:
length += cur_hi - cur_lo
total += (xb - xa) * length
return total
def union_critical_area(rects, window, r):
"""A(r) from the definition: the union over pairs of different nets of the
intersections of the rectangles expanded by r, clipped to the window."""
r = Fraction(r)
X1, Y1, X2, Y2 = window
grown = [(a - r, b - r, c + r, d + r, n) for a, b, c, d, n in rects]
boxes = []
for i in range(len(grown)):
for j in range(i + 1, len(grown)):
p, q = grown[i], grown[j]
if p[4] == q[4]:
continue
box = (max(p[0], q[0], X1), max(p[1], q[1], Y1), min(p[2], q[2], X2), min(p[3], q[3], Y2))
if box[0] < box[2] and box[1] < box[3]:
boxes.append(box)
return union_area(boxes)
def random_layout(rng, n, nets, size):
rects = []
for i in range(n):
x1 = rng.randint(0, size - 2)
y1 = rng.randint(0, size - 2)
rects.append((x1, y1, x1 + rng.randint(1, 4), y1 + rng.randint(1, 4), "n%d" % (i % nets)))
return rects
WIRES = [(0, -1, 20, 0, "A"), (0, 1, 20, 2, "B")]
WIRE_WINDOW = (-10, -10, 30, 12)
def test_two_wires_closed_form():
faces = build_faces(WIRES, WIRE_WINDOW)
L, s = 20, 1
for r in [Fraction(1, 4), Fraction(1, 2), Fraction(3, 4), Fraction(1), Fraction(3), Fraction(15, 2)]:
expected = (L + 2 * r) * max(2 * r - s, 0)
assert critical_area(faces, r) == expected
def test_matches_union_of_expanded_rectangles():
rng = random.Random(1)
for trial in range(6):
rects = random_layout(rng, 7, 3, 14)
window = (0, 0, 14, 14)
faces = build_faces(rects, window)
radii = [Fraction(k, 4) for k in range(0, 33, 3)] + [Fraction(rng.randint(1, 600), 97) for _ in range(4)]
for r in radii:
assert critical_area(faces, r) == union_critical_area(rects, window, r), (trial, r)
def test_faces_partition_window_and_h2_is_critical_radius():
rng = random.Random(2)
rects = random_layout(rng, 8, 3, 12)
window = (0, 0, 12, 12)
faces = build_faces(rects, window)
assert sum(area(f[0]) for f in faces) == 144
for _ in range(300):
p = (Fraction(rng.randint(0, 1200), 100), Fraction(rng.randint(0, 1200), 100))
poly, nu, h1, h2 = face_of(faces, p)
assert evaluate(h2, p) == critical_radius(p, rects)
def test_grid_of_defect_centres():
# Count the cells of a grid whose centre is critical; the error is at most the
# area of the grid cells that meet the boundary of the critical region.
rng = random.Random(3)
rects = random_layout(rng, 6, 2, 10)
window = (0, 0, 10, 10)
faces = build_faces(rects, window)
m = 160
h = Fraction(10, m)
radii = {(i, j): critical_radius(((i + 0.5) * float(h), (j + 0.5) * float(h)), rects) for i in range(m) for j in range(m)}
for r in [Fraction(1, 2), Fraction(5, 4), Fraction(2)]:
hits = sum(1 for t in radii.values() if t <= r)
grid = float(hits * h * h)
exact = float(critical_area(faces, r))
perimeter, edges = 0.0, 0
for poly, _, _, h2 in faces:
low, _ = split(poly, (h2[0], h2[1], h2[2] - r))
if low is not None:
edges += len(low)
perimeter += sum(math.dist(low[k], low[(k + 1) % len(low)]) for k in range(len(low)))
bound = float(h) * (math.sqrt(2) * perimeter + 2 * float(h) * edges)
assert abs(grid - exact) <= bound
assert abs(grid - exact) <= 0.05 * max(exact, 1.0)
def test_average_critical_area_against_grid_of_centres():
# The average is the integral over the window of P(R >= t(p)). The function t is
# 1-Lipschitz in the L-infinity norm and the survival function is (1/r0)-Lipschitz,
# so the midpoint rule on cells of side h errs by at most |W| h / (2 r0).
rng = random.Random(4)
rects = random_layout(rng, 6, 3, 10)
window = (0, 0, 10, 10)
faces = build_faces(rects, window)
r0 = 0.5
exact = average_critical_area(faces, r0)
m = 160
h = 10.0 / m
fr = [(float(a), float(b), float(c), float(d), n) for a, b, c, d, n in rects]
total = 0.0
for i in range(m):
for j in range(m):
total += survival(critical_radius(((i + 0.5) * h, (j + 0.5) * h), fr), r0)
grid = total * h * h
assert abs(grid - exact) <= 100 * h / (2 * r0) + 1e-9
assert abs(grid - exact) <= 0.01 * exact
def test_average_matches_direct_integral_of_a():
# Integrate A(r) f(r) numerically with the exact A of the union method.
rects = [(0, 0, 6, 1, "A"), (0, 2, 6, 3, "B"), (7, 0, 8, 3, "C")]
window = (0, 0, 8, 3)
faces = build_faces(rects, window)
r0 = 0.25
exact = average_critical_area(faces, r0)
tmax = max(evaluate(f[3], p) for f in faces for p in f[0])
n = 4000
total = 0.0
for k in range(n):
r = (k + 0.5) * float(tmax) / n
fr = r / r0 ** 2 if r <= r0 else r0 ** 2 / r ** 3
total += float(union_critical_area(rects, window, Fraction(r))) * fr * float(tmax) / n
total += 24 * survival(float(tmax), r0)
assert abs(total - exact) <= 1e-3 * exact
def test_page_example():
rects = [(0, 0, 6, 1, "A"), (0, 2, 6, 3, "B"), (7, 0, 8, 3, "C")]
faces, crit, avg = voronoi_critical_area(rects, (0, 0, 8, 3), 0.25)
for k in range(0, 41):
r = Fraction(k, 10)
expected = 0 if r <= Fraction(1, 2) else (24 if r >= 2 else (2 * r - 1) * (10 - r))
assert crit(r) == expected
closed = 0.25 ** 2 * (12.75 - 4 * math.log(2) + 3)
assert abs(avg - closed) <= 1e-12
def test_limits():
rng = random.Random(5)
rects = random_layout(rng, 6, 2, 10)
window = (0, 0, 10, 10)
faces = build_faces(rects, window)
prev = Fraction(-1)
for k in range(0, 41):
a = critical_area(faces, Fraction(k, 4))
assert a >= prev
prev = a
assert critical_area(faces, 100) == 100
History
Stapper defined the critical area and its average in 1983 at IBM. Before Voronoi methods, it was computed by shape expansion at sampled sizes or by Monte Carlo defect simulation. Papadopoulou and Lee published the Voronoi formulation for shorts in 1999, with the second order diagram and closed form integration, and extended the diagram to segments of any orientation in 2001. Papadopoulou continued the line with methods for opens and via blocks based on higher order and Hausdorff Voronoi diagrams.
References
- Evanthia Papadopoulou and D. T. Lee, Critical area computation via Voronoi diagrams, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 18(4), 463 to 474, April 1999, the square defect model, the critical radius as the L-infinity distance to the second nearest polygon, the second order L-infinity Voronoi diagram of rectilinear polygons, its construction by plane sweep, and the integration of the critical area over its regions
- Evanthia Papadopoulou and D. T. Lee, The L-infinity Voronoi diagram of segments and VLSI applications, International Journal of Computational Geometry and Applications 11(5), 503 to 528, 2001, the L-infinity Voronoi diagram of segments of any orientation, which extends the method beyond rectilinear layouts
- C. H. Stapper, Modeling of integrated circuit defect sensitivities, IBM Journal of Research and Development 27(6), 549 to 557, November 1983, the critical area as a function of defect size and its average over the defect size distribution, the quantity that the method computes
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 | W2 basic |
|
Tag VXSKTK Edit this page History Report an error Markdown