CAffNet: Hard Constraint-Affine Neural Networks

Yang Zhao, Jungeun Lee, Jeong hwan Jeon, Sze Zheng Yong · 2026

Read CAffNet: Hard Constraint-Affine Neural Networks by Yang Zhao, Jungeun Lee, Jeong hwan Jeon, Sze Zheng Yong (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-24437.txt.

Introduction

Zhao and three co-authors present CAffNet, building hard constraint rules into feed networks and text models with input-set affine constraints of any size. Soft constraints give no rule promise, while post-fixing after training can yield weak results. The team adds a learned constraint-affine layer beyond fixed square or side maps, tuning jointly with network weights. The build sets no limits on constraint-space sizes, preserves full rule powers, and promises constraint keeping for every input. Tests across domains needing promised rules show robust scores.

Catalog record

CREATORYang Zhao, Jungeun Lee, Jeong hwan Jeon, Sze Zheng Yong
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE59803
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2605.24437

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

CAffNet: Hard Constraint-Affine Neural Networks Yang Zhao, Jungeun Lee, Jeong hwan Jeon, Sze Zheng Yong Abstract We present a novel framework for embedding hard constraint satisfaction into neural network (NN) architectures, specifically feedforward neural networks and transformers, with input-dependent affine constraints of arbitrary cardinality. Traditional constraint enforcement approaches either rely on penalty-based soft constraints, which offer no guarantee of satisfaction, or on post-processing methods that enforce constraints after the NN is trained, which may lead to suboptimality. We introduce a trainable constraint-affine (CAffine) layer into NNs, yielding CAffNet, which goes beyond enforcing affine constraints via fixed orthogonal or parallel projections and enables joint optimization with network parameters. Moreover, we impose no restrictions on the constraint space dimensions and establish that our construction preserves the universal approximation properties of NNs, while providing provable guarantees on constraint adherence for all inputs. Experimental validation demonstrates robust performance across diverse domains requiring guaranteed constraint satisfaction. 1 Introduction Table 1 : Comparison of methods enforcing input-dependent constraints on neural networks for the target function y=f(x)\in\mathbb{R}^{n_{\textup{out}}} , based on the more detailed comparison in ( 15 , Table 1) . Our proposed CAffNet guarantees hard constraint satisfaction with a closed-form framework that preserves the universal approximation property for an arbitrary number of input-dependent affine inequality constraints * ‣ 1 . Method Constraint Support Satisfaction Computation Universal Eq./Ineq. Guarantee Approx. Soft-Constrained Any Both No Closed-Form Yes POLICE ( 2 ) y=Ax+b\;\;\forall x\in R Eq. Only Always Closed-Form Unknown KKT-hPINN ( 5 ) Ax+By=b (# constraints \leq n_{\textup{out}} ) Eq. Only Always Closed-Form Unknown ACnet ( 3 ) h(x,y)=0 (# constraints \leq n_{\textup{out}} ) Eq. Only Always Closed-Form Unknown DC3 ( 7 ) g(x,y)\leq 0,h(x,y)=0 Both Asymptotic Iterative Unknown FSNet ( 18 ) g(x,y)\leq 0,h(x,y)=0 Both Asymptotic Iterative Unknown HardNet-Aff ( 15 ) b^{l}(x)\!\leq\!A(x)y\!\leq\!b^{u}(x) (# constraints \!\leq\!2n_{\textup{out}} ) Both Always Closed-Form Yes CAffNet (Ours) A(x)y\leq b(x) (arbitrary # constraints) Both Always Closed-Form Yes Neural networks have demonstrated remarkable capability in approximating complex nonlinear functions in high-dimensional spaces, making them attractive for a wide range of applications ( 6 ; 10 ) . In safety-critical domains such as autonomous vehicles, robotics, and aerospace systems, this expressive power enables learned controllers that can adapt to complex dynamics and uncertainties ( 12 ; 4 ; 8 ) . However, ensuring that these learned controllers provide formal constraint satisfaction still remains a significant challenge ( 4 ; 13 ) . A common approach to mitigate this issue is to incorporate soft constraints by adding a penalty term to the training objective, encouraging the network to produce safe outputs. While penalty-based methods can work well empirically, they generally do not provide hard safety guarantees, especially with limited training data or when encountering out-of-distribution edge cases at deployment ( 14 ; 11 ; 15 ) . In contrast, hard-constrained methods were studied by enforcing the network output within the safe region. Frerix et al. ( 9 ) enforce homogeneous linear inequality constraints Ax\leq 0 by converting the feasible set from an H-representation to a V-representation of a polyhedral cone, and then restricting the network output to a combination of its rays via a constraint layer. However, this approach relies on the homogeneity of the constraints, and the hyperplane-to-vertex conversion can become computationally expensive as the output dimension and the number of constraints grow. In addition, C-DGMs ( 22 ) add a differentiable constraints layer that incrementally adjusts each output element by computing the corresponding greatest lower bound and least upper bound, and clamping the value into this interval, working for a more general type of (affine) constraints Ax\leq b . Moreover, RAYEN ( 23 ) can satisfy different kinds of constraints, such as linear, quadratic, second-order cone, and linear matrix inequality, by adjusting the output vector length from the interior point of the feasible region. However, these methods are only applicable when the constraints are input-independent. Moving beyond input-independent constraints, recent work has begun to study hard constraint enforcement when the feasible set varies with the input (cf. Table 1 ). For input-dependent equality constraints, POLICE ( 2 ) provably enforces the output to be an affine function of the input within a convex region by modifying layer parameters based on its vertices, while KKT-hPINN ( 5 ) enforces hard linear equality constraints by inserting projection layers derived from KKT conditions, and ACnet ( 3 ) reformulates input-output nonlinear equality constraints to affine equality constraints. On the other hand, for the more general case with input-dependent inequality constraints, DC3 ( 7 ) uses a differentiable procedure to satisfy equality constraints and unrolls gradient-based corrections for inequality constraints. However, the approach relies on iterative optimization, whose convergence and runtime can vary across problem instances and hyperparameter settings. A similar problem also arises in FSNet ( 18 ) , which solves an unconstrained optimization problem to minimize constraint violations iteratively. While this iterative procedure asymptotically drives violations toward zero, exact feasibility generally depends on running a sufficient number of iterations and meeting a tolerance. (a) HardNet projection. (b) CAffNet projection. Figure 1 : Comparison of the projection results between HardNet ( 15 ) and the proposed CAffNet in the presence of linearly dependent constraints, where HardNet projects outside of the feasible region while CAffNet finds a feasible projection. Furthermore, projection-based methods onto a single (hard) constraint with closed-form expressions have been studied ( 11 ; 16 ) . It was then extended to multiple constraints by HardNet-Aff ( 15 ) , which projects the output of neural networks into the safe region of input-dependent affine constraints by adding correction terms to the output. However, it assumes that A(x) has full row rank. This requirement leads to two main limitations. One is that the number of (two-sided) constraints cannot exceed the input dimensions, which is restrictive in real-world applications. Another limitation is that it cannot be applied to linearly dependent constraints (cf. Fig. 1(a) ), where the projection may fall outside the feasible region. In contrast, our proposed CAffNet method addresses this issue as shown in Fig. 1(b) . Moreover, when A(x) is not full column rank, the projection solution may not be unique, which is not considered in HardNet. For example, \{(x,y)\in\mathbb{R}^{2}\mid[0,1][x,y]^{\top}\leq[0,0]^{\top}\} has infinitely many solutions as the line of y=0 satisfies the constraints. While HardNet only projects onto a specific point on this line, our proposed CAffNet introduces an additional trainable term to find the optimal projection onto this entire line instead of simply using orthogonal or parallel projection. A comparison of related input-dependent methods is summarized in Table 1 . More comparisons with input-independent methods can be found in ( 15 , Table 1) . Noting the above limitations, we propose CAffNet, which combines a constraint-affine ( CAff ine) layer with neural net works, to address these issues by introducing a constraint decomposition method and a trainable projection module to handle an arbitrary number of constraints with provable feasibility guarantees and universal approximation property. The main contributions of this paper are as follows: 1. Closed-form hard constraint enforcement. We propose CAffNet, a closed-form neural network framework that guarantees hard satisfaction of an arbitrary number of input-dependent affine inequality constraints * * * Note that equality constraints can be equivalently expressed using two sets of

Read the complete text