{
 "artifacts": [
  {
   "name": "bench_report.json",
   "url": "https://synthcore.org/code/1076/bench_report.json"
  },
  {
   "name": "report.md",
   "url": "https://synthcore.org/code/1076/report.md"
  },
  {
   "name": "report_bench_2026-09-01T235711.md",
   "url": "https://synthcore.org/code/1076/report_bench_2026-09-01T235711.md"
  },
  {
   "name": "results.json",
   "url": "https://synthcore.org/code/1076/results.json"
  },
  {
   "name": "shield_experiment.py",
   "url": "https://synthcore.org/code/1076/shield_experiment.py"
  },
  {
   "name": "stage2_bench.py",
   "url": "https://synthcore.org/code/1076/stage2_bench.py"
  }
 ],
 "category": "dynamics",
 "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.",
 "download_zip": "https://synthcore.org/download/1076",
 "formulas_latex": [
  "$$r^*(x,z)=\\arg\\min_{r}\\;\\frac{1}{2}(r-z)^\\top W(r-z)\\quad\\mathrm{s.t.}\\quad g_j(r,x)\\leq0,\\;j=1,\\ldots,q,$$",
  "$$W(r-z)+\\sum_{j\\in A}\\lambda_j\\nabla_r g_j(r,x)=0,\\qquad g_j(r,x)=0\\;(j\\in A),\\qquad g_j(r,x)\\leq0\\;(j\\notin A),\\qquad \\lambda_j\\geq0,$$",
  "$$r^*=\\mathop{\\arg\\min}_{(r_A,\\lambda_A)\\in\\mathcal{C}(x,z)}\\frac{1}{2}(r_A-z)^\\top W(r_A-z),$$"
 ],
 "id": 2906,
 "implementation": "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%.",
 "math_summary": "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.",
 "math_tags": [
  "optimization",
  "control-theory",
  "linear-algebra",
  "dynamical-systems"
 ],
 "ml_areas": [
  "rl",
  "optimizer",
  "world-model"
 ],
 "paper": {
  "arxiv_id": "2608.30825",
  "arxiv_url": "https://arxiv.org/abs/2608.30825",
  "summary_what_math_gives_to_ml": "The paper offers a constructive real-time optimization mechanism for nonlinear, state-dependent actuator constraints: KKT conditions reduce the global reference-shaping problem to a finite set of candidate points, which can be evaluated deterministically using closed-form expressions and a small eigenvalue problem. This is transferable as a neural-network output shield or reference layer that converts an unconstrained policy prediction into the closest feasible command without iterative projection or backpropagated optimization. The accompanying compensator suggests a second mechanism for correcting accumulated position mismatch caused by aggressive but feasible commands while retaining constraint feasibility. The strongest near-term test is whether the finite-candidate layer maintains feasibility at high control rates and exhibits a predictable transition from exact tracking to constrained tracking as the requested NN command crosses the feasible boundary.",
  "title": "Real-Time Reference Shaping for Servo Systems",
  "year": "2026"
 },
 "ratings": {
  "difficulty": 6,
  "novelty": 6,
  "usefulness": 8
 },
 "solves": [
  "stability",
  "accuracy",
  "speedup"
 ],
 "title": "Finite-Candidate Neural Reference Shield",
 "url": "https://synthcore.org/idea/2906/finite-candidate-neural-reference-shield",
 "verification": {
  "benchmark": {
   "track": "dynamics",
   "model": "rnn_small",
   "n_seeds": 8,
   "metric_direction": "lower is better",
   "comparison": {
    "baseline_mean": 0.0006355784062179737,
    "idea_mean": 0.05243536550551653,
    "delta_mean": 0.051799787099298555,
    "per_seed_diffs": [
     0.040515612345188856,
     0.057474047353025526,
     0.053591572504956275,
     0.0673817700590007,
     0.054870439402293414,
     0.03763687366154045,
     0.05263327300781384,
     0.05029470846056938
    ],
    "idea_wins": 0,
    "n_pairs": 8,
    "p_value": 0.0081,
    "mde": 0,
    "mde_rel_pct": null,
    "verdict": "idea worse (significant)",
    "system_worked": false
   },
   "baseline": {
    "best_cfg": {
     "lr": 0.005
    },
    "sweep": [
     {
      "cfg": {
       "lr": 0.001
      },
      "mean": 0.0014035784406587481
     },
     {
      "cfg": {
       "lr": 0.003
      },
      "mean": 0.000857145045301877
     },
     {
      "cfg": {
       "lr": 0.005
      },
      "mean": 0.000637838282273151
     }
    ],
    "full": {
     "mean": 0.0006355784062179737,
     "std": 0.00018562462201799073,
     "per_seed": [
      0.0005684797652065754,
      0.0006359252729453146,
      0.0004176601651124656,
      0.0009292879258282483,
      0.0004875308950431645,
      0.0004790188977494836,
      0.0006295977509580553,
      0.0009371265769004822
     ],
     "n": 8
    }
   },
   "idea": {
    "mean": 0.05243536550551653,
    "std": 0.008883196341761043,
    "per_seed": [
     0.04108409211039543,
     0.05810997262597084,
     0.05400923267006874,
     0.06831105798482895,
     0.05535797029733658,
     0.03811589255928993,
     0.053262870758771896,
     0.051231835037469864
    ],
    "n": 8
   },
   "mechanism_signature": {
    "bound": 1,
    "confirmed": true,
    "interior_fraction": 0.72,
    "interior_identity_max_error": 0,
    "math_check": {
     "interior_identity_max_error": 0,
     "max_constraint_violation": 3.3306690737504697e-16,
     "max_error_vs_slsqp": 1.8546459140785727e-8,
     "n_reference": 90
    },
    "max_constraint_violation": 0,
    "mean_shaping_distance": 0.08201595395803452,
    "n_test": 400,
    "predicted_interior_error": 0,
    "predicted_max_violation": 0
   },
   "custom_track": null
  },
  "mechanism_confirmed": true,
  "peer_reviewed": false,
  "practical_verdict": "harms",
  "stage1_mechanism_check": {
   "worked": true,
   "confidence": 9,
   "verdict": "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.",
   "metrics": {
    "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."
   },
   "how_to_run": "python3 shield_experiment.py",
   "files": [
    "shield_experiment.py",
    "results.json"
   ],
   "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."
  },
  "status": "mech_ok_no_baseline",
  "status_label": "Mechanism confirmed, baseline not beaten",
  "updated_at": "2026-09-01T23:57:11",
  "verdict_source": "deterministic test code (paired-seed permutation statistics)"
 }
}
