△ Mechanism confirmed, baseline not beaten 2026

Legendre Feasibility Layer

Implementation & benchmark of arXiv:2607.24007 — Smooth Learning with Hard Constraints via Legendre-Regularized Policies

Usefulness8/10
Difficulty5/10
Novelty6/10

Source paper: Smooth Learning with Hard Constraints via Legendre-Regularized Policies arXiv:2607.24007 ⓘ · analyzed Aug 30, 2026

AI-generated research hypothesis, automatically tested. Not peer-reviewed.

Idea description

Replace an unconstrained neural decision head followed by clipping, projection, or penalty losses with a Legendre-regularized optimizer layer that always returns a feasible decision. The layer maps network-produced latent scores smoothly into the relative interior of a convex feasible region and can be differentiated using the inverse Hessian of the regularizer.

Formulas

$$\min_{\pi\in\Pi}\mathbb{E}_{(x,\xi)}\ell(\pi(x);\xi),\qquad \pi(x)\in S$$
$$T_\varepsilon(z)=\arg\min_{w\in S}\left\{\langle z,w\rangle+\varepsilon h(w)\right\},\qquad \varepsilon>0$$
$$z+\varepsilon\nabla h(w)=0,\qquad \frac{\partial T_\varepsilon(z)}{\partial z}=-\frac{1}{\varepsilon}\left[\nabla^2h(T_\varepsilon(z))\right]^{-1}$$
$$h(w)=-\sum_{r=1}^{m}\log\left(b_r-a_r^\top w\right),\qquad \nabla^2h(w)=\sum_{r=1}^{m}\frac{a_ra_r^\top}{(b_r-a_r^\top w)^2}$$

Mathematical statement

The paper formulates contextual policy learning as $\min_{\pi\in\Pi}\mathbb{E}_{(x,\xi)}\ell(\pi(x);\xi)$, where $x\in\mathbb{R}^{k_1}$ is context, $\xi\in\mathbb{R}^{k_2}$ is an uncertain downstream parameter, $S\subseteq\mathbb{R}^n$ is the deterministic feasible set, and $\pi(x)\in S$. Its construction uses a Legendre regularizer $h:S\to\mathbb{R}$ and defines the optimizer map $T_\varepsilon(z)=\arg\min_{w\in S}\{\langle z,w\rangle+\varepsilon h(w)\}$, with latent score $z\in\mathbb{R}^n$ and regularization strength $\varepsilon>0$. For strictly convex twice-differentiable $h$ and $w=T_\varepsilon(z)$ in the relative interior of $S$, first-order optimality gives $z+\varepsilon\nabla h(w)=0$, and implicit differentiation gives $\partial w/\partial z=-\varepsilon^{-1}[\nabla^2h(w)]^{-1}$. The Legendre property makes $T_\varepsilon$ single-valued, smooth, and onto the relative interior; equivalently, $T_\varepsilon(z)=\nabla h^*(-z/\varepsilon)$, where $h^*$ is the convex conjugate. For a polytope $S=\{w:Aw\le b\}$, use the concrete barrier $h(w)=-\sum_r\log(b_r-a_r^\top w)$, where $a_r^\top$ is row $r$ of $A$ and $b_r-a_r^\top w$ is its slack. Its Hessian is $\nabla^2h(w)=\sum_r a_ra_r^\top/(b_r-a_r^\top w)^2$.

Implementation notes

(1) Integration point: attach the layer immediately after a context encoder $z=f_\theta(x)$ and before the downstream decision loss. Store the fixed constraint matrix $A\in\mathbb{R}^{m\times n}$ and vector $b$ for $S=\{w:Aw<b\}$. Replace penalty terms, post-hoc clipping, or nondifferentiable Euclidean projection. The component is suitable for supervised prescriptive learning, constrained policy networks, and RL actors whose action must satisfy budgets or resource limits.

(2) Pseudocode:

z = encoder_theta(x)
w = initialize_strictly_feasible(A, b)
for t in 1..NewtonSteps:
    slack = b - A @ w
    g = z - eps * sum_rows(A / slack[:,None], axis=0)
    H = eps * A.T @ diag(1 / slack**2) @ A
    delta = solve(H + damping*I, g)
    alpha = largest_backtracking_step(w, delta, A, b)
    w = w - alpha * delta
return w

The gradient $g$ is the gradient of $\langle z,w\rangle+\varepsilon h(w)$ and $H$ is $\varepsilon\nabla^2h(w)$. During backward, either differentiate the unrolled Newton iterations or use the implicit Jacobian $J=-H^{-1}$; for upstream gradient $u=\partial L/\partial w$, return $\partial L/\partial z=J^\top u$. Add damping only to stabilize nearly singular systems.

(3) Computed from the mathematics: strict feasibility, barrier gradient and Hessian, Newton updates, backtracking, and the inverse-Hessian Jacobian. Estimated empirically: Newton iteration count, damping, backtracking factor, and the schedule for $\varepsilon$. Start with $\varepsilon=0.1$ and optionally anneal toward $0.01$; monitor the minimum slack because small $\varepsilon$ can create ill-conditioning. For simplex constraints, use the exact entropy form $h(w)=\sum_iw_i\log w_i$, which gives $T_\varepsilon(z)_i=\exp(-z_i/\varepsilon)/\sum_j\exp(-z_j/\varepsilon)$, as a correctness baseline. For equality constraints $Cw=d$, solve Newton systems in KKT form with matrix $\begin{bmatrix}H&C^\top\\C&0\end{bmatrix}$.

