From 306b787aa7f44e6b94d61a43840201bf3b3f88ef Mon Sep 17 00:00:00 2001 From: yexiaozhou Date: Fri, 3 Apr 2026 00:43:40 +0800 Subject: [PATCH] fix(layout_optimizer): update arm_slider reach value and improve scene poll version handling --- unilabos/layout_optimizer/mock_checkers.py | 2 +- unilabos/layout_optimizer/optimizer.py | 4 +++- unilabos/layout_optimizer/static/lab3d.html | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/unilabos/layout_optimizer/mock_checkers.py b/unilabos/layout_optimizer/mock_checkers.py index d677a40c..67f80b19 100644 --- a/unilabos/layout_optimizer/mock_checkers.py +++ b/unilabos/layout_optimizer/mock_checkers.py @@ -78,7 +78,7 @@ class MockReachabilityChecker: "elite_cs66": 0.914, "elite_cs612": 1.304, "elite_cs620": 1.800, - "arm_slider": 1.07, # 线性导轨臂:body 2.14m × 0.35m,reach ≈ half length + "arm_slider": 0.3, # 线性导轨臂:1.07 body 2.14m × 0.35m,reach ≈ half length } # 未知型号回退臂展:realistic default for lab-scale arms diff --git a/unilabos/layout_optimizer/optimizer.py b/unilabos/layout_optimizer/optimizer.py index 9c1f33f2..cae38952 100644 --- a/unilabos/layout_optimizer/optimizer.py +++ b/unilabos/layout_optimizer/optimizer.py @@ -80,7 +80,7 @@ def _run_de( best_vector = init_pop[best_idx].copy() # Early stopping 跟踪 - patience = 20 + patience = 200 best_cost_history: list[float] = [best_cost] for gen in range(1, maxiter + 1): @@ -102,6 +102,8 @@ def _run_de( # 默认 currenttobest1bin:mutant = target + F*(best - target) + F*(r1 - r2) mutant = ( init_pop[i] + # add a scaled minimum to encourage exploration + + f_val * 0.1 * (upper - lower) * rng.uniform(-1, 1, size=ndim) + f_val * (best_vector - init_pop[i]) + f_val * (init_pop[r1] - init_pop[r2]) ) diff --git a/unilabos/layout_optimizer/static/lab3d.html b/unilabos/layout_optimizer/static/lab3d.html index f0f40eb4..48b8106b 100644 --- a/unilabos/layout_optimizer/static/lab3d.html +++ b/unilabos/layout_optimizer/static/lab3d.html @@ -1200,13 +1200,13 @@ loadDeviceCatalog().then(() => { }); /* ── Scene Poller (demo agent) ─────────────── */ -let _scenePollVersion = -1; // -1 = uninitialized, first poll sets baseline +let _scenePollVersion = 0; setInterval(async () => { try { const res = await fetch('/scene/placements'); if (!res.ok) return; const data = await res.json(); - if (_scenePollVersion === -1) { _scenePollVersion = data.version; return; } // baseline on first poll + if (data.version < _scenePollVersion) _scenePollVersion = 0; // server restart if (data.version <= _scenePollVersion) return; _scenePollVersion = data.version; const labW = parseFloat(document.getElementById('lab-w').value) || 4;