feat(spatial): 近贴合家族与容差扫描

稳定性家族加 clearance 参数(把上块抬离底座 0/1/2/4 格,1 格 = 0.25mm),
新增 area.gap1/2/4。extract 加 tol 子命令:对每个间隙扫容差,问两件事——会不会
提取出一条不存在的 T-P 接触,以及这条假边会不会被检查器接受为有效凭证。
This commit is contained in:
x committed 2026-12-03 22:23:04 +08:00
1 parent e798d8fc43
commit b46c76ce9a
2 files changed
+59 -5

No files matched your search

+42 -1
View File
@@ -178,9 +178,50 @@ def report(n: int = 32) -> None:
print("余隙 = 互不接触的零件表面之间的最小距离,说明容差有没有被真正考验")
GAP_FAMILIES = (("area.sup2", 0), ("area.gap1", 1), ("area.gap2", 2), ("area.gap4", 4))
def report_tolerance(n: int = 8) -> None:
"""Does the distance tolerance decide anything, and what does it cost.
For every clearance the upper block sits at, sweep the tolerance and ask two
questions: does an edge between the block and its (absent) pedestal appear,
and if so does the checker accept that edge as a certificate. A tolerance
that fuses two parts 0.25mm apart does not merely add noise -- it forges a
support that validates.
"""
tols = (0.0, 0.5, 1.0, 2.0, 4.0)
print(f"{'family':10s} {'间隙':>4s} " + " ".join(f"{t:>9.1f}" for t in tols))
print("-" * 68)
for fam, gap in GAP_FAMILIES:
cells = []
for tol in tols:
got = forged = total = 0
for i in range(n):
sc = generator.make(fam, seed=7, index=i)
edges = extract_edges(sc.obs.entities, tol=tol)
world = FullState(entities=list(sc.obs.entities), edges=edges)
tp = [e for e in edges if {e.a, e.b} == {"T", "P"}]
total += 1
if tp:
got += 1
forged += int(checker.validate_evidence(
world, Query(kind="stability", a="T"), [tp[0].eid]))
mark = "ok" if gap == 0 else ("!" if forged else " ")
cells.append(f"{got:2d}/{total} {mark:2s}")
print(f"{fam:10s} {gap:4d} " + " ".join(f"{c:>9s}" for c in cells))
print()
print("单元格 = 提取到 T-P 边的样本数 / 总数;ok = 该边合法(间隙为 0,本来就贴着)")
print("! = 该边被检查器当成有效凭证,但零件其实没有接触 —— 容差过大伪造了支撑")
print("间隙单位 0.25mm;真实装配的余隙是 0.2mm 级,即 1 格")
def main(argv=None) -> int:
argv = list(sys.argv[1:] if argv is None else argv)
report(int(argv[0]) if argv else 32)
if argv and argv[0] == "tol":
report_tolerance(int(argv[1]) if len(argv) > 1 else 8)
else:
report(int(argv[0]) if argv else 32)
return 0