Hard constraints that change with the state
Control policies can be trained to violate constraints less often. Some problems require every output to satisfy them. A robot action, a process-control input, or the action returned by an RL policy may need to satisfy a set of affine inequalities that changes with the state at each inference step:
The allowable output depends on the current state . During obstacle avoidance, the set of safe control actions changes as the robot moves. A penalty loss can reduce violations without ruling them out. An optimization layer can correct a proposed output, though it may need an iterative solve on every forward pass.
CAffNet builds the affine constraints into the output architecture. If a feasible output exists, it guarantees constraint satisfaction for an arbitrary number of input-dependent affine constraints. The constraint matrix need not have full row rank, a useful distinction from earlier hard-constraint architectures. The guarantee covers the supplied constraints; physical closed-loop safety requires further conditions.
Limits of fixed projection
An earlier approach to hard constraints is to let a network propose an unconstrained output and then use linear projection to bring it to a constraint boundary or feasible set. The correction is explicit: an infeasible point is replaced with a feasible one.
A fixed projection rule makes a task decision from geometry alone. Suppose a safety boundary fixes one component of a control input while leaving another free. Orthogonal projection retains or changes the free component according to its fixed formula. It does not account for goal tracking, energy use, or room for a future maneuver. The correction can remove a violation while discarding freedom that would be useful for the task.
Input-dependent constraints bring another limitation. Earlier affine hard-constraint architectures such as HardNet-Aff require structural conditions, including full row rank of the constraint matrix and a condition on the number of constraints. Actual feasible action sets can contain redundant or dependent constraints, and a low-dimensional action can be enclosed by many inequalities. These are common configurations for polytopes.
CAffNet aims to enforce constraints without requiring full row rank or a small constraint count, while retaining a learnable direction along each candidate face.
A triangular feasible set
Consider a network that outputs two values, , subject to the following constraints:
The outputs satisfying these inequalities form a triangle. An ordinary network can propose a point outside it. A soft constraint penalizes such an output in the loss, but a large penalty still does not rule out violations at inference time.
CAffNet processes the output as follows:
The network first proposes . If this output lies outside the allowable region, the CAffNet layer returns a point inside it. Assuming a nonempty feasible set, the final output satisfies the supplied affine constraints by construction.
A boundary can contain many feasible points. A different point on the same boundary may serve the task better than the one chosen by a fixed geometric projection. A robot might be safe at both points yet move efficiently toward its goal at only one of them. CAffNet’s trainable null-space term learns along directions that preserve the active equality constraints. Within this freedom, it can learn both how to correct an infeasible proposal and where on a face to place the corrected output.
Many inequalities need not all be active at once. A point on the boundary of a two-dimensional polygon usually lies on one edge or at a vertex where two edges meet. CAffNet constructs candidates from small constraint subsets, tests them against the full constraint set, and selects a feasible candidate. Combining input-dependent constraints, active-set candidates with fewer rank restrictions, and a trainable null-space direction distinguishes this construction from fixed projection.
Constructing candidates on polyhedral faces
Let be a subset of constraints, with corresponding rows and . CAffNet constructs a candidate for each subset:
The first two terms project the nominal network output onto the equality face . The last term lies in the null space of , allowing movement along the face while preserving its equality constraints. A second network learns how to use that freedom through the task loss.
Consider the equality . A fixed orthogonal projection maps to , although every point satisfies the equality. CAffNet can learn a value of that serves the task while keeping the output feasible.
Each candidate is checked against all inequalities. If the nominal output is feasible, the architecture returns it unchanged. Otherwise, it selects the closest feasible candidate. All constraint subsets with cardinality up to the output dimension are enumerated, giving the following candidate count:
A projection onto a polyhedron lies on a face described by linearly independent active constraints. At most such constraints are needed, which explains the subset size limit. Enumerating those active sets carries a computational cost even though inference requires no iterative solver.
The feasibility theorem and its assumptions
Assume that the following polyhedron is nonempty for every input:
The paper establishes that at least one enumerated face candidate is feasible. Selecting from the feasible candidates gives
This theorem is the paper’s strongest result: it guarantees constraint satisfaction at inference time, beyond the empirical reduction in violations obtained with a penalty. Its scope depends on the supplied model. A controller using estimated constraints and guarantees only . The true plant constraints may still be violated if the model is wrong, a constraint is missing, or the deployment state falls outside the modeled regime.
The paper also claims that universal approximation is preserved for feasible targets when the underlying unconstrained network class is universal. The claim is plausible, though the appendix proof leaves gaps. It compares against a selected boundary candidate as if that candidate were already feasible. Satisfying one face’s equality does not ensure that the remaining inequalities hold. The proof also moves from an approximation statement to a pointwise inequality without establishing the additional conditions needed for that step. These gaps do not refute the feasibility theorem, but they leave the universal-approximation argument less complete than the hard-feasibility result.
Applying the layer to control barrier constraints
Control Barrier Functions (CBFs) often produce constraints affine in the control input :
Rearranging this inequality puts it in the form accepted by CAffNet. The policy proposes an action, and the output layer returns one satisfying the modeled CBF inequality. This lets the constraint layer serve as a safety filter for the learned policy.
Physical closed-loop safety requires the dynamics, barrier function, safe initial condition, and sampled-data implementation to satisfy their respective assumptions. CBF feasibility alone is insufficient. Near an obstacle, actuator limits may leave no input satisfying both the CBF and hardware constraints. CAffNet assumes a nonempty feasible action set even at states where an actual controller may have no feasible action.
The cost of active-set enumeration
In the paper’s small solver-learning experiment, CAffNet-FF takes roughly 1,325 ms per epoch, compared with 4.27 ms for an unconstrained neural network. This is a substantial training-time gap. CAffNet-Lite reduces the enumeration, though the full method’s general feasibility proof does not automatically extend to every rule that restricts the enumerated subsets.
The reported results include zero constraint violation in toy regression, a feasible optimizer in a low-dimensional learning problem, and collision-free behavior in one unicycle-control demonstration. Evidence for broader accuracy, efficiency, or suitability for high-dimensional real-time control remains limited. In the solver-learning experiment, the Transformer variant has a much worse objective value than the feed-forward model. The control evaluation is also too narrow to establish how safety generalizes.
CAffNet provides a neural output layer that enforces known input-dependent affine constraints. Constructing candidates on active faces and learning the null-space freedom are useful ideas. Its safety guarantee depends on a correct constraint model and a nonempty feasible set. Model uncertainty, discretization, missing hazards, and computational scaling remain separate problems.
Reference
Yang Zhao, Jungeun Lee, Jeong Hwan Jeon, and Sze Zheng Yong. CAffNet: Hard Constraint-Affine Neural Networks. ICML, 2026.