Algorithm Search⌘K

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
Properties
deterministicexactofflineiterative
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 rr exactly when its L∞L_\infty distance to the second nearest net is at most rr. That distance is a piecewise linear function over the second order L∞L_\infty Voronoi diagram of the layout, so one diagram gives A(r)A(r) for all rr, 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 Ri=[ai,bi]×[ci,di]R_i = [a_i, b_i] \times [c_i, d_i], i=1,…,ni = 1, \dots, n, each with a net label νi\nu_i, at least two nets, and a window WW that is an axis-parallel rectangle. Rectangles may overlap; rectangles of the same net count as connected. The defect of radius rr at pp is the square p+r[−1,1]2p + r[-1, 1]^2, and defect radii have Stapper's density ff with peak r0r_0 (on the critical area page), with survival function S(t)=P(radius≥t)S(t) = P(\text{radius} \ge t), which is 1−t2/(2r02)1 - t^2/(2r_0^2) for t≤r0t \le r_0 and r02/(2t2)r_0^2/(2t^2) for t>r0t > r_0.

Distances. The L∞L_\infty distance from p=(x,y)p = (x, y) to RiR_i is

δi(p)=max⁡(ai−x, x−bi, ci−y, y−di, 0),\delta_i(p) = \max(a_i - x,\ x - b_i,\ c_i - y,\ y - d_i,\ 0),

because a point of a product of intervals can be chosen coordinate by coordinate. The distance to a net is dN(p)=min⁡νi=Nδi(p)d_N(p) = \min_{\nu_i = N} \delta_i(p), and the critical radius t(p)t(p) is the second smallest value among the dN(p)d_N(p), one value per net.

Output. The function A(r)=area⁡{p∈W:t(p)≤r}A(r) = \operatorname{area}\{p \in W : t(p) \le r\}, which is the critical area for shorts, as a structure that answers each rr exactly, and the average

Aˉ=∫0∞A(r)f(r) dr=∫WS(t(p)) dp,\bar A = \int_0^\infty A(r) f(r)\, dr = \int_W S\big(t(p)\big)\, dp,

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 P⊆WP \subseteq W with a state (ν,h1,h2)(\nu, h_1, h_2): ν\nu is the nearest net on PP, and h1h_1 and h2h_2 are affine functions of pp, or +∞+\infty, equal on PP to the distance to the nearest net and to the second nearest net. Splitting a face by an affine function uu means cutting its polygon by the line u=0u = 0 into the parts with u≤0u \le 0 and u≥0u \ge 0.

  1. VORONOI-CRITICAL-AREA(rectangles, W, r0)
  2. 1faces ← {(W, none, +∞, +∞)}
  3. 2for each rectangle R of net M, in any order
  4. 3g_1, …, g_5 ← a − x, x − b, c − y, y − d, 0 ▷ δ_R = max of these
  5. 4for each face (P, ν, h1, h2)
  6. 5if some g_k ≥ (M = ν ? h1 : h2) at every vertex of P then keep the face; continue
  7. 6split P into parts Q on which one g_k is the maximum; let g be that piece on Q
  8. 7if ν = none: the state of Q is (M, g, +∞)
  9. 8else if M = ν: split Q by g − h1; where g ≤ h1 set h1 ← g
  10. 9else split Q by g − h1 and g − h2:
  11. 10where g ≤ h1: (ν, h1, h2) ← (M, g, h1)
  12. 11where h1 ≤ g ≤ h2: h2 ← g
  13. 12where g ≥ h2: no change
  14. 13A(r) = Σ over faces of area(P ∩ {h2 ≤ r}) ▷ one clip per face
  15. 14Ā = Σ over faces of ∫ area(P ∩ {h2 ≤ r}) f(r) dr ▷ quadratic pieces, closed form
  16. 15return faces, A, Ā

