From 32819042e5e77c7bf69eb6e72924034b6c84b9f2 Mon Sep 17 00:00:00 2001 From: x Date: Thu, 3 Dec 2026 19:27:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(spatial):=20=E6=8A=8A=E5=9B=A0=E6=9E=9C?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=8F=98=E6=88=90=E5=88=86=E5=B8=83=EF=BC=8C?= =?UTF-8?q?=E8=AE=A9=E5=90=8C=E6=97=8F=E5=86=85=E4=B8=A4=E4=B8=AA=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=B9=B6=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 反复出现的同一个病:每加一族,模型就换一条按域的常量规则。原因是同族内因果变量 是固定的——"有接触"和"接触吃得上力"在家族内部是同一件事,于是恒答一行就能fit。 - 稳定性:上块 T 的 xy 从 {-13,-6,0,3,6,13}x{-9,0,0,0,9} 抽取,形心有时落在重叠 矩形之外,接触存在但不吃载,同族内真/假并存。 - 自由度:六个配合的轴向从六个自由度里抽,有时只覆盖五个(重复一个、缺一个), 实体数与边数完全不变。 - 七配合的家族保持冗余件在最后,删它依然无害。 --- spatial/generator.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/spatial/generator.py b/spatial/generator.py index edcb453..62c24a7 100644 --- a/spatial/generator.py +++ b/spatial/generator.py @@ -144,15 +144,22 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): # nothing. Without it "something was removed" and "the target lost support" # are the same event on every sample, and a one-bit rule fits the whole # family -- measured: that rule scores 1.000 here while knowing no physics. + # the causal variable is drawn, not fixed. Until it was, "there is a contact" + # and "the contact carries load" were the same event inside the family, so a + # constant answer fit it and the model never had to look at geometry -- which + # is exactly what the report kept showing. + dx = rng.choice((-13, -6, 0, 3, 6, 13)) + dy = rng.choice((-9, 0, 0, 0, 9)) ents = [Entity("G", "ground", attrs={"plane": 0}), Entity("P", "block", attrs={"box": [40, 40, 0, 60, 60, 20]}), - Entity("T", "block", attrs={"box": [42, 42, 20, 58, 58, 36]}), + Entity("T", "block", attrs={"box": [42 + dx, 42 + dy, 20, 58 + dx, 58 + dy, 36]}), Entity("D", "block", attrs={"box": [80, 40, 0, 100, 60, 16]})] edges = [Edge("kPG", "contact", "P", "G"), Edge("kPT", "contact", "T", "P"), Edge("kDG", "contact", "D", "G")] top = None if n_blocks >= 3: - ents.append(Entity("U", "block", attrs={"box": [44, 44, 36, 56, 56, 48]})) + ents.append(Entity("U", "block", + attrs={"box": [44 + dx, 44 + dy, 36, 56 + dx, 56 + dy, 48]})) edges.append(Edge("kTU", "contact", "U", "T")) top = "U" vis_edges = {e.eid for e in edges} @@ -185,7 +192,19 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): def _build_freedom(rng, n_cons: int, hidden: int): - axes = list(DOF_AXES) + ["tz"] # a 7th constraint repeats tz: redundant + # the axes are drawn, so a family spans both verdicts with the same entity + # count: six mates that cover every axis lock the part, six that cover five + # do not, and the difference is invisible from the shape of the scene + axes = list(DOF_AXES) + if n_cons == 7: + rng.shuffle(axes) + axes = axes + [rng.choice(axes)] # a redundant 7th mate, last + else: + if rng.random() < 0.5: # drop one, repeat another + drop = rng.randrange(len(axes)) + dup = rng.choice([a for i, a in enumerate(axes) if i != drop]) + axes = [a for i, a in enumerate(axes) if i != drop] + [dup] + rng.shuffle(axes) ents = [Entity("P", "part", attrs={"x": 0, "y": 0, "z": 0})] edges, visible = [], set() for i in range(n_cons):