MIT's HardNet++ Enforces Nonlinear Constraints on Network Outputs
An MIT method corrects a neural network's output step by step until it satisfies nonlinear rules, with violations shrinking exponentially under standard assumptions.
TL;DR
- MIT researchers' HardNet++ adds a differentiable layer that repeatedly corrects a neural network's output until it satisfies nonlinear equality and inequality constraints [^1].
- In a control test, constraints held to high precision with little lost performance, though the guarantee holds only to a tolerance and under assumptions [^1].
Background
Neural networks are increasingly used as fast stand-ins for optimization solvers, for example in model predictive control, which repeatedly solves an optimization problem online [^1]. Their outputs often must obey hard rules, from conservation laws to safety bounds, but a standard network offers no such guarantee. Penalizing violations during training cannot ensure feasibility at inference, especially on unfamiliar inputs [^1]. Hard-constraint methods instead project the output onto the allowed set, but mostly for specific forms such as linear constraints [^1].
What happened
Andrea Goertzen, Kaveh Alim and Navid Azizan at MIT describe HardNet++ in a new paper [^1]. It extends HardNet, earlier work by Y. Min and Navid Azizan that projects outputs in closed form onto linear equality and inequality constraints while provably keeping the network's expressivity [^1]. For nonlinear rules no single closed-form projection exists, so HardNet++ works iteratively: at each step it linearizes the constraints around the current output and applies a closed-form correction. Prior iterative methods left gaps: ENFORCE handles nonlinear equality constraints but not inequalities, and many approaches lack convergence guarantees [^1].
The key change is a damping term. On curved constraints, HardNet's step stays parallel to boundaries that are already satisfied and can fail to reach a violated one; damping lets the step move across them [^1]. It also keeps the linear system solvable whatever the number of constraints and variables, and penalizes large steps where the linear approximation no longer holds. Each iteration is differentiable, so the layer stays active during training, and the network learns to produce outputs that are good after correction, not only before it [^1]. Under standard assumptions, including that a feasible point exists, the authors prove that constraint violation shrinks exponentially with the number of iterations, down to any chosen tolerance [^1].
The test is an illustrative model predictive control problem. A feed-forward network with two hidden layers of 200 neurons maps a starting state to a ten-step plan that must obey the system dynamics, limits on the control inputs and a quadratic bound on the state [^1]. The target state lies outside that bound, so the state can never reach it. With 500 correction iterations and 100 random starting conditions, the network's plans were 5.6e-3 worse than those of the CVXPY solver on average and 0.016 in the worst case. The quadratic constraint was violated by at most 9.5e-7, the dynamics and control limits by at most 3.6e-3 and 4.1e-3 [^1].
Why it matters
For learned solvers, feasibility decides whether they can be deployed at all: a fast network whose plan breaks a constraint is no substitute for the solver [^1]. HardNet++ handles nonlinear equality and inequality constraints together, which the authors say many existing methods cannot, and it comes with a convergence proof. In the test, the learned controller drove the state toward the edge of the allowed region, as the optimal solution does, without giving up much performance [^1].
The limits matter just as much. The guarantee is asymptotic: under smoothness and regularity assumptions, violations shrink toward zero, but after a finite number of iterations they stay small and nonzero, as the 3.6e-3 dynamics residual shows [^1]. The evidence is one small problem with five state variables and four inputs, and the authors leave larger control and learning problems to future work. The paper also reports no run times, so how 500 iterations per output compare with calling the solver directly remains open [^1].
Practical example
Say Noor's team controls heating in office buildings with model predictive control and wants a neural network to replace the solver on cheap hardware. The network outputs the next ten steps of heater settings, which must respect how the rooms respond, each heater's power limit and a curved bound on combined temperatures.
With only a training penalty, the network does well on the data it has seen. On an unusually cold morning, outside that data, nothing stops its plan from breaking a limit, because soft constraints cannot guarantee feasibility at inference [^1]. With HardNet++, the raw plan passes through the correction layer: linearize the constraints around the plan, take a damped step toward the allowed region, repeat. Since Noor's team trains with the layer switched on, the network learns plans that remain good after correction, as the paper's setup does [^1].
Noor still has decisions to make. The paper's run used a damping value of 0.3 and 500 iterations, and the residual violations, while tiny, were not zero: up to 3.6e-3 on the dynamics [^1]. So Noor's team sets its own tolerance, measures how long the 500 steps take on the target hardware, and keeps a final range check before any command reaches a heater.
Related gear
We recommend this text because it provides the mathematical foundation of neural architecture and optimization required to understand how HardNet++ modifies the learning process.