Line L6 splits PP by g2−g1g_2 - g_1, then each part by g3g_3 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 hh at all vertices, then δR≥h\delta_R \ge h on all of PP, 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 PP and an affine hh: between two consecutive values of hh at the vertices of PP, the area of P∩{h≤r}P \cap \{h \le r\} is a quadratic in rr. So three exact areas fix each quadratic, and ∫(c0+c1r+c2r2)f(r) dr\int (c_0 + c_1 r + c_2 r^2) f(r)\, dr has a closed form: on r≤r0r \le r_0 the integrand is a polynomial, and on r>r0r > r_0 the terms are c0r02r−3c_0 r_0^2 r^{-3}, c1r02r−2c_1 r_0^2 r^{-2} and c2r02r−1c_2 r_0^2 r^{-1}, whose integrals are rational functions and a logarithm. Above the largest vertex value the whole face counts, with weight S(⋅)S(\cdot) at that value.

The implementation works in exact rational arithmetic. All lines it cuts by are differences of two affine pieces with coefficients in {−1,0,1}\{-1, 0, 1\}, so the vertices have small denominators.

Example

The layout is A=[0,6]×[0,1]A = [0, 6] \times [0, 1], B=[0,6]×[2,3]B = [0, 6] \times [2, 3] and C=[7,8]×[0,3]C = [7, 8] \times [0, 3], three nets, in the window W=[0,8]×[0,3]W = [0, 8] \times [0, 3] of area 24. The build leaves 42 faces, and the values of h2h_2 at their vertices are 12\frac{1}{2}, 11, 32\frac{3}{2} and 22.

Some critical radii: at (3,1.5)(3, 1.5), in the middle of the gap between AA and BB, the distances to AA, BB and CC are 0.50.5, 0.50.5 and 44, so t=0.5t = 0.5. At (3,0.5)(3, 0.5), inside AA, they are 00, 1.51.5 and 44, so t=1.5t = 1.5: a defect centred on a wire must reach the next net. At (7.5,1.5)(7.5, 1.5), inside CC, t=1.5t = 1.5 as well.

The structure gives A(r)=0A(r) = 0 for r≤12r \le \frac{1}{2}, and

rr 34\frac{3}{4} 11 32\frac{3}{2} 22 33
A(r)A(r) 378\frac{37}{8} 99 1717 2424 2424

These fit one formula. The pair regions are AA with BB: [0,6+r]×[2−r,1+r][0, 6 + r] \times [2 - r, 1 + r], AA with CC: [7−r,6+r]×[0,1+r][7 - r, 6 + r] \times [0, 1 + r], and BB with CC: [7−r,6+r]×[2−r,3][7 - r, 6 + r] \times [2 - r, 3], inside WW for 12≤r≤2\frac{1}{2} \le r \le 2. Each of the three pairwise overlaps and the triple overlap is the square [7−r,6+r]×[2−r,1+r][7 - r, 6 + r] \times [2 - r, 1 + r] of area (2r−1)2(2r - 1)^2, so inclusion and exclusion gives

A(r)=(6+r)(2r−1)+2(1+r)(2r−1)−3(2r−1)2+(2r−1)2=(2r−1)(10−r),12≤r≤2,A(r) = (6 + r)(2r - 1) + 2(1 + r)(2r - 1) - 3(2r - 1)^2 + (2r - 1)^2 = (2r - 1)(10 - r), \qquad \tfrac{1}{2} \le r \le 2,

and A(r)=24A(r) = 24 for r≥2r \ge 2. With r0≤12r_0 \le \frac{1}{2} only the tail of ff is used:

Aˉ=r02∫1/22−2r2+21r−10r3 dr+24⋅r022⋅22=r02(12.75−4ln⁡2+3)≈12.9774 r02.\bar A = r_0^2 \int_{1/2}^{2} \frac{-2r^2 + 21r - 10}{r^3}\, dr + 24 \cdot \frac{r_0^2}{2 \cdot 2^2} = r_0^2 \big( 12.75 - 4 \ln 2 + 3 \big) \approx 12.9774\, r_0^2.

For r0=0.25r_0 = 0.25 this is 0.811090.81109 and for r0=0.5r_0 = 0.5 it is 3.244353.24435, the values the program returns.

Correctness

The full proof shows the following.

Squares and distances. The square p+r[−1,1]2p + r[-1,1]^2 meets RiR_i if and only if δi(p)≤r\delta_i(p) \le r. So it meets net NN if and only if dN(p)≤rd_N(p) \le r, and it shorts two nets if and only if t(p)≤rt(p) \le r. Hence A(r)=area⁡{p∈W:t(p)≤r}A(r) = \operatorname{area}\{p \in W : t(p) \le r\} is the critical area of the definition. This is the observation of Papadopoulou and Lee.

