exp+test: #31 机制落库——门控地平线 select=pre --pre_near(远端短前瞻、近终段用整条地平线)
轮次 48 的曲线给出:时限收益随 h 缩短单调上升,而末态精度代价集中在 h<=4 ⇒ 假设病因是 "近终段没有终端代价"而不是"前瞻短"。本参数把两者分开:当前误差<=pre_near(mm) 时打分退回 整条地平线,远端保持 commit 窗口口径。代价多一次 goal_err(B×K 点),只在门控开启时发生。 单测按夹具手算:起点 e=900 ⇒ pre_near=950 必须在第一次规划就翻回 endpoint 的选择, pre_near=100/0 必须保持 pre 的选择(三条断言彼此可分,门控若没接上会直接红)。 52 项测试绿;ast 复核新局部名(qa_pre/qa_full/e_pre/e_full)未遮蔽任何 rollout 形参。 判读规则预注册写在 ml/runs/_r49_gate.sh 顶部:成立=err_success_med 回到 ~0.22mm 且 time_ok 保住 >=0.31;只满足一半则记为机理负结论。两个阈值(5/20mm)都报,不挑最好。
This commit is contained in:
+10
-2
@@ -987,7 +987,7 @@ class PreHorizonTest(unittest.TestCase):
|
||||
def gaps(self, q, cap):
|
||||
return {'gm': torch.ones(q.shape[0], 49)}
|
||||
|
||||
def run1(self, select, commit_n=2, pre_h=0):
|
||||
def run1(self, select, commit_n=2, pre_h=0, pre_near=0.0):
|
||||
# 候选0:前 2 步各 +0.2(前缀 0.4),随后 14 步 −0.4/14 ⇒ 地平线末端回到 0
|
||||
# 候选1:16 步各 +0.05 ⇒ 前缀只有 0.1,但地平线末端 0.8
|
||||
c0 = [0.2, 0.2] + [-(0.4 / 14.0)] * 14
|
||||
@@ -1000,7 +1000,7 @@ class PreHorizonTest(unittest.TestCase):
|
||||
patch('ml.sim.closed_loop.goal_err', side_effect=err):
|
||||
_, per = rollout(self.StubModel(acts), self.NearKin(), [{'q0': [0] * 6, 'T': [1, 0, 0]}], 'cpu',
|
||||
K=2, safety=False, max_sec=0.04, return_traj=True, use_sub=False,
|
||||
select=select, replan='empty', commit_n=commit_n, pre_h=pre_h)
|
||||
select=select, replan='empty', commit_n=commit_n, pre_h=pre_h, pre_near=pre_near)
|
||||
return per
|
||||
|
||||
def test_pre_and_endpoint_pick_opposite(self):
|
||||
@@ -1024,6 +1024,14 @@ class PreHorizonTest(unittest.TestCase):
|
||||
b = self.run1('pre', commit_n=2, pre_h=2)
|
||||
torch.testing.assert_close(a['traj'], b['traj'], rtol=0, atol=0)
|
||||
|
||||
def test_pre_near_gate_flips_only_inside_the_threshold(self):
|
||||
"""#31 的门控:夹具里"当前误差"= (0.9 − q0)·1000,起点 q0=0 ⇒ e=900。
|
||||
pre_near=950 ⇒ 第一次规划就在门内 ⇒ 必须退回 endpoint 的选择(0.06);
|
||||
pre_near=100 或 0 ⇒ 门外 ⇒ 保持 pre 的选择(0.24)。"""
|
||||
self.assertAlmostEqual(float(self.run1('pre', pre_near=950.0)['traj'][0, 1, 0]), 0.05 * 1.2, places=5)
|
||||
self.assertAlmostEqual(float(self.run1('pre', pre_near=100.0)['traj'][0, 1, 0]), 0.2 * 1.2, places=5)
|
||||
self.assertAlmostEqual(float(self.run1('pre', pre_near=0.0)['traj'][0, 1, 0]), 0.2 * 1.2, places=5)
|
||||
|
||||
def test_pre_equals_endpoint_when_commit_is_the_whole_horizon(self):
|
||||
"""不变式:commit_n=16 = 整条地平线 ⇒ pre 的索引落到末端,必须与 endpoint 选同一条。"""
|
||||
p = self.run1('pre', commit_n=16)
|
||||
|
||||
Reference in New Issue
Block a user