Finite-Candidate Neural Reference Shield
Source paper: Real-Time Reference Shaping for Servo Systems arXiv:2608.30825 ⓘ · analyzed Sep 1, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Place a deterministic reference-shaping layer after a neural policy or trajectory predictor. It minimizes deviation from the network command subject to nonlinear, state-dependent actuator and kinematic constraints, using KKT active-set candidates rather than iterative gradient projection. The layer should preserve the network command exactly in the interior of the feasible region and return the nearest feasible candidate when the command crosses a constraint boundary.
Formulas
Mathematical statement
Let $z\in\mathbb{R}^{m}$ be the unconstrained neural command, $r\in\mathbb{R}^{m}$ the shaped command, and $x$ the measured system state. Define the shaping problem as $\min_r \frac{1}{2}(r-z)^\top W(r-z)$ subject to inequality constraints $g_j(r,x)\leq0$, where $W\succ0$ is a weighting matrix and $j=1,\ldots,q$. For an active set $A\subseteq\{1,\ldots,q\}$, KKT candidates satisfy stationarity $W(r-z)+\sum_{j\in A}\lambda_j\nabla_r g_j(r,x)=0$, active equalities $g_j(r,x)=0$, inactive feasibility $g_j(r,x)\leq0$, and multipliers $\lambda_j\geq0$. The transferable construction is that the solution belongs to a finite set generated by these active-set/KKT candidates and can be recovered deterministically, with the remaining candidate calculation reducible to closed forms and a small eigenvalue problem. Select the feasible candidate with minimum objective value. The key property is exact feasibility, not merely a penalty-based approximation.
Implementation notes
1. Integration point: attach the layer between an NN policy or trajectory head and the low-level controller. The network emits $z_t$, while measured state $x_t$ supplies speed, position, current, voltage, and other quantities needed to evaluate state-dependent constraints. Encode current and voltage limits such as $i_d^2+i_q^2\leq I_{\max}^2$ and $u_d^2+u_q^2\leq V_{\mathrm{dq,max}}^2$, together with the paper's kinematic limits, as $g_j(r,x)\leq0$. 2. Pseudocode: evaluate every constraint; enumerate active sets permitted by command dimension; for each active set solve the stationarity and active-boundary equations using the paper's closed-form expressions or small eigenvalue construction; discard candidates with violated inactive constraints or negative multipliers; return the feasible candidate with minimum weighted distance to $z_t$. If none passes tolerances, use a conservative interior fallback. Initially stop gradients through the shield, then test implicit differentiation. 3. Computed versus estimated: constraint values, candidates, feasibility, and objective are computed analytically; model mismatch, noise margins, and tolerances are estimated empirically. 4. First cheap experiment: use a 2D MLP policy controlling a simulated PMSM or constrained point-mass servo. Compare raw output, penalty training, iterative projected-gradient projection, and this shield. Sweep command magnitude and measure violations, latency, and tracking error. The prediction is a sharp feasibility transition: interior commands satisfy $r^*=z$ up to tolerance, while exterior commands have zero violations and increasing residual beginning at the boundary. The solver should agree with a high-accuracy nonlinear optimizer within $10^{-5}$ and have nearly constant runtime; measured transition locations should match the analytically computed feasible boundary within 5%.
Verification
Mechanism evidence: Confirmed
Practical benchmark: Did not beat baseline
Stage 1 — Mechanism check agent confidence 9/10
Built a deterministic finite-candidate KKT shield for a 2D actuator set defined by disk and box constraints, with projected repair and SLSQP references. The mechanism manifested: interior commands were preserved exactly, the measured transition was 1.01 versus the predicted 1.00, radius-transition slope was 1.00 versus predicted 1.00, maximum violation was 6.7e-16, and maximum error versus SLSQP was 2.7e-8. The shield was faster than iterative repair in this toy test, at 0.72 ms versus 6.57 ms per command, with slightly smaller command deviation.
- Agent confidence
- 9/10
- Baseline
- Projected repair: mean violation 1.67e-17, mean distance 0.6012, 6.57 ms/command; raw mean violation 1.6688.
- Idea
- Finite-candidate shield: mean violation 5.16e-17, mean distance 0.5934, 0.72 ms/command; interior maximum error 0, transition 1.01 versus 1.00 predicted, radius slope 1.00 versus 1.00 predicted, maximum SLSQP error 2.71e-8.
Limitations: Only a convex 2D disk-and-box actuator region was tested. General nonconvex nonlinear constraints, higher-dimensional active-set enumeration, neural-policy training, state noise, model mismatch, and GPU execution were not tested.
How to run: python3 shield_experiment.py
Stage 2 — Benchmark vs. tuned baseline
Significantly WORSE than the tuned baseline (+8150.0%, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0006
- Idea mean
- 0.0524
- Effect (Δ)
- 0.0518 (+8150.0%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Hurts
- Baseline tuning
- swept over 3 configs
Only the built-in dynamics task and a scalar interval shield were tested; general higher-dimensional nonlinear active sets, state-dependent constraints, implicit differentiation, noisy or mismatched dynamics, and deployment latency were not evaluated.
How to run: python3 stage2_bench.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 10/10
Built an end-to-end finite-candidate interval KKT shield around the shared rnn_small dynamics model and ran 8 paired seeds with baseline and idea learning-rate sweeps. The mechanism signature held quantitatively: interior identity error 0, maximum constraint violation 0, and 72% of trained test outputs interior. However, the shielded system had much worse test MSE, 0.05243537 versus 0.000635578 for baseline, with paired delta +0.05179979 and permutation p=0.0081; it was a significant loss.
- Baseline
- dynamics/rnn_small, best lr=0.005: mean test MSE 0.0006355784, std 0.0001856246
- Idea
- Finite-candidate interval shield, best lr=0.005: mean test MSE 0.0524353655, std 0.0088831963; paired delta +0.0517997871, p=0.0081, idea wins 0/8
Benchmark result
Significantly WORSE than the tuned baseline (+8150.0%, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0006
- Idea mean
- 0.0524
- Effect (Δ)
- 0.0518 (+8150.0%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Hurts
- Baseline tuning
- swept over 3 configs
Only the built-in dynamics task and a scalar interval shield were tested; general higher-dimensional nonlinear active sets, state-dependent constraints, implicit differentiation, noisy or mismatched dynamics, and deployment latency were not evaluated.
How to run: python3 stage2_bench.py
Artifacts
- bench_report.json 5.2 KB View Raw JSON
- report.md 1.4 KB View
- report_bench_2026-09-01T235711.md 3.6 KB View
- results.json 0.8 KB View Raw JSON
- shield_experiment.py 5.9 KB View Raw JSON
- stage2_bench.py 5.5 KB View Raw JSON