Invariant. After the first kk rectangles are inserted, the faces are convex, have disjoint interiors and cover WW, and on each face h1=dν=min⁡NdNh_1 = d_\nu = \min_N d_N and h2=min⁡N≠νdNh_2 = \min_{N \ne \nu} d_N, where the distances use only the inserted rectangles. A new rectangle of net MM changes only dMd_M, to min⁡(dM,g)\min(d_M, g). The proof checks the three cases of lines L8 to L12, using that dM≥h2d_M \ge h_2 before the insertion when M≠νM \ne \nu.

Exact output. After all insertions h2=th_2 = t 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 P∩{h≤r}P \cap \{h \le r\} grows at a rate equal to the length of the chord P∩{h=r}P \cap \{h = r\} divided by ∣∇h∣|\nabla h|, and that chord length is affine between consecutive vertex values.

What is not proved here. Papadopoulou and Lee build the second order L∞L_\infty 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 Ri=[ai,bi]×[ci,di]R_i = [a_i, b_i] \times [c_i, d_i] with net labels νi\nu_i, and WW is a closed axis-parallel rectangle. A defect of radius r≥0r \ge 0 centred at pp is the closed square Q(p,r)=p+r[−1,1]2={q:∥q−p∥∞≤r}Q(p, r) = p + r[-1, 1]^2 = \{q : \|q - p\|_\infty \le r\}. For a net NN and a set II of inserted rectangles, dNI(p)=min⁡{δi(p):i∈I,νi=N}d^I_N(p) = \min\{\delta_i(p) : i \in I, \nu_i = N\}, with min⁡∅=+∞\min \emptyset = +\infty. The critical radius t(p)t(p) is the second smallest entry of the list (dN(p))N(d_N(p))_N over all nets, with one entry per net. The critical area for shorts is A(r)=area⁡{p∈W:Q(p,r) meets rectangles of two different nets}A(r) = \operatorname{area}\{p \in W : Q(p, r) \text{ meets rectangles of two different nets}\}.

Lemma 1 (distance to a rectangle). δi(p):=min⁡q∈Ri∥q−p∥∞=max⁡(ai−x,x−bi,ci−y,y−di,0)\delta_i(p) := \min_{q \in R_i} \|q - p\|_\infty = \max(a_i - x, x - b_i, c_i - y, y - d_i, 0) for p=(x,y)p = (x, y).

Proof. For q=(u,v)∈Riq = (u, v) \in R_i, ∥q−p∥∞=max⁡(∣u−x∣,∣v−y∣)\|q - p\|_\infty = \max(|u - x|, |v - y|). The choices of u∈[ai,bi]u \in [a_i, b_i] and v∈[ci,di]v \in [c_i, d_i] are independent and max⁡\max is nondecreasing in each argument, so the minimum is max⁡(min⁡u∣u−x∣,min⁡v∣v−y∣)\max(\min_u |u - x|, \min_v |v - y|). The distance from xx to [ai,bi][a_i, b_i] is max⁡(ai−x,x−bi,0)\max(a_i - x, x - b_i, 0), since at most one of ai−xa_i - x and x−bix - b_i is positive. The same holds for yy, and the maximum of the two expressions is the formula. □\square

Lemma 2 (shorts and the critical radius). Q(p,r)Q(p, r) meets RiR_i if and only if δi(p)≤r\delta_i(p) \le r. Hence Q(p,r)Q(p, r) meets rectangles of two different nets if and only if t(p)≤rt(p) \le r, and A(r)=area⁡{p∈W:t(p)≤r}A(r) = \operatorname{area}\{p \in W : t(p) \le r\}.

Proof. Q(p,r)∩Ri≠∅Q(p, r) \cap R_i \ne \emptyset if and only if some q∈Riq \in R_i has ∥q−p∥∞≤r\|q - p\|_\infty \le r. Since RiR_i is compact, the minimum δi(p)\delta_i(p) is attained, so this holds if and only if δi(p)≤r\delta_i(p) \le r. The square meets net NN if and only if dN(p)≤rd_N(p) \le r, and it meets two different nets if and only if at least two entries of the list (dN(p))N(d_N(p))_N are at most rr, which is the case if and only if the second smallest entry is at most rr. □\square

