Algorithmadvanced
Simplicial approximation
Also called Director-Hachtel design centering.
Director and Hachtel's design centering. A polytope built from boundary points approximates the feasible region, and the design moves to the center of its largest inscribed ball.
- Time
- O(K (m log m + s)) worst
- Space
- O(m) extra
- Where
- K = the number of rounds; m = the number of boundary points, at most 4 + K in the plane; s = the number of circuit evaluations per line search
- Model
- Word RAM
- Properties
- deterministicnot exactofflineiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Stephen W. Director, Gary D. Hachtel, 1977
Simplicial approximation is a method for design centering that Director and Hachtel published in 1977. The acceptable region of the circuit parameters, the set where every specification holds, is known only through circuit simulation. The method assumes that is convex. It finds points on the boundary of by line searches, takes their convex hull as an inner approximation of , and puts the nominal design at the center of the largest ball inscribed in that polytope, which is a linear program. It then adds a boundary point near a face that touches the ball and repeats. The ball is a hypersphere in the parameter space as scaled. If the parameters are first scaled by their spreads, the ball is an ellipsoid in the original units. This page proves what the method guarantees on a convex region, shows a region where the polytope stops growing, and shows a nonconvex region where the method fails.
In plain words
A circuit works for some parameter settings and fails for others. The settings that work form a region, and its edge is costly to find, since each test is a simulation. The goal is to put the design deep inside the region, so that manufacturing errors do not push it out.
The method walks from a working design in a few directions until the circuit fails, and keeps the points where it crossed the edge. Joining these points gives a shape with flat sides that lies inside the region, if the region has no dents. Inside the shape it finds the largest round ball, and the center of that ball is the new design.
Then it looks at the flat sides that touch the ball, walks outward from the middle of the largest one to find a new edge point, and grows the shape. The ball can only grow.
The problem
The input is a point inside and a line search oracle: for and a direction , is the last point of the ray , , that lies in . In practice the oracle is a bisection on with one circuit simulation per step. The output is a center and a radius with , as large as the method can certify. The parameters are assumed to be scaled so that a ball is the right shape for the tolerances: with a covariance of the process spreads, the scaled parameters are , and a ball there is the ellipsoid in the original units.
The key subproblem is the largest ball in a polytope with unit normals . A ball lies in the half-space of face if and only if , because the farthest point of the ball along is . So the largest ball is the linear program
in the variables . Its center is often called a Chebyshev center of . A face is tangent when its constraint is tight at the optimum, that is when it touches the ball.
The algorithm
SIMPLICIAL-APPROXIMATION(exit, x0, K)- 1
S ← {exit(x0, +e_j), exit(x0, −e_j) : j = 1, …, n} ▷ 2n line searches - 2
repeat at most K times - 3
P ← the convex hull of S, as faces n_f · x ≤ b_f with unit normals - 4
(c, r) ← argmax r subject to n_f · c + r ≤ b_f for every face f - 5
T ← the faces of P with n_f · c + r = b_f ▷ tangent faces - 6
sort T by decreasing size (in the plane, edge length) - 7
for each face f of T that is not marked: q ← the center of the largest ball inside f - 8
y ← exit(q, n_f) ▷ search outward along the normal - 9
if y ≠ q then S ← S ∪ {y}; go to the next round - 10
else mark f ▷ f lies on a supporting hyperplane of R - 11
if no point was added then stop ▷ every tangent face supports R - 12
return c, r
In the plane, a face is an edge, and the center of the largest ball inside it is its midpoint. The implementation works in the plane. It builds the hull with Andrew's monotone chain and solves the three-variable linear program of line L4 with the simplex method under Bland's rule, starting from the basis of slack variables around the centroid of the hull vertices.
Example
The region is the triangle , , . Its largest inscribed disc has radius and center . The start is , and the four line searches of L1 return , , and . The last column gives the area of the hull divided by the area 18 of the triangle.
| round | new point | center | radius | step of lines L5 to L10 | area ratio |
|---|---|---|---|---|---|
| 0 | the four of L1 | (1, 3.723) | 0.903 | all 4 edges touch; the longest, (0, 4) to (1, 0), has midpoint (0.5, 2), and the search finds (0, 1.875) | 0.278 |
| 1 | (0, 1.875) | (0.937, 3.612) | 0.937 | longest tangent edge (1, 0) to (2, 4), midpoint (1.5, 2), new point (4.833, 1.167) | 0.337 |
| 2 | (4.833, 1.167) | (1.798, 1.926) | 1.610 | the longest tangent edge lies on , so the search returns its midpoint and the edge is marked; the next, (1, 0) to (4.833, 1.167), gives (3.094, 0) | 0.730 |
| 3 | (3.094, 0) | (1.995, 1.659) | 1.659 | the longest unmarked tangent edge, (0, 1.875) to (1, 0), gives (0, 0.671) | 0.798 |
| 4 | (0, 0.671) | (1.757, 1.757) | 1.757 | the four tangent edges, two of them on , lie on the three sides of the triangle: stop | 0.832 |
The method stops with the exact inscribed disc after eight line searches that found a point and four that did not. The hull covers only 83 percent of the triangle at the stop. The method needs the boundary only where the ball touches it.
On regions with a curved boundary the method does not stop, and the measured behavior depends on the shape. The table gives the area ratio and the radius for a unit disc started at and for the ellipse started at , whose largest inscribed disc has radius 1. The "longest edge" rule refines the longest edge of the whole hull in place of the longest tangent edge.
| region and rule | round 0 | round 5 | round 10 | round 20 | round 40 | round 59 |
|---|---|---|---|---|---|---|
| disc, tangent rule: area | 0.595 | 0.906 | 0.965 | 0.987 | 0.996 | 0.998 |
| disc, tangent rule: | 0.666 | 0.904 | 0.966 | 0.987 | 0.995 | 0.998 |
| ellipse, tangent rule: area | 0.588 | 0.872 | 0.880 | 0.880 | 0.880 | 0.880 |
| ellipse, tangent rule: | 0.846 | 0.967 | 0.998 | 1.000 | 1.000 | 1.000 |
| ellipse, longest edge: area | 0.588 | 0.906 | 0.956 | 0.982 | 0.995 | 0.998 |
On the ellipse the tangent rule finds the right radius by round 20 and then keeps refining near the two points where the ball touches, so the polytope never covers more than 88 percent of the region. This is correct for centering, but it means the polytope is not a good model of the whole region.
Correctness
The full proof shows four facts for a compact convex region with a nonempty interior, and one failure for a nonconvex region.
The ball is a linear program. As shown above, if and only if for all faces.
Inclusion, nesting and monotone radius. The points of lie in and is convex, so each hull lies in , and so does each ball. Points are only added, so , the old ball is feasible in the next round, and , where is the radius of the largest ball in .
The stop test is sound. If the outward search from the midpoint of a face, or from any point in its relative interior, does not move, then the hyperplane of that face supports . Otherwise a point of beyond the face and the face itself would span points of just outside the midpoint.
A fixed point is optimal. Suppose every tangent face supports . By LP duality and complementary slackness, there are weights on the tangent faces with , and . Any ball in satisfies for these faces, and the weighted sum gives . So when the method stops at line L11, its ball is a largest ball in .
What is not guaranteed. The rule does not make the polytope converge to , as the ellipse shows. This page does not prove that tends to when the method runs forever; the disc and ellipse runs only measure it. Director and Hachtel discuss convergence for convex regions in their paper, and the reader should take the exact statement from there.
Nonconvex regions. For the L-shaped region started at , the first hull is the quadrilateral with corners , , and . It contains , which is not in , and its inscribed disc, with center and radius 1.311, contains , which is not in either. The run ends with a radius of 1.464, while no disc in has a radius above .
Proof: What simplicial approximation guarantees on a convex region, and how it fails on a nonconvex onefull
Setting. is a compact convex set with a nonempty interior, the acceptable region. For and a direction , the line search returns with . Because is convex and closed, . The method starts from an interior point . is the set of boundary points after round , , and is the optimum of the linear program of line L4 for . The inscribed radius of a set is .
Lemma 1 (the largest ball is a linear program). Let with . Then if and only if for every . So is the optimum of
a linear program in the variables .
Proof. The largest value of over is , reached at . The ball lies in the half-space of face if and only if this value is at most , and it lies in if and only if it lies in every half-space.
The center of an optimal ball is often called a Chebyshev center of . If the norms are not normalized, the constraint reads , which is still linear in .
Lemma 2 (the start). has a nonempty interior and contains in its interior.
Proof. is interior, so each of the line searches along returns with . The hull of these points contains the cross-polytope , which contains a ball around .
Theorem 1 (inclusion, nesting and monotone radius). For every round :
- .
- .
- .
Proof. Every point of is in , and is convex, so the convex hull of is in . The ball is in by Lemma 1. Points are only added, so and . The optimal ball of round lies in , so it is feasible for the program of round , and . Finally, gives .
So each center is a feasible design with a safety margin of at least in every direction, and the margin never shrinks from one round to the next.
Lemma 3 (the stop test). Let be a facet of with outward unit normal and hyperplane , and let be a point in the relative interior of . If , then , so the hyperplane of supports .
Proof. , so and the line search is defined. Suppose some has . Write , where is parallel to the hyperplane of . Since is in the relative interior of and the affine hull of is that hyperplane, for some small . Let , so that . The point
is a convex combination of points of , so . Then for the search from along , which contradicts .
In the plane, a facet is an edge and the center of the largest -ball in it is its midpoint, which is in its relative interior. In higher dimensions the center of the largest ball inscribed in a facet is also in its relative interior when the facet has a nonempty relative interior.
Theorem 2 (a fixed point is optimal). Suppose that at round every face that touches the optimal ball, that is with , supports . Then , and is a largest ball in . In particular, when the method stops at line L11, every tangent face was marked by Lemma 3, and the returned ball is a largest ball in .
Proof. The dual of the program of Lemma 1 is
The primal is feasible and bounded, so by strong duality the dual has an optimal with , and by complementary slackness only for faces that touch the optimal ball. Take any ball . For each touching face , lies in its half-space, so by Lemma 1 . Multiply by and add:
So no ball in is larger than , and with Theorem 1, . A mark set in an earlier round stays valid, because a supporting hyperplane of stays a supporting hyperplane.
The proof shows more: the optimal ball needs only the faces that touch it to lie on supporting hyperplanes of . The polytope can be far from elsewhere. On the triangle of the page, the method stops with the exact inscribed disc while the hull covers only 83 percent of the triangle.
What is not proved here. Two natural claims are not given a proof on this page.
- Convergence of the polytope to . The rule refines only faces that touch the ball, so the polytope need not fill . On the ellipse the tests measure that the area of stays at 88.0 percent of the area of from round 20 to round 60, while has reached . The variant that refines the longest edge of the whole hull adds points with gaps that shrink along the whole boundary, and in the same test it reaches 99.8 percent.
- Convergence of to when the method never stops. The tests measure it on a disc (0.998 after 60 rounds) and an ellipse, but the general statement is not proved here. Director and Hachtel (1977) give the method and their own discussion of its convergence for convex regions, and the reader should consult the paper for its exact statement.
Theorem 3 (failure on a nonconvex region). Let be the L-shaped region and . Then , and the optimal ball of is not contained in .
Proof. The four line searches from return , , and . Their hull is the quadrilateral bounded by , , and . The point satisfies all four inequalities, but it lies in the removed square , so it is not in . By the symmetry in and , the program of Lemma 1 has an optimal center that touches , and , so . This gives and . The ball contains , which is not in .
The run goes on to stop with a radius of 1.4645, while every disc in has radius at most . It stops because the midpoint of a tangent edge is outside , so the line search has no valid start, and the implementation reads this as a face on the boundary. So on a nonconvex region the method can report a center whose ball holds infeasible designs, and a radius that no ball in reaches.
Complexity
In the plane, round has boundary points. The hull costs , the three-variable program costs with Megiddo's method for fixed dimension, and a round runs at most one successful line search plus one search for each newly marked face. Each face is marked at most once, so rounds cost arithmetic and circuit evaluations, where is the number of simulations per line search. In practice the simulations dominate: a bisection to a relative accuracy of takes about 10 of them. The implementation uses the simplex method, which is fast on these small programs but has no such worst-case bound.
In dimensions the hull of points can have on the order of faces, by the upper bound theorem for polytopes, and the program has one constraint per face. This is why the method is practical only for a few parameters, often fewer than ten.
Properties
- Inner approximation. For a convex region every polytope and every ball lie inside , so the center is always a working design and is a certified margin.
- Monotone. The radius never decreases, and the polytope only grows. With a distribution of the parameters, the probability of the polytope around the nominal point is a lower bound on the yield, and it grows from round to round, as Bandler and Chen note.
- Exact at a fixed point. When all tangent faces support the ball is a largest ball in . On polygons and polytopes this stop can happen after finitely many rounds, as on the triangle.
- Local refinement. Only the boundary near the ball is explored, which saves simulations but leaves the rest of the region unknown.
- Needs convexity. Every guarantee above rests on the convexity of .
Variants and improvements
- Scaling and ellipsoids. Scaling by the process covariance before the method turns the ball into an ellipsoid of equal probability density under a normal law. A worst-case tolerance box needs a different body and a different program.
- Refining the whole boundary. Choosing the longest face overall, as in the ellipse table, makes the polytope fill the region, at the cost of searches far from the ball. Such a polytope is better for yield estimation.
- Yield estimation. Director, Hachtel and Vidigal (1978) estimate the yield from the polytope, by integrating the parameter density over it, which is cheap since membership in a polytope needs no simulation.
- Other centering methods. The design centering page lists the gravity method, statistical Monte Carlo methods and worst-case distance methods, which do not need a convex region.
- Operability analysis. Goyal and Ierapetritou (2002) used the same steps to map the feasible operating region of chemical processes.
When to use it
Use it when the acceptable region is known or expected to be convex, the number of parameters is small, and each simulation is expensive enough that a few dozen line searches are the budget. It gives a centered design with a certified margin. Do not use it when the region may be nonconvex, for example when several specifications pull in different directions, or for more than a handful of parameters. In those cases a statistical method or a worst-case distance method is safer.
Pitfalls
- Nonconvex regions. The polytope can contain failing designs, and the reported margin can be larger than any margin in , as in the L-shaped example. Nothing in the method warns about this; a check of the center and of a few points of the ball by simulation catches the worst cases.
- Unscaled parameters. A ball in raw units treats a resistor in ohms and a width in micrometers as equal. Scale by the spreads first.
- Inexact line searches. A bisection that stops early returns a point slightly inside or outside . A point outside breaks the inclusion. Bias the search to return the last feasible point.
- Ties and degenerate faces. Several faces can touch the ball, and several can have the same size. A fixed tie rule keeps runs reproducible.
- Using the polytope as the region. The polytope is accurate only near the ball. A yield computed from it is a lower bound, and it can be far below the true yield, as on the ellipse.
- Starting point. must be strictly inside ; otherwise the first hull can be flat and the program has no ball.
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
# Shared helper of the pr3 eda pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Plane regions with exact line search oracles, for the simplicial approximation tests.
Each region has inside(p), exit_point(x, d) and area. exit_point returns the
point where the ray x + t d, t >= 0, first leaves the closed region, for x
in the region; a point on the boundary that moves outward exits at t = 0.
"""
import math
class Ellipse:
"""(x - cx)^2 / a^2 + (y - cy)^2 / b^2 <= 1; a = b gives a disc."""
def __init__(self, cx, cy, a, b):
self.cx, self.cy, self.a, self.b = cx, cy, a, b
self.area = math.pi * a * b
def inside(self, p, eps=1e-9):
return ((p[0] - self.cx) / self.a) ** 2 + ((p[1] - self.cy) / self.b) ** 2 <= 1 + eps
def exit_point(self, x, d):
u = ((x[0] - self.cx) / self.a, (x[1] - self.cy) / self.b)
e = (d[0] / self.a, d[1] / self.b)
qa = e[0] ** 2 + e[1] ** 2
qb = 2 * (u[0] * e[0] + u[1] * e[1])
qc = min(u[0] ** 2 + u[1] ** 2 - 1, 0.0)
t = (-qb + math.sqrt(max(qb * qb - 4 * qa * qc, 0.0))) / (2 * qa)
return (x[0] + t * d[0], x[1] + t * d[1])
class ConvexPolygon:
"""The intersection of the half-planes n . p <= c of its edges; vertices counterclockwise."""
def __init__(self, vertices):
self.vertices = vertices
self.halfplanes = []
for i, a in enumerate(vertices):
b = vertices[(i + 1) % len(vertices)]
dx, dy = b[0] - a[0], b[1] - a[1]
n = (dy / math.hypot(dx, dy), -dx / math.hypot(dx, dy))
self.halfplanes.append((n, n[0] * a[0] + n[1] * a[1]))
self.area = abs(shoelace(vertices))
def inside(self, p, eps=1e-9):
return all(n[0] * p[0] + n[1] * p[1] <= c + eps for n, c in self.halfplanes)
def exit_time(self, x, d):
t = math.inf
for n, c in self.halfplanes:
nd = n[0] * d[0] + n[1] * d[1]
if nd > 1e-15:
t = min(t, max((c - n[0] * x[0] - n[1] * x[1]) / nd, 0.0))
return t
def exit_point(self, x, d):
t = self.exit_time(x, d)
return (x[0] + t * d[0], x[1] + t * d[1])
class Union:
"""A union of convex polygons, possibly nonconvex, with the exact first exit along a ray."""
def __init__(self, pieces, area):
self.pieces, self.area = pieces, area
def inside(self, p, eps=1e-9):
return any(q.inside(p, eps) for q in self.pieces)
def exit_point(self, x, d):
t = 0.0
while True:
p = (x[0] + t * d[0], x[1] + t * d[1])
nxt = max((t + q.exit_time(p, d) for q in self.pieces if q.inside(p)), default=t)
if nxt <= t + 1e-15:
return p
t = nxt
def shoelace(vertices):
return sum(a[0] * b[1] - b[0] * a[1] for a, b in zip(vertices, vertices[1:] + vertices[:1])) / 2
simplicial_approximation.py 123 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/simplicial-approximation/. The authors are listed in prov/TB95X2.jsonl.
"""Simplicial approximation for design centering in the plane (after Director and Hachtel 1977).
The feasible region R is known only through a line search oracle:
exit_point(x, d) returns the point where the ray x + t d, t >= 0, first
leaves R, for a point x of R. The method keeps a set of boundary points,
takes their convex hull, puts the largest inscribed disc in the hull by a
linear program, and adds a new boundary point found from the middle of the
longest edge that touches the disc, along the outward normal of that edge.
simplicial_approximation returns one record per iteration with the hull,
the centre and the radius. The method assumes that R is convex; on a
nonconvex region the hull can leave R.
"""
import math
def convex_hull(points):
"""Andrew's monotone chain; vertices in counterclockwise order, no collinear ones."""
pts = sorted(set(points))
if len(pts) <= 2:
return pts
def cross(o, a, b):
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])
lower, upper = [], []
for p in pts:
while len(lower) >= 2 and cross(lower[-2], lower[-1], p) <= 1e-12:
lower.pop()
lower.append(p)
for p in reversed(pts):
while len(upper) >= 2 and cross(upper[-2], upper[-1], p) <= 1e-12:
upper.pop()
upper.append(p)
return lower[:-1] + upper[:-1]
def edges(hull):
"""Edges (a, b, unit outward normal, offset): the hull is n . x <= offset."""
out = []
for i, a in enumerate(hull):
b = hull[(i + 1) % len(hull)]
dx, dy = b[0] - a[0], b[1] - a[1]
length = math.hypot(dx, dy)
nrm = (dy / length, -dx / length)
out.append((a, b, nrm, nrm[0] * a[0] + nrm[1] * a[1]))
return out
def inscribed_disc(faces, inner):
"""The LP max r subject to n_f . c + r <= b_f, by the simplex method.
inner is a point strictly inside the polygon. The variables are
c - inner split into positive and negative parts, and r, so the origin
is a feasible basis. Bland's rule prevents cycling.
"""
m = len(faces)
rows = []
for i, (_, _, (nx, ny), off) in enumerate(faces):
slack = [1.0 if j == i else 0.0 for j in range(m)]
rows.append([nx, -nx, ny, -ny, 1.0] + slack + [off - nx * inner[0] - ny * inner[1]])
cost = [0.0, 0.0, 0.0, 0.0, -1.0] + [0.0] * m + [0.0]
basis = [5 + i for i in range(m)]
while True:
enter = next((j for j in range(5 + m) if cost[j] < -1e-12), None)
if enter is None:
break
best = None
for i in range(m):
if rows[i][enter] > 1e-12:
ratio = rows[i][-1] / rows[i][enter]
if best is None or ratio < best[0] - 1e-15 or (abs(ratio - best[0]) <= 1e-15 and basis[i] < basis[best[1]]):
best = (ratio, i)
i = best[1]
piv = rows[i][enter]
rows[i] = [x / piv for x in rows[i]]
for k in range(m):
if k != i and rows[k][enter] != 0.0:
f = rows[k][enter]
rows[k] = [x - f * y for x, y in zip(rows[k], rows[i])]
f = cost[enter]
cost = [x - f * y for x, y in zip(cost, rows[i])]
basis[i] = enter
x = [0.0] * 5
for i, j in enumerate(basis):
if j < 5:
x[j] = rows[i][-1]
return (inner[0] + x[0] - x[1], inner[1] + x[2] - x[3]), x[4]
def simplicial_approximation(exit_point, x0, iterations, rule="tangent", tol=1e-9):
points = [exit_point(x0, d) for d in ((1, 0), (0, 1), (-1, 0), (0, -1))] # @line L1
on_boundary = set()
history = []
for _ in range(iterations): # @line L2
hull = convex_hull(points) # @line L3
faces = edges(hull)
inner = (sum(p[0] for p in hull) / len(hull), sum(p[1] for p in hull) / len(hull))
centre, radius = inscribed_disc(faces, inner) # @line L4
history.append({"hull": hull, "centre": centre, "radius": radius})
scale = max(1.0, radius)
if rule == "tangent": # @line L5
cand = [f for f in faces if f[3] - f[2][0] * centre[0] - f[2][1] * centre[1] - radius <= 1e-7 * scale]
else:
cand = list(faces)
cand.sort(key=lambda f: -math.dist(f[0], f[1])) # @line L6
added = False
for a, b, nrm, _ in cand:
if (a, b) in on_boundary:
continue
mid = ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2) # @line L7
y = exit_point(mid, nrm) # @line L8
if math.dist(y, mid) > tol * scale:
points.append(y) # @line L9
added = True
break
on_boundary.add((a, b)) # @line L10
if not added: # @line L11
break
return history # @line L12
test_simplicial_approximation.py 133 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/simplicial-approximation/. The authors are listed in prov/TB95X2.jsonl.
import itertools
import math
import random
from regions import ConvexPolygon, Ellipse, Union, shoelace
from simplicial_approximation import convex_hull, edges, inscribed_disc, simplicial_approximation
TRIANGLE = ConvexPolygon([(0, 0), (6, 0), (0, 6)])
PENTAGON = ConvexPolygon([(0, 0), (4, 0), (5, 3), (2, 5), (-1, 3)])
DISC = Ellipse(0, 0, 1, 1)
ELLIPSE = Ellipse(0, 0, 2, 1)
L_SHAPE = Union([ConvexPolygon([(0, 0), (4, 0), (4, 2), (0, 2)]), ConvexPolygon([(0, 0), (2, 0), (2, 4), (0, 4)])], 12.0)
def solve3(a, y):
det = lambda m: (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]))
d = det(a)
if abs(d) < 1e-12:
return None
out = []
for j in range(3):
m = [row[:] for row in a]
for i in range(3):
m[i][j] = y[i]
out.append(det(m) / d)
return out
def brute_radius(faces):
# The LP optimum is at a vertex: try every triple of tight faces.
best = 0.0
for f in itertools.combinations(faces, 3):
x = solve3([[n[0], n[1], 1.0] for _, _, n, _ in f], [b for _, _, _, b in f])
if x and all(n[0] * x[0] + n[1] * x[1] + x[2] <= b + 1e-9 for _, _, n, b in faces):
best = max(best, x[2])
return best
def random_convex_polygon(rng):
while True:
hull = convex_hull([(rng.uniform(-3, 3), rng.uniform(-3, 3)) for _ in range(rng.randint(3, 9))])
if len(hull) >= 3 and abs(shoelace(hull)) > 1:
return hull
def test_convex_hull_contains_all_points():
rng = random.Random(5)
for _ in range(100):
pts = [(rng.uniform(-1, 1), rng.uniform(-1, 1)) for _ in range(rng.randint(3, 12))]
hull = convex_hull(pts)
assert set(hull) <= set(pts)
assert all(n[0] * p[0] + n[1] * p[1] <= b + 1e-12 for _, _, n, b in edges(hull) for p in pts)
def test_inscribed_disc_lp_against_brute_force():
rng = random.Random(6)
for _ in range(150):
faces = edges(random_convex_polygon(rng))
hull = [f[0] for f in faces]
inner = (sum(p[0] for p in hull) / len(hull), sum(p[1] for p in hull) / len(hull))
centre, radius = inscribed_disc(faces, inner)
assert math.isclose(radius, brute_radius(faces), rel_tol=1e-9, abs_tol=1e-12)
assert all(n[0] * centre[0] + n[1] * centre[1] + radius <= b + 1e-9 for _, _, n, b in faces)
def check_run(region, x0, iterations, r_region):
history = simplicial_approximation(region.exit_point, x0, iterations)
previous = None
for rec in history:
hull, c, r = rec["hull"], rec["centre"], rec["radius"]
# Every vertex is a point of R, so for convex R the whole hull is in R.
assert all(region.inside(p) for p in hull)
assert all(n[0] * c[0] + n[1] * c[1] + r <= b + 1e-9 for _, _, n, b in edges(hull))
assert r <= r_region + 1e-9
if previous:
assert r >= previous["radius"] - 1e-9
assert all(n[0] * p[0] + n[1] * p[1] <= b + 1e-9 for _, _, n, b in edges(hull) for p in previous["hull"])
previous = rec
return history
def test_convex_regions_inside_nested_and_monotone():
check_run(DISC, (0.3, -0.2), 60, 1.0)
check_run(ELLIPSE, (0.5, 0.3), 60, 1.0)
check_run(TRIANGLE, (1.0, 4.0), 60, 6 - 3 * math.sqrt(2))
check_run(PENTAGON, (1.0, 1.0), 60, brute_radius(edges(PENTAGON.vertices)))
def test_polygon_stops_at_its_inscribed_disc():
h = check_run(TRIANGLE, (1.0, 4.0), 60, 6 - 3 * math.sqrt(2))
r = 6 - 3 * math.sqrt(2)
assert len(h) == 5
assert math.isclose(h[-1]["radius"], r, rel_tol=1e-9)
assert math.dist(h[-1]["centre"], (r, r)) < 1e-8
rng = random.Random(7)
for _ in range(40):
region = ConvexPolygon(random_convex_polygon(rng))
x0 = tuple(sum(p[i] for p in region.vertices) / len(region.vertices) for i in range(2))
want = brute_radius(edges(region.vertices))
h = check_run(region, x0, 200, want)
assert len(h) < 200
assert math.isclose(h[-1]["radius"], want, rel_tol=1e-7)
def test_measured_area_ratios():
# Measured, not proved: the tangent rule fills the disc but stalls on the ellipse.
disc = simplicial_approximation(DISC.exit_point, (0.3, -0.2), 60)
ratio = [shoelace(rec["hull"]) / DISC.area for rec in disc]
assert [round(ratio[k], 3) for k in (0, 10, 40, 59)] == [0.595, 0.965, 0.996, 0.998]
ell = simplicial_approximation(ELLIPSE.exit_point, (0.5, 0.3), 60)
assert round(shoelace(ell[-1]["hull"]) / ELLIPSE.area, 3) == 0.880
assert math.isclose(ell[-1]["radius"], 1.0, rel_tol=1e-6)
longest = simplicial_approximation(ELLIPSE.exit_point, (0.5, 0.3), 60, rule="longest")
assert shoelace(longest[-1]["hull"]) / ELLIPSE.area > 0.997
def test_nonconvex_region_breaks_the_method():
h = simplicial_approximation(L_SHAPE.exit_point, (1.0, 1.0), 20)
first = h[0]
assert first["hull"] == [(0.0, 1.0), (1.0, 0.0), (4.0, 1.0), (1.0, 4.0)]
# The hull holds points that are not in R.
assert not L_SHAPE.inside((2.4, 2.4))
assert all(n[0] * 2.4 + n[1] * 2.4 <= b for _, _, n, b in edges(first["hull"]))
# The final disc is larger than any disc in R and pokes out of R.
last = h[-1]
c, r = last["centre"], last["radius"]
best = 2 * math.sqrt(2) / (1 + math.sqrt(2))
assert r > best + 0.2
far = (c[0] + r / math.sqrt(2), c[1] + r / math.sqrt(2))
assert not L_SHAPE.inside(far)
History
Director and Hachtel published simplicial approximation in 1977, at a time when design centering by Monte Carlo methods needed thousands of simulations. Their idea was to replace the unknown region by a polytope that is cheap to work with, and to spend simulations only on line searches. Director, Hachtel and Vidigal (1978) used the same polytope to estimate the yield. Later surveys, such as that of Bandler and Chen (1988), list the method among the first geometric centering methods and note that its convexity assumption limits its use. The method was later applied to the operability of chemical processes by Goyal and Ierapetritou (2002).
References
- Stephen W. Director and Gary D. Hachtel, The simplicial approximation approach to design centering, IEEE Transactions on Circuits and Systems CAS-24(7), 363 to 372, July 1977, the method (boundary points by line searches, the convex hull, the inscribed hypersphere by a linear program, expansion from the largest face that touches the sphere) and its assumption that the region is convex; the section numbers were not checked
- Stephen W. Director, Gary D. Hachtel and Luis M. Vidigal, Computationally efficient yield estimation procedures based on simplicial approximation, IEEE Transactions on Circuits and Systems 25(3), 121 to 130, 1978, yield estimation from the polytope of the method
- John W. Bandler and Shao Hua Chen, Circuit optimization, the state of the art, IEEE Transactions on Microwave Theory and Techniques 36(2), 424 to 443, February 1988, Section V.B, the simplicial approach, which gives a lower bound on the yield that increases monotonically and is limited by its convexity assumption
- Vishal Goyal and Marianthi G. Ierapetritou, Determination of operability limits using simplicial approximation, AIChE Journal 48(12), 2002, a step-by-step restatement of the method and its use outside circuit design (the page range was not confirmed)
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 TB95X2 Edit this page History Report an error Markdown