(4) First cheap experiment: use a 2-layer MLP on synthetic contextual resource allocation with $w\in\mathbb{R}^{20}$, constraints $w\ge0$, $\sum_iw_i=1$, and five additional linear capacity constraints. Train against a random linear-plus-quadratic downstream cost. Compare an unconstrained output plus penalty, Euclidean projection, and this Legendre layer at equal hidden size and optimizer. Measure constraint violations, downstream cost, gradient norms near active constraints, convergence steps, and wall-clock time. Success means zero violations up to numerical tolerance, smoother loss and gradient curves than projection, and lower test downstream cost at equal training steps; a useful target is at least 10% lower cost than the penalty baseline without degradation relative to projection.

Verification

Mechanism confirmed, baseline not beaten

Stage 1 · Toy mechanism gate: Passed ✓

Stage 2 · Mechanism transferred to benchmark: Confirmed ✓

Stage 2 · Practical benchmark result: Significantly worse ✗

Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works

Stage 1 — Mechanism check agent confidence 8/10

Built a differentiable Legendre feasibility layer using entropy on the simplex plus logarithmic capacity barriers, with unrolled KKT Newton updates and feasibility-preserving backtracking. The mechanism manifested: Jacobian gain matched the predicted 1/(n epsilon) scaling to 1.6e-16 relative error, simplex log-ratios matched the predicted 1/epsilon law below 1e-15 absolute error, and score/epsilon equivariance was below 9e-18. In the toy comparison, the layer had slightly lower test MSE (0.0009941 vs 0.0010142, about 2.0% better) and zero violations, but required 16.7 seconds versus 0.71 seconds for the penalty model, so the practical speed win was absent.

Agent confidence
8/10
Baseline
Penalty softmax: test MSE 0.00101421, max capacity violation 0, minimum slack 0.5726, runtime 0.708 s
Idea
Legendre barrier: test MSE 0.00099408, max capacity violation 0, minimum slack 0.5740, runtime 16.67 s; math checks: Jacobian relative error 1.6e-16, log-ratio absolute error <=8.9e-16, equivariance max error 8.7e-18

Limitations: The main mechanism checks use the exact simplex entropy map rather than independently solving the general barrier problem. The comparison used a small synthetic dataset, softmax penalty baseline, unrolled Newton differentiation rather than a custom implicit backward, one seed, and relatively loose capacity constraints; Euclidean projection and active/near-boundary stress tests were not evaluated.

How to run: python3 legendre_experiment.py

Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.24007)

Significantly WORSE than the tuned baseline (+27.3%, p=0.0081, wins 0 / 8 paired seeds).

Benchmark
Directional polytope
Model
mlp_tiny
Paired seeds
8
Baseline mean
0.001
Idea mean
0
Effect (Δ)
0.0003 (+27.3%; negative = idea better)
Wins
0 / 8 paired seeds
p-value
0.0081 (permutation test, 20 000 shuffles)
Smallest detectable effect
±12.3%
Mechanism
Confirmed ✓
Practical effect
Hurts
Baseline tuning
swept over 9 configs
Limitations:

The benchmark used the registered directional_polytope geometry track and a box specialization of the polytope barrier rather than the full equality-constrained simplex-plus-capacity formulation. It did not test vision, sequence, dynamics, Euclidean projection, or a custom newly registered track.

How to run: python3 bench_legendre.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

Implemented and benchmarked the Legendre feasibility head on the registered directional_polytope track using identical end-to-end mlp_tiny systems. The mechanism signature was quantitatively confirmed with maximum relative Jacobian error 1.46e-7, but the idea was significantly worse than the tuned baseline: test MSE 0.0012857 versus 0.0010100, paired delta +0.0002757, permutation p=0.0081. The feasibility mechanism works mathematically, but it did not transfer to a task-metric win under this protocol.

Baseline
directional_polytope / mlp_tiny; tuned lr=0.03, penalty=0.0; 8-seed test MSE mean 0.0010100425 ± 0.0001477102
Idea
Legendre box barrier; lr=0.03, eps=0.2; 8-seed test MSE mean 0.0012857039 ± 0.0000905600; paired delta +0.0002756614; permutation p=0.0081; significantly worse

Benchmark result

Significantly WORSE than the tuned baseline (+27.3%, p=0.0081, wins 0 / 8 paired seeds).

Benchmark
Directional polytope
Model
mlp_tiny
Paired seeds
8
Baseline mean
0.001
Idea mean
0
Effect (Δ)
0.0003 (+27.3%; negative = idea better)
Wins
0 / 8 paired seeds
p-value
0.0081 (permutation test, 20 000 shuffles)
Smallest detectable effect
±12.3%
Mechanism
Confirmed ✓
Practical effect
Hurts
Baseline tuning
swept over 9 configs
Limitations:

The benchmark used the registered directional_polytope geometry track and a box specialization of the polytope barrier rather than the full equality-constrained simplex-plus-capacity formulation. It did not test vision, sequence, dynamics, Euclidean projection, or a custom newly registered track.

How to run: python3 bench_legendre.py

Artifacts

Implementation overview ⬇ Download all as ZIP 6 files · code, reports and structured results