Lemma 3 (pieces). Let g1,…,g5g_1, \dots, g_5 be affine and PP a convex polygon. Line L6 splits PP by g2−mg_2 - m, then each part by g3−mg_3 - m, and so on, where mm is the piece recorded on the part, starting with m=g1m = g_1. The resulting parts are convex, have disjoint interiors, cover PP, and on each part the recorded piece gg equals max⁡kgk\max_k g_k.

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 jj, after the splits by g2,…,gjg_2, \dots, g_j the recorded piece on each part is ≥g1,…,gj\ge g_1, \dots, g_j on that part: on the part where gj−m≤0g_j - m \le 0 the old mm stays and is ≥gj\ge g_j; on the part where gj−m≥0g_j - m \ge 0 the new piece gjg_j is ≥m\ge m, which is ≥g1,…,gj−1\ge g_1, \dots, g_{j-1}. After j=5j = 5 the recorded piece is the maximum. □\square

Lemma 4 (vertex test). If an affine uu satisfies u≥0u \ge 0 at every vertex of a convex polygon PP, then u≥0u \ge 0 on PP. So if one piece gkg_k of δR\delta_R has gk≥hg_k \ge h at every vertex of PP, then δR≥h\delta_R \ge h on PP.

Proof. Every point of PP 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 u=gk−hu = g_k - h and uses δR=max⁡jgj≥gk\delta_R = \max_j g_j \ge g_k. □\square

Invariant. Let IkI_k be the first kk inserted rectangles. After their insertion:

  1. the faces are convex polygons with disjoint interiors whose union is WW;
  2. on each face with state (ν,h1,h2)(\nu, h_1, h_2) and for every point pp of the face, h1(p)=dνIk(p)=min⁡NdNIk(p)h_1(p) = d^{I_k}_\nu(p) = \min_N d^{I_k}_N(p) and h2(p)=min⁡N≠νdNIk(p)h_2(p) = \min_{N \ne \nu} d^{I_k}_N(p);
  3. h1h_1 and h2h_2 are affine on the face or +∞+\infty; when k=0k = 0 the state is (none,+∞,+∞)(\text{none}, +\infty, +\infty).

Base. For k=0k = 0 the one face is WW and all distances are +∞+\infty.

Step. Insert RR of net MM, and write g=δRg = \delta_R and dN=dNIkd_N = d^{I_k}_N. The new distances are dM′=min⁡(dM,g)d'_M = \min(d_M, g) and dN′=dNd'_N = d_N for N≠MN \ne M. Fix a face (P,ν,h1,h2)(P, \nu, h_1, h_2). 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, M=νM = \nu. By Lemma 4, g≥h1=dνg \ge h_1 = d_\nu on PP, so dν′=dνd'_\nu = d_\nu and nothing changes. Quick test, M≠νM \ne \nu. By Lemma 4, g≥h2g \ge h_2 on PP. Then dM′=min⁡(dM,g)≥h2d'_M = \min(d_M, g) \ge h_2, because dM≥h2d_M \ge h_2 by part 2. So min⁡N≠νdN′=h2\min_{N \ne \nu} d'_N = h_2, and the nearest net is still ν\nu with h1≤h2h_1 \le h_2. Nothing changes.

