feat(spatial): 近贴合进训练——间隙族内抽 0 或 1-2,族级捷径失效

This commit is contained in:
liuhuajie committed 2026-12-03 23:55:43 +08:00
1 parent 1e862e577a
commit 6f6410554a
4 files changed
+58 -19

No files matched your search

+13 -5
View File
@@ -35,6 +35,7 @@ FAMILIES = {
"area.gap1": {"domain": "stability", "n_blocks": 2, "hidden": 0, "clearance": 1},
"area.gap2": {"domain": "stability", "n_blocks": 2, "hidden": 0, "clearance": 2},
"area.gap4": {"domain": "stability", "n_blocks": 2, "hidden": 0, "clearance": 4},
"area.near": {"domain": "stability", "n_blocks": 2, "hidden": 0, "near": 1},
"dof.c6": {"domain": "freedom", "n_cons": 6, "hidden": 0},
"dof.c6r": {"domain": "freedom", "n_cons": 7, "hidden": 0},
"dof.c6h": {"domain": "freedom", "n_cons": 6, "hidden": 1},
@@ -150,7 +151,7 @@ def _build_connection(rng, n_paths: int, hidden: int):
def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int = 0,
clearance: int = 0):
clearance: int = 0, near: int = 0):
if free:
# the minimal pair against area.sup2h: here T has exactly one contact and
# that contact leads to a block which itself hangs in the air. Nothing
@@ -181,7 +182,13 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int
# grid unit is 0.25mm). At 0 the two surfaces touch exactly; at 1 they are
# 0.25mm apart, which is the regime real assemblies live in and the regime a
# distance tolerance actually has to decide.
cl = int(clearance)
# ``near`` draws the clearance inside one family: 0 sometimes, 1-2 units
# otherwise. That is the whole point -- with a fixed clearance the family is
# single-answer (constant rules score 1.000) and with a per-family fixed
# clearance the model can key on the family instead of on contact. Here the
# same question, same scene, same edge count differ only in whether the two
# faces coincide, so the only thing that can separate them is contact.
cl = int(clearance) if not near else int(rng.choice((0, 0, 0, 1, 2)))
ents = [Entity("G", "ground", attrs={"plane": 0}),
Entity("P", "block", attrs={"box": [40, 40, 0, 60, 60, 20]}),
Entity("T", "block", attrs={"box": [42 + dx, 42 + dy, 20 + cl,
@@ -228,8 +235,8 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int
# that removes P, so "removed something" no longer implies "answer false"
query = Query(kind="stability", a="T")
r = rng.random()
if clearance:
return ents, edges, query, vis_edges, vis_ents, layers, ["front", "iso"], {"length": "mm", "per_unit": 1}
if clearance or near:
return ents, edges, query, vis_edges, vis_ents, layers, ["front", "iso"], {"length": "mm", "per_unit": 1}
if not hidden:
harmless = top or "D"
if r < 0.4:
@@ -300,7 +307,8 @@ _BUILDERS = {
"connection": lambda rng, spec: _build_connection(rng, spec["n_paths"], spec["hidden"]),
"stability": lambda rng, spec: _build_stability(rng, spec["n_blocks"], spec["hidden"],
spec.get("free", 0), spec.get("notch", 0),
spec.get("clearance", 0)),
spec.get("clearance", 0),
spec.get("near", 0)),
"freedom": lambda rng, spec: _build_freedom(rng, spec["n_cons"], spec["hidden"],
spec.get("no_edit", 0), spec.get("notch", 0)),
}