Otherwise the face is split by Lemma 3 into parts QQ on which gg is one affine piece. On a part QQ:

  • $\nu = $ none. This happens only for the first rectangle, since after it every point has a finite distance to its net. All dN=+∞d_N = +\infty, so dM′=gd'_M = g is the only finite distance: the state (M,g,+∞)(M, g, +\infty) is correct.
  • M=νM = \nu. dν′=min⁡(h1,g)d'_\nu = \min(h_1, g), and every other net has dN′=dN≥h1≥dν′d'_N = d_N \ge h_1 \ge d'_\nu, so ν\nu is still nearest and h2h_2 is unchanged. Splitting QQ by g−h1g - h_1 gives the part g≤h1g \le h_1, where h1←gh_1 \leftarrow g, and the part g≥h1g \ge h_1, where nothing changes. Both are affine.
  • M≠νM \ne \nu. Before the step dM≥h2≥h1d_M \ge h_2 \ge h_1, by part 2.
    • Where g≤h1g \le h_1: dM′=g≤h1=dν′≤dN′d'_M = g \le h_1 = d'_\nu \le d'_N for every N∉{M,ν}N \notin \{M, \nu\}. So MM is nearest with h1′=gh_1' = g, and the second smallest is min⁡(dν′,min⁡N∉{M,ν}dN′)=h1\min(d'_\nu, \min_{N \notin \{M, \nu\}} d'_N) = h_1, since all the other entries are ≥h1\ge h_1. The state (M,g,h1)(M, g, h_1) is correct.
    • Where h1≤g≤h2h_1 \le g \le h_2 (or h2=+∞h_2 = +\infty): dM′=min⁡(dM,g)=gd'_M = \min(d_M, g) = g because dM≥h2≥gd_M \ge h_2 \ge g. Since g≥h1g \ge h_1, ν\nu stays nearest. The other entries N∉{M,ν}N \notin \{M, \nu\} satisfy dN′=dN≥h2≥gd'_N = d_N \ge h_2 \ge g, so min⁡N≠νdN′=g\min_{N \ne \nu} d'_N = g. The state (ν,h1,g)(\nu, h_1, g) is correct.
    • Where g≥h2g \ge h_2: dM′=min⁡(dM,g)≥h2d'_M = \min(d_M, g) \ge h_2, and dN′=dN≥h2d'_N = d_N \ge h_2 for the other N≠νN \ne \nu, with equality for the net that attained h2h_2 (if that net is MM, then dM=h2d_M = h_2 there and dM′=h2d'_M = h_2). So min⁡N≠νdN′=h2\min_{N \ne \nu} d'_N = h_2 and nothing changes.

Each case sets h1h_1 and h2h_2 to affine functions on its part, so part 3 holds. This completes the step. □\square

Theorem 1 (exact critical area). After all rectangles are inserted, every face satisfies h2=th_2 = t on its polygon, and line L13 returns A(r)A(r) exactly.

Proof. By the invariant, on each face h1=min⁡NdNh_1 = \min_N d_N and the nearest net is ν\nu, so the second smallest entry of the list (dN)N(d_N)_N is min⁡N≠νdN=h2\min_{N \ne \nu} d_N = h_2, which is tt. Since there are at least two nets, tt is finite everywhere. The faces cover WW and their boundaries have zero area, so area⁡{p∈W:t(p)≤r}=∑facesarea⁡(P∩{h2≤r})\operatorname{area}\{p \in W : t(p) \le r\} = \sum_{\text{faces}} \operatorname{area}(P \cap \{h_2 \le r\}). By Lemma 2 the left side is A(r)A(r). Each term is the area of the convex polygon P∩{h2−r≤0}P \cap \{h_2 - r \le 0\}, computed exactly by one split and the shoelace formula in rational arithmetic. □\square

Lemma 5 (quadratic pieces). Let PP be a convex polygon and hh affine, not constant, with vertex values v0<v1<⋯<vmv_0 < v_1 < \dots < v_m (distinct values only). Then a(r)=area⁡(P∩{h≤r})a(r) = \operatorname{area}(P \cap \{h \le r\}) is 00 for r≤v0r \le v_0, equal to area⁡(P)\operatorname{area}(P) for r≥vmr \ge v_m, and a polynomial of degree at most 2 on each [vj,vj+1][v_j, v_{j+1}]. If hh is constant on PP with value vv, then a(r)=0a(r) = 0 for r<vr < v and area⁡(P)\operatorname{area}(P) for r≥vr \ge v.

Proof. Rotate coordinates so that h=∣∇h∣ s+consth = |\nabla h|\, s + \text{const} with ss the first coordinate. Then a(r)=∫−∞rℓ(ρ) dρ/∣∇h∣a(r) = \int_{-\infty}^{r} \ell(\rho)\, d\rho / |\nabla h|, where ℓ(ρ)\ell(\rho) is the length of the chord P∩{h=ρ}P \cap \{h = \rho\}. For ρ\rho strictly between vjv_j and vj+1v_{j+1}, no vertex lies on the line h=ρh = \rho, so the line crosses the same two edges of PP for all such ρ\rho. The crossing points depend affinely on ρ\rho along those fixed edges, so their distance ℓ(ρ)\ell(\rho) is affine in ρ\rho there. Its integral is quadratic on [vj,vj+1][v_j, v_{j+1}], and aa is continuous. Below v0v_0 the chord is empty, above vmv_m all of PP is included. The constant case is direct. □\square

Theorem 2 (average). Let ff be a density of the defect radius with survival function S(t)=∫t∞fS(t) = \int_t^\infty f. Then ∫0∞A(r)f(r) dr=∑faces∫0∞aP(r)f(r) dr\int_0^\infty A(r) f(r)\, dr = \sum_{\text{faces}} \int_0^\infty a_P(r) f(r)\, dr, 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 [vj,vj+1][v_j, v_{j+1}] the function aPa_P is the unique polynomial of degree at most 2 through its values at vjv_j, (vj+vj+1)/2(v_j + v_{j+1})/2 and vj+1v_{j+1}, which the implementation computes exactly and interpolates. Above vmv_m, aP=area⁡(P)a_P = \operatorname{area}(P) contributes area⁡(P)S(vm)\operatorname{area}(P) S(v_m). For Stapper's density, ∫rk⋅r/r02 dr\int r^k \cdot r/r_0^2\, dr and ∫rk⋅r02r−3 dr\int r^k \cdot r_0^2 r^{-3}\, dr for k=0,1,2k = 0, 1, 2 are rk+2/((k+2)r02)r^{k+2}/((k+2) r_0^2), −r02/(2r2)-r_0^2/(2r^2), −r02/r-r_0^2/r and r02ln⁡rr_0^2 \ln r, which are the closed forms used, with each interval split at r0r_0. □\square

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 tt from the second order L∞L_\infty 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 4n+14n + 1 affine pieces of the distance functions, so there are O(n2)O(n^2) such lines. The faces are unions of cells of their arrangement inside WW, so F=O(n4)F = O(n^4), 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, O(n4)O(n^4), so the build takes O(n5)O(n^5) operations on rationals of bounded size in the worst case. This bound is crude. On random layouts with n=5,10,20n = 5, 10, 20 and 4040 rectangles the implementation leaves F=183F = 183, 445445, 12941294 and 39903990 faces, about n1.5n^{1.5}; most of them are fragments of larger regions of the diagram, which could be merged when their states are equal.

Once built, A(r)A(r) at one radius costs one clip per face, O(Fk)O(F k). The average costs O(k)O(k) clips per face, O(Fk2)O(F k^2). The method answers all radii from one build, where direct shape expansion pays a full union of rectangles for every radius.

Properties

  • Exact. A(r)A(r) 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 rr or on ff; a new size distribution needs only line L14.
  • Square defects. The result is the critical area for square defects. A disk of radius rr lies inside the square of radius rr and contains the square of radius r/2r/\sqrt{2}, so the disk critical area lies between A(r/2)A(r/\sqrt{2}) and A(r)A(r).
  • 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 L∞L_\infty 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 L∞L_\infty 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 Aˉ\bar A 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 A(r)A(r). See Monte Carlo integration.
  • Shape expansion. Growing all shapes by rr and intersecting nets, as in the union test of the implementation, gives A(r)A(r) for one rr 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 A(r/2)A(r/\sqrt{2}) and A(r)A(r). 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 t=0t = 0 everywhere near them if treated as different sites.
  • Window edges. Shapes just outside WW still count as near nets. Include them, or the area near the border is too small.
  • Divergent averages. With Stapper's r−3r^{-3} tail, a formula for one pair extended to all rr diverges; the window cap A(r)≤area⁡(W)A(r) \le \operatorname{area}(W) 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.

voronoi_critical_area_extraction.pyI0RawGitHub
# 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 L∞L_\infty 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

  1. 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
  2. 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
  3. 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.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.average
  • a full proof of time.build
  • a full proof of time.query
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example