betaFeedback

WorksEngineering

Enforcing Ellipsoidal Constraints in Neural Networks with a Polynomial Safety Layer

Abstract

Often the output of a learned mapping must satisfy prescribed constraints. In the control of autonomous systems, for example, the chosen action must keep the system within a collision-free region. We consider the case in which a proposed output is corrected by projection onto a safety ellipsoid. Computing this projection amounts to solving a quadratically constrained quadratic program (QCQP). We construct a neural-network safety layer by unrolling a feasibility-preserving polynomial penalty iteration. The unrolled structure allows the loss gradient to propagate from the feasible output through the safety layer to the network parameters during training. We show how to choose the layer parameters so that every iterate is feasible and give a computable bound on its distance to the exact projection at any prescribed depth. We illustrate the method by training a LiDAR-based policy to control an unmanned aerial vehicle. A privileged model predictive control expert uses the map and the measured vehicle state to generate the training data. In the simulated narrow mazes, the filtered policy avoided wall contact at every tested stage of training, including at initialization, when every unfiltered flight hit a wall. A representative build of the learned policy and its safety layer for an Arm Cortex-M4F microcontroller occupies about 36 KiB of flash, with a RAM budget below 5 KiB.

Introduction

In many applications, the output of a learned mapping must satisfy a hard constraint at each evaluation. For example, a network that allocates assets must respect a prescribed risk budget. For the control of an autonomous system, the command returned by a learned policy must belong to a feasible set to ensure safety and collision avoidance. Even if an expert supplies only feasible commands during training, the policy can propose an infeasible command [7]. Safety filters can correct the proposal before it is applied [12, 25, 7]. Embedding the safety layer in the policy allows training to account for the corrected action [4].

We consider learned mappings whose outputs must satisfy quadratic constraints. When the feasible outputs form an ellipsoid, finding the smallest correction to a proposal amounts to solving a quadratically constrained quadratic program (QCQP). Such constraints arise, for example, from discrete-time barrier conditions with a quadratic barrier for systems whose next state is affine in the input [1]. To account for the correction during training, we implement the safety layer as a sequence of neural network blocks at the output of the learned mapping (Figure 1). Each block performs one step of the polynomial penalty iteration. Starting from a feasible output, the iteration preserves feasibility under an explicit rule for choosing the coefficients. A scalar recursion bounds the distance from the filtered output to the exact projection at any chosen depth.

Figure 1. The neural network hθh_\theta proposes uNNu_{\mathrm{NN}}. The safety layer starts at the feasible point u(0)=vu^{(0)} = v. Each block FℓF_\ell performs one polynomial penalty step and returns a feasible iterate. The diamond marks the filtered output uSu_S, and the black dot marks the exact projection u⋆u^\star. Pink shows the learning process. During training, y=ydatay = y_{\mathrm{data}} and the loss compares uSu_S with the paired target udatau_{\mathrm{data}}.

A safety filter defined by a convex optimization problem can be incorporated into training by differentiating through its solution [2]. For example, a neural controller can enforce control barrier function constraints through a differentiable quadratic program [26]. Other approaches parameterize feasible predictions directly [23] or incorporate constraint corrections into training [6]. Unrolling assigns one iteration of an optimization algorithm to each network block [11]. In our construction each polynomial iteration is implemented exactly as a feedforward neural network block for the given coefficients. At any prescribed depth the layer gives a bound on the projection error. With the layer parameters chosen according to our rule, every block returns a feasible output for any network proposal during training, adaptation and deployment.

Section 2 gives the construction and the finite-depth certificate. Section 3 applies it to a LiDAR-based policy trained to imitate a privileged model predictive controller for a drone. We examine the commands proposed during learning and the actions returned by the filter for the drone.

Safety layer from polynomial iterations with feasibility guarantees

Let yy denote the features supplied to the neural network hθh_\theta with trainable weights θ\theta. uNN=hθ(y)u_{\mathrm{NN}} = h_\theta(y) is the proposal provided by the network. The feasible set C\mathcal{C}, which for example describes the safe set with respect to collision avoidance, is given by the center vv and the positive definite shape matrix MM by C={u:g(u)≤1}\mathcal{C} = \{u : g(u) \le1\}, where g(u)=(u−v)TM(u−v)g(u) = (u-v)^\mathsf{T}M(u-v). The feasible output closest to the network proposal is

u⋆=arg⁡min⁡u∈Cf(u),f(u)=12∥u−uNN∥2.(1)u^\star= \arg\min_{u \in\mathcal{C}} f(u), \qquad f(u) = \frac{1}{2}\lVert u-u_{\mathrm{NN}}\rVert^2. \tag*{(1)}

This QCQP has a unique solution and returns the proposal itself whenever it is feasible. For a proposal outside the ellipsoid, the exact projection u⋆u^\star lies on its boundary. An approximation can therefore be arbitrarily close to u⋆u^\star and still lie outside. We require each iteration block to return a point in CC. Note that any constraint u⊤Qu+2b⊤u+c≤0u^\top Q u + 2b^\top u + c \le0 with Q≻0Q \succ0 and nonempty interior takes this form with v=−Q−1bv = -Q^{-1}b, ρ=b⊤Q−1b−c\rho= b^\top Q^{-1}b - c, and M=Q/ρM = Q/\rho. A positive definite weight on the correction can likewise be absorbed by a change of coordinates.

Polynomial iteration as a neural network for the projection

Our main contribution is to construct a neural network safety layer from the feasibility-preserving polynomial penalty iteration developed for encrypted QCQP optimization (Schlor et al. [21]). The exact realization integrates the safety mechanism into a feedforward architecture with a prescribed depth and feasible block outputs. Each of its NN blocks implements one iteration exactly using affine maps and a square activation function σ(τ)=τ2\sigma(\tau)=\tau^2. Policy and safety layer thus form a single feedforward network of fixed depth, with the safety layer using only additions and multiplications for given coefficients. This makes the combined network a candidate for implementation as one network with fixed latency on dedicated hardware, for example on FPGAs or as logic circuits (Xu et al. (2024); Lucia et al. [16]). From a feasible initial iterate, every iteration block returns a feasible output. During training, the loss at the chosen block output can be differentiated through the blocks to update the preceding network. Furthermore, for the projection problem in (1), we give an explicit choice of the penalty weight mm and bound the distance to the exact projection at each depth.

Each polynomial iteration block Fℓ+1F_{\ell+1} takes the current iterate u(ℓ)u^{(\ell)} and the network proposal uNNu_{\mathrm{NN}} as inputs and returns the next iterate u(ℓ+1)u^{(\ell+1)}. Starting from u(0)=vu^{(0)}=v, each block takes one gradient step of length γℓ\gamma_\ell on the penalized objective Jkℓ=f+(m/kℓ)gkℓJ_{k_\ell}=f+(m/k_\ell)g^{k_\ell}. Here m≥0m\ge0 is the penalty weight shared by all blocks during one evaluation, and kℓ≥1k_\ell\ge1 is the integer exponent chosen for block Fℓ+1F_{\ell+1}. All blocks use the same ellipsoid data (v,M)(v,M). For ℓ=0,…,N−1\ell=0,\ldots,N-1 this gives

u(ℓ+1)=u(ℓ)−γℓ[u(ℓ)−uNN+2m g(u(ℓ))kℓ−1M(u(ℓ)−v)].(2)u^{(\ell+1)}=u^{(\ell)}-\gamma_\ell\left[u^{(\ell)}-u_{\mathrm{NN}}+2m\,g(u^{(\ell)})^{k_\ell-1}M(u^{(\ell)}-v)\right]. \tag*{(2)}

For a given exponent kℓk_\ell, the ellipsoid data (v,M)(v,M), penalty weight mm and step size γℓ\gamma_\ell determine the coefficients of the polynomial in u(ℓ)u^{(\ell)} and uNNu_{\mathrm{NN}}. We therefore call Fℓ+1F_{\ell+1} a polynomial iteration block. To implement this update, the block first computes d=u(ℓ)−vd=u^{(\ell)}-v and MdMd by affine maps. Two neurons with square activation σ\sigma suffice to multiply two scalars. They take a+ba+b and a−ba-b as inputs, and their outputs give ab=[σ(a+b)−σ(a−b)]/4ab=[\sigma(a+b)-\sigma(a-b)]/4. Repeating this construction and summing the products gives g(u(ℓ))=d⊤Mdg(u^{(\ell)})=d^\top Md. Further products give the vector g(u(ℓ))kℓ−1Mdg(u^{(\ell)})^{k_\ell-1}Md. An affine output combines this vector with u(ℓ)u^{(\ell)} and uNNu_{\mathrm{NN}} to give exactly the iterate in (2). After NN such blocks the layer returns uS=SN(uNN;v,M)=u(N)u_S=S_N(u_{\mathrm{NN}};v,M)=u^{(N)}. For a given ellipsoid, the complete layer is polynomial in the proposal if its coefficients are chosen in advance for a bounded range of proposals. In the navigation example the current proposal determines the penalty weight and step sizes before the blocks are evaluated.

Feasibility, projection error and convergence

The safety layer must return a feasible output at any prescribed depth. The following theorem guarantees this property for suitable choices of mm, the weight of the penalty term gkℓ/kℓg^{k_\ell}/k_\ell in the objective JkℓJ_{k_\ell}, and of the block step sizes γℓ\gamma_\ell.

Theorem 1 (Feasibility and projection error). Let λ−,λ+>0\lambda_-,\lambda_+>0 be the smallest and largest eigenvalues of MM. Initialize u(0)=vu^{(0)}=v, choose an integer kℓ≥1k_\ell\ge1 for each step, and keep the penalty

weight mm fixed throughout one network evaluation. Let mm and the step sizes γℓ\gamma_\ell satisfy

m≥max⁡(0,g(uNN)−1)2λ−,0<γℓ≤[1+(4kℓ−2)mλ+]−1.(3)m \ge\frac{\max(0,\sqrt{g(u_{\mathrm{NN}})}-1)}{2\lambda_{-}}, \qquad0 < \gamma_\ell\le[1+(4k_\ell-2)m\lambda_{+}]^{-1}. \tag*{(3)}

With E0=1/λ−E_0=1/\lambda_{-} and qℓ=(1−γℓ)/(1+γℓ)q_\ell=(1-\gamma_\ell)/(1+\gamma_\ell), define

Eℓ+1=qℓEℓ+(1−qℓ)m/kℓ.(4)E_{\ell+1}=q_\ell E_\ell+(1-q_\ell)m/k_\ell. \tag*{(4)}

Then g(u(N))≤1g(u^{(N)})\le1 and ∥u(N)−u⋆∥2≤EN\lVert u^{(N)}-u^\star\rVert_2\le\sqrt{E_N} for every N≥0N\ge0.

Proof. Use u,u+u,u^{+} for successive iterates. A change of variables w=M1/2(u−v)w=M^{1/2}(u-v) maps the ellipsoid to the unit ball, so it suffices to show that r=∥w∥≤1r=\lVert w\rVert\le1 implies ∥w+∥≤1\lVert w^{+}\rVert\le1. With d~=M1/2(uNN−v)\tilde{d}=M^{1/2}(u_{\mathrm{NN}}-v), the update becomes w+=Aw+γd~w^{+}=Aw+\gamma\tilde{d}, where A=(1−γ)I−2γmr2k−2M⪰0A=(1-\gamma)I-2\gamma mr^{2k-2}M\succeq0 by (3). Its largest eigenvalue gives ∥w+∥≤(1−γ)r−2γmλ−r2k−1+γ∥d~∥\lVert w^{+}\rVert\le(1-\gamma)r-2\gamma m\lambda_{-}r^{2k-1}+\gamma\lVert\tilde{d}\rVert. By (3) this bound is nondecreasing in rr on [0,1][0,1] and at most one at r=1r=1, since ∥d~∥=g(uNN)\lVert\tilde{d}\rVert=\sqrt{g(u_{\mathrm{NN}})}. Induction from w(0)=0w^{(0)}=0 gives feasibility. We bound the squared error D=∥u−u⋆∥2D=\lVert u-u^\star\rVert^2 without computing u⋆u^\star. Write D+=∥u+−u⋆∥2D^{+}=\lVert u^{+}-u^\star\rVert^2. On the ellipsoid, ∥∇g∥2≤4λ+g\lVert\nabla g\rVert^2\le4\lambda_{+}g gives I⪯∇2Jk⪯[1+(4k−2)mλ+]I⪯I/γI\preceq\nabla^2J_k\preceq[1+(4k-2)m\lambda_{+}]I\preceq I/\gamma. For ΔJ=Jk(u+)−Jk(u⋆)\Delta J=J_k(u^{+})-J_k(u^\star), the quadratic upper bound on the segment [u,u+][u,u^{+}] and strong convexity at uu give 2γΔJ≤(1−γ)D−D+2\gamma\Delta J\le(1-\gamma)D-D^{+}, using u+−u=−γ∇Jk(u)u^{+}-u=-\gamma\nabla J_k(u). Since u+u^{+} is feasible, the optimality condition for the Euclidean projection u⋆u^\star gives f(u+)−f(u⋆)≥D+/2f(u^{+})-f(u^\star)\ge D^{+}/2. Since 0≤(m/k)gk≤m/k0\le(m/k)g^k\le m/k on the ellipsoid, ΔJ≥D+/2−m/k\Delta J\ge D^{+}/2-m/k. Thus D+≤qD+(1−q)m/kD^{+}\le qD+(1-q)m/k. The initial bound ∥v−u⋆∥2≤E0\lVert v-u^\star\rVert^2\le E_0 and induction yield ∥u(N)−u⋆∥2≤EN\lVert u^{(N)}-u^\star\rVert^2\le E_N by (4).

The feasibility guarantee is independent of the architecture of the preceding network and applies equally to proposals generated by convolutional networks or transformers, provided the conditions of Theorem 1 hold.

With a linearly increasing penalty exponent and the largest permitted step sizes, the block outputs converge to the exact projection while remaining feasible at every depth. The following corollary quantifies this convergence.

Corollary 2 (Decay of the projection error bound). Take kℓ=ℓ+1k_\ell=\ell+1 and the largest step in (3). For fixed κ=2mλ+>0\kappa=2m\lambda_{+}>0, ENE_N is O(N−1)O(N^{-1}) if κ<1\kappa<1, O(N−1log⁡N)O(N^{-1}\log N) if κ=1\kappa=1, and O(N−1/κ)O(N^{-1/\kappa}) if κ>1\kappa>1.

Proof. Set wj=1−qj−1=[1+κ(j−12)]−1w_j=1-q_{j-1}=[1+\kappa(j-\frac{1}{2})]^{-1}. Since 1−wj≤e−wj1-w_j\le e^{-w_j}, integral comparison gives

∏j=i+1N(1−wj)≤[1+κ(i+12)1+κ(N+12)]1/κ\prod_{j=i+1}^{N}(1-w_j)\le\left[\frac{1+\kappa(i+\frac{1}{2})}{1+\kappa(N+\frac{1}{2})}\right]^{1/\kappa}

for 0≤i≤N0\le i\le N. Expanding (4) with this bound and wi=O(i−1)w_i=O(i^{-1}) yields EN=O(N−1/κ(1+∑i=1Ni1/κ−2))E_N=O\left(N^{-1/\kappa}\left(1+\sum_{i=1}^{N}i^{1/\kappa-2}\right)\right). Summing the powers of ii gives the three rates.

Remark 3 (Learning through the safety layer). The training dataset contains pairs (ydata,udata)(y_{\mathrm{data}},u_{\mathrm{data}}) of input features and target outputs. For each pair, the network proposes hθ(ydata)h_\theta(y_{\mathrm{data}}), and the loss compares the filtered output uSu_S with the target udatau_{\mathrm{data}}. Backpropagation through the NN blocks gives the gradient with respect to θ\theta. The penalty weight mm and step sizes γℓ\gamma_\ell can also be chosen as functions of the network proposal, as in the navigation example in § 3. Backpropagation then includes the dependence of both mm and γℓ\gamma_\ell on the proposal. When the filtered output is locally insensitive to the proposal, the gradient reaching the network can vanish. In that example, an auxiliary loss compares the proposal directly with the expert action.

Learning a LiDAR-based drone navigation policy from a privileged MPC expert

We consider an indoor drone that must reach a goal through a maze without hitting the walls (Figure 2). A global planner uses the map to provide a feasible route and waypoints for the local controller ([20, 13]). We train a LiDAR-based policy by imitating an expert with access to additional information ([3]). Here the expert is a model predictive controller (MPC) that uses the measured state and the mapped corridor ahead. Its first acceleration command serves as the training target. The policy uses local range measurements for navigation ([18]). At each update it proposes a planar acceleration from the latest scan, the measured velocity, the relative waypoint and the reference velocity.

Figure 2. The learned LiDAR policy proposes an acceleration from sensor measurements and route references. The safety layer filters the proposal before it is applied. The MPC supplies the training targets.

Collision-free demonstrations alone do not guarantee that the learned policy satisfies the safety constraints ([12, 7]). At a bend, for example, an imitation error can cause the drone to brake too late and hit the outer wall (Figure 3). The planner covers the route with overlapping cells. Each cell is an ellipsoid {x:Vi(x)≤1}\{x : V_i(x) \le1\} in the joint state x=(p,w)x = (p,w) of position and velocity, with a quadratic function ViV_i that is positive definite about the cell center. The planner selects one active cell, also where two cells overlap. With the planar acceleration u∈R2u \in\mathbb{R}^{2} held constant over one sampling interval TT, the nominal next state x+(u)x^{+}(u) is affine in uu. For the cells used here, Vi(x+(u))≤(1−β)Vi(x)+βV_i(x^{+}(u)) \le(1-\beta)V_i(x) + \beta, with 0<β<10 < \beta< 1, therefore defines a nonempty ellipse of accelerations that keep the next state in the cell when Vi(x)≤1V_i(x) \le1. With hi=1−Vih_i = 1 - V_i, this is the discrete-time barrier condition hi(x+(u))≥(1−β)hi(x)h_i(x^{+}(u)) \ge(1-\beta)h_i(x). Each cell also limits the velocity so that the drone, continuing at its current velocity for half a sampling interval, would still be inside the cell’s position ellipse. Together with the current and the next position, this point p+Tw/2p + T\boldsymbol{w}/2 spans a triangle that contains the flight segment p+tw+12t2up + t\boldsymbol{w} + \frac{1}{2}t^{2}u, 0≤t≤T0 \le t \le T. Since the ellipse is convex, the whole nominal segment stays in mapped free space. The planner switches to the next cell only once the measured position and velocity satisfy its entry condition.

Figure 3. Flight on a held-out maze. The enlargement shows the filter active and bypassed. The square marks where the drone comes to rest when the filter is added only at deployment.

MPC expert and policy training

To train the LiDAR policy, we pair each observation with the acceleration commanded by the expert in closed-loop simulation.

Privileged MPC expert. At each sampling instant the expert uses the measured state to solve a constrained tracking problem over a receding horizon [19, 9]. It predicts planar motion with two acceleration inputs over 3.5 s at a sampling interval of 0.1 s. It tracks the planner’s waypoints and reference velocities, constrains each predicted flight segment to its assigned corridor cell and checks membership in both cells at a handover. The first acceleration must also lie in the same safety ellipse used by the learned policy. The expert applies this acceleration for one sampling interval and then replans.

Training data. We collected about 83,000 expert actions on 296 layouts with narrow and wide corridors. We verified each accepted plan over its full prediction horizon.

LiDAR policy. The navigation example uses a compact multilayer perceptron whose embedded memory requirements are reported in § 3.3. The policy receives 32 LiDAR ranges, the measured velocity, the relative waypoint and the reference velocity. Two hidden layers of 64 tanh units produce the two acceleration components. The safety layer uses ten polynomial iteration blocks with exponents kℓ=ℓ+1k_{\ell} = \ell+ 1 for ℓ=0,…,9\ell= 0, \ldots, 9. We choose the coefficients for the current proposal according to (3). For imitation we minimize ∥uS−udata∥2+η∥uNN−udata∥2\lVert u_{\mathrm{S}} - u_{\mathrm{data}}\rVert^{2} + \eta\lVert u_{\mathrm{NN}} - u_{\mathrm{data}}\rVert^{2}. The auxiliary term gives the policy a direct gradient when the filter attenuates the gradient from the applied acceleration. We chose η=0.1\eta= 0.1. We trained on the full dataset and on two subsets of 10,000 and 20,000 examples, each covering all training maps. For each dataset we used matched initial weights and the same number of training updates. One policy used the loss above, and the other fitted its proposal directly to the expert acceleration.

Flight, intervention and learning

On six unseen narrow mazes, we tested both policies with and without the layer from the same six initial states per map and three training seeds (Table 1). With the smallest training set, training with the layer gave 102 goal arrivals, compared with 60 when it was added after training. Both avoided wall contact. At larger training budgets, adding the layer after training gave more arrivals.

ExamplesTrained with filterTrained without filter
Filter activeBypassedFilter addedNo filter
10,000102 / 078 / 660 / 090 / 0
20,00090 / 054 / 0102 / 090 / 0
Full dataset96 / 072 / 0102 / 0102 / 0

Table 1. Goal arrivals / wall contacts in 108 narrow-maze flights per column and training budget. The remaining flights timed out.

Figure 3 shows how the safety layer corrects insufficient braking before the left turn. The network still commands forward acceleration. The safety layer applies a braking acceleration, and the drone enters the next cell and reaches the goal. With the same weights and the layer bypassed, the drone carries too much speed into the turn and hits the far wall. All six contacts occurred at this bend for one training seed.

The square in Figure 3 marks where adding the layer after training brings the drone to rest. The unchanged scan and waypoint then lead to repeated zero acceleration after filtering. At this

state, both policies request similar forward accelerations but different lateral components. The safety ellipse couples these components: after filtering, the policy trained with the layer retains enough forward acceleration to move. This illustrates how training with the safety layer can improve progress through a narrow bend. On 72 further narrow mazes, the independently trained policy with the smallest training set hit a wall in 18 of 1,296 flights. Adding the layer to the same weights prevented all observed contacts. In Figure 4, filtering also allowed the drone to reach the goal, although it reduced arrivals across these mazes overall. On a broader set of familiar and unseen maps, both policies avoided wall contact and reached more goals with the full training set. Even with the full dataset, the layer corrected about two fifths of the proposals. The safety ellipse gives a sufficient condition for clearance, so a correction need not indicate an impending collision. On a separate maze we varied the initial position and velocity and applied a lateral gust midway along the route (Figure 5). The route tube is a band extending 0.20 m to either side of the planned route, used only to measure recovery. For the gust direction shown, all flights that were within this band at gust onset and subsequently left it returned with forward progress. Goal completion depended on the wind direction. Some disturbed trajectories left the nominal cell even though the applied accelerations remained feasible. The flights illustrate recovery after a disturbance. The clearance guarantee applies to the nominal motion.

Flight trajectories for policies with and without the safety layer and an enlargement of the first turn

Figure 4. An independently trained unfiltered policy hits the outer wall at the first turn. Applying the safety layer to the same weights allows the drone to complete the route. All three flights use fresh feedback from the same initial state.

Figure 5. Perturbed starts on a complex maze (left, one policy seed). The enlarged bend shows matched calm and wind-driven flights. The filled circle marks the end of the gust and the open circle marks return to the route tube.

We also held the first proposed acceleration for ten additional sampling intervals while continuing to update the state and safety ellipse. Both unfiltered controllers hit walls in more than half the flights. The filtered controller avoided wall contact because it could correct the held proposal using the current state at each sample.

At successive training stages, we evaluated the policies from the same initial states in the narrow test mazes, with weights fixed during each flight (Figure 6). At initialization, every unfiltered flight hit a wall, while filtering prevented contact but achieved no goals. Most early proposals were infeasible. The layer thus enforced feasibility before the policy had learned to navigate.

Closed-loop evaluation of policies in narrow test mazes

Figure 6. Closed-loop evaluation of the policies in narrow test mazes at successive stages of training. Left: fraction of test flights with wall contact. Right: fraction of proposed accelerations outside the safety ellipse before filtering, for two training set sizes.

Finally, partially trained policies were updated during flight on two unseen layouts using MPC targets at the visited states. Roughly two thirds of the filtered policy’s proposals were infeasible, yet every applied acceleration satisfied the constraint to numerical tolerance. The unfiltered policy hit walls in nearly all flights. Separate tests gave the same arrivals before and after adaptation. Thus, the layer maintained feasibility while the controller weights changed.

Feasibility at prescribed depth and computational effort

For safety-critical control, feasibility of the applied command, uS∈Cu_{\mathrm{S}} \in\mathcal{C}, is required at every sampling instant, whereas proximity to the exact projection u∗u^{*} is secondary. Under the conditions of Theorem 1, every polynomial block returns a feasible output, so the depth NN can be fixed in advance without losing the feasibility guarantee. Training through the layer allows the policy to account for the correction produced by the chosen number of blocks, as illustrated by the avoided stall in Figure 3 and the limited-data comparison in Table 1.

For the polynomial layer used in the navigation example, we choose the smallest penalty weight and largest step sizes allowed by (3) for the current proposal. A feasible proposal then passes through unchanged. The fixed version uses an upper bound RR on g(uNN)\sqrt{g(u_{\mathrm{NN}})}, so for a given ellipse its coefficients apply to the whole prescribed range of proposals.

We first evaluated the polynomial layer on accelerations proposed by a policy trained on the full dataset, using one training seed and states visited by the MPC on 24 unseen maps. Among the roughly 740 infeasible proposals, increasing the number of blocks from one to ten reduced the mean distance to the exact projection from about 1.4 to 0.1 m/s2^{2}. Over the same proposals, the mean of the certified bounds fell from about 3 to 0.4 m/s2^{2}. Each bound applies to the individual command and can be evaluated without computing the exact projection. Since the recursion (4) does not involve the iterates, a depth sufficient for a prescribed tolerance can be determined before the blocks are evaluated. The trained policy typically proposed accelerations that lay just outside the safety ellipse when a correction was needed. Their median normalized radius g(uNN)\sqrt{g(u_{\mathrm{NN}})} was about 1.02, with the boundary at one. For proposals farther outside the ellipse, sampled at a normalized radius of 1.5, the projection error decreased slowly even at 100 blocks. For a spherical constraint, the proposal-dependent choice in (3) with k0=1k_{0}=1 gives the exact projection in the first block. For an elongated ellipsoid, the same rule prescribes a smaller step size as the proposal moves farther outside the safety ellipse. With the bound implied by the full output range of the policy, the fixed-coefficient layer was too conservative at the chosen depth and all flights with this choice reached the time limit, highlighting the importance of a tight bound RR.

Radial scaling [23] and Frank–Wolfe iterations [14, 15] also enforce feasibility, while a scalar root search [8] computes the Euclidean projection numerically. The polynomial iteration offers a feedforward realization whose blocks, for given coefficients, use only additions and multiplications. Its projection error is bounded in advance by (4), and with the sequence of Corollary 2 its output converges to u∗u^{*} as the depth increases. Radial scaling generally returns a different feasible point. This structure makes the layer a candidate for fixed-latency hardware implementation (§ 2.1).

While MPC can be implemented efficiently even on low-end microcontrollers for small problems [22, 17, 24], its computational effort generally grows with the prediction horizon and the number of constraints [5] (Findkeisen et al. 2026). For a fixed network architecture and safety-layer depth, the learned policy and its safety layer have a prescribed computational budget per command. On a single thread of an Apple M3 Max CPU, the learned policy with its safety layer took 22 μ\mus per command at the median. This includes feature assembly from the supplied LiDAR ranges, evaluation of the network, construction of the safety ellipse, ten polynomial steps and calculation of the error bound. On the same states, replanning and checking the 35-step MPC horizon took about 0.8 ms, or 36 times as long. Both medians fall within the 100 ms control interval and exclude sensing and map construction. For onboard use, we also compiled an earlier version of the policy with the same architecture, including the safety layer, for an STM32 Cortex-M4F microcontroller. The controller image occupied about 36 KiB of flash and budgeted less than 5 KiB of RAM, including the stack. The timings and memory footprint support deploying the navigation policy and safety layer on resource-limited embedded systems. Sensing and global planning require a separate assessment; the planner can also run offboard.

Conclusion

Training a neural network on feasible examples alone does not ensure that its outputs satisfy a hard constraint. For a learned mapping with an ellipsoidal output constraint, we constructed a safety layer that approximates the Euclidean projection of the network proposal. Each block implements one polynomial penalty step exactly for the supplied coefficients. The loss can therefore be evaluated at the filtered output and differentiated through the same blocks used at deployment. We showed how to choose the parameters of the polynomial safety layer so that every block returns a feasible output. At any chosen depth, we can also bound the distance from that output to the exact projection. The construction also applies to nonlinear discrete-time models that are affine in the control input, provided the quadratic safety condition defines a nonempty, nondegenerate ellipsoid of inputs.

We evaluated the safety layer in simulation on a drone navigating indoor mazes. We trained its LiDAR-based policy to imitate a privileged model predictive control (MPC) expert that used the map and the measured drone state to compute target accelerations. The filtered policy avoided wall contact at every tested stage, even before it had learned to navigate. During in-flight adaptation, the safety layer kept every applied acceleration feasible. On unseen mazes, adding the layer to a policy trained without filtering prevented the wall contacts observed with the same weights, although fewer flights reached the goal overall. The narrow-maze trials show that including the safety layer in training can also improve navigation performance. With limited data, the policy trained with the layer reached the goal more often than the policy trained without it, although both used the same layer in flight. This advantage disappeared with larger training sets.

We plan to extend the construction to more complex feasible sets described by several overlapping ellipsoids. In particular, we will study how to blend the outputs of their safety layers while preserving feasibility. We also plan to evaluate the policy and safety layer in closed-loop flight on a drone with limited onboard computing power, including an implementation of both as one network on an FPGA, and measure whether they meet the control deadline.

Generative AI use

We used ChatGPT and Codex (OpenAI, including GPT-6 Astra) to assist with manuscript drafting and preparation of the simulation code. We carefully evaluated and checked the simulation results reported in this paper. The authors take full responsibility for the content, results, and conclusions presented in this paper.

References

  1. [1]A. Agrawal and K. Sreenath. Discrete control barrier functions for safety-critical control of discrete systems with application to bipedal robot navigation. In Proc. Robotics: Science and Systems (RSS), Cambridge, Massachusetts, July 2017. doi: 10.15607/RSS.2017.XIII.073.DOI
  2. [2]A. Agrawal, B. Amos, S. Barratt, S. Boyd, S. Diamond, and J. Z. Kolter. Differentiable convex optimization layers. In Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper_files/paper/2019/hash/9ce3c52fc54362e22025399d3181c638-Abstract.html.arxiv.org/abs/1910.12430
  3. [3]D. Chen, B. Zhou, V. Koltun, and P. Kräh enbühl. Learning by cheating. In Proc. Conf. Robot Learning (CoRL), volume 100 of Proceedings of Machine Learning Research, pages 66–75. PMLR, 2020. URL https://proceedings.mlr.press/v100/chen20a.html.arxiv.org/abs/1912.12294
  4. [4]G. Dalal, K. Dvijotham, M. Vecerík, T. Hester, C. Paduraru, and Y. Tassa. Safe exploration in continuous action spaces. arXiv preprint, 2018. URL https://arxiv.org/abs/1801.08757.
  5. [5]M. Diehl, H. J. Ferreau, and N. Haverbeke. Efficient numerical methods for nonlinear MPC and moving horizon estimation. In L. Magni, D. M. Raimondo, and F. Allgöwer, editors, Nonlinear Model Predictive Control, volume 384 of Lecture Notes in Control and Information Sciences, pages 391–417. Springer, Berlin, Heidelberg, 2009. doi: 10.1007/978-3-642-01094-1_32.DOI
  6. [6]P. L. Donti, D. Rolnick, and J. Z. Kolter. DC3: A learning method for optimization with hard constraints. In Proc. Int. Conf. Learning Representations (ICLR), 2021. URL https://openreview.net/forum?id=V1ZHVxJ6dSS.arxiv.org/abs/2104.12225
  7. [7]J. Drgoňa, T. X. Nghiem, T. Beckers, M. Fazlyab, E. Mallada, C. Jones, D. Vrabie, S. L. Brunton, and R. Findeisen. Safe physics-informed machine learning for dynamics and control. In Proc. Am. Control Conf. (ACC), pages 591–606, 2025. doi: 10.23919/ACC63710.2025.11107836.DOI
  8. [8]D. Eberly. Distance from a point to an ellipse, an ellipsoid, or a hyperellipsoid. Technical report, Geometric Tools, 2020. URL https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf.
  9. [9]R. Findeisen, L. Imsland, F. Allgöwer, and B. A. Foss. State and output feedback nonlinear model predictive control: An overview. Eur. J. Control, 9(2–3):190–206, 2003. doi: 10.3166/ejc.9.190-206. URL https://doi.org/10.3166/ejc.9.190-206.
  10. [11]K. Gregor and Y. LeCun. Learning fast approximations of sparse coding. In Proc. Int. Conf. Machine Learning (ICML), pages 399–406, 2010. URL https://icml.cc/2010/papers/449.pdf.
  11. [12]K.-C. Hsu, H. Hu, and J. F. Fisac. The safety filter: A unified view of safety-critical control in autonomous systems. Annu. Rev. Control Robot. Auton. Syst., 7:47–72, 2024. doi: 10.1146/annurev-control-071723-102940.DOI
  12. [13]M. Kögel, M. Ibrahim, C. Kallies, and R. Findeisen. Safe hierarchical model predictive control and planning for autonomous systems. Int. J. Robust Nonlinear Control, 35(7):2658–2676, 2025. doi: 10.1002/rnc.6808.
  13. [14]J.-L. Lin, W. Hung, S.-H. Yang, P.-C. Hsieh, and X. Liu. Escaping from zero gradient: Revisiting action-constrained reinforcement learning via Frank-Wolfe policy optimization. In Proc. Conf. Uncertainty in Artificial Intelligence (UAI), volume 161 of Proceedings of Machine Learning Research, pages 397–407. PMLR, 2021. URL https://proceedings.mlr.press/v161/lin21b.html.arxiv.org/abs/2102.11055
  14. [15]Z. Liu, L. Liu, X. Wang, and P. Zhao. DFWLayer: Differentiable Frank-Wolfe optimization layer. In Tiny Papers at the Int. Conf. Learning Representations (ICLR), 2024. URL https://openreview.net/forum?id=XoPQqUctS1.arxiv.org/abs/2308.10806
  15. [16]S. Lucia, D. Navarro, Ó. Lucía, P. Zometa, and R. Findeisen. Optimized FPGA implementation of model predictive control for embedded systems using high-level synthesis tool. IEEE Trans. Ind. Informat., 14(1):137–145, 2018. doi: 10.1109/TII.2017.2719940.DOI
  16. [17]K. Nguyen, S. Schoedel, A. Alavilli, B. Plancher, and Z. Manchester. TinyMPC: Model-predictive control on resource-constrained microcontrollers. In Proc. IEEE Int. Conf. Robot. Autom. (ICRA), 2024. doi: 10.1109/ICRA57147.2024.10610987.
  17. [18]M. Pfeiffer, M. Schaeuble, J. Nieto, R. Siegwart, and C. Cadena. From perception to decision: A data-driven approach to end-to-end motion planning for autonomous ground robots. In Proc. IEEE Int. Conf. Robot. Autom. (ICRA), pages 1527–1533, 2017. doi: 10.1109/ICRA.2017.7989182.DOI
  18. [19]J. B. Rawlings, D. Q. Mayne, and M. M. Diehl. Model Predictive Control: Theory, Computation, and Design. Nob Hill Publishing, Santa Barbara, CA, 2nd, paperback edition, 2020. ISBN 978-0-9759377-5-4. URL https://sites.engineering.ucsb.edu/~jbraw/mpc/.
  19. [20]C. Richter, A. Bry, and N. Roy. Polynomial trajectory planning for aggressive quadrotor flight in dense indoor environments. In M. Inaba and P. Corke, editors, Robotics Research, volume 114 of Springer Tracts in Advanced Robotics, pages 649–666. Springer, Cham, 2016. doi: 10.1007/978-3-319-28872-7_37.DOI
  20. [21]S. Schlor, A. Iannelli, J. Kim, H. Shim, and F. Allgöwer. A polynomial-based QCQP solver for encrypted optimization. In Proc. IEEE Conf. Decis. Control (CDC), pages 7885–7891, 2025. doi: 10.1109/CDC57313.2025.11312321.DOI
  21. [22]G. Takács, P. Zometa, R. Findeisen, and B. Rohal-Ilkiv. Embedded model predictive vibration control on low-end 8-bit microcontrollers via automatic code generation. In Proc. 23rd Int. Congr. Sound Vib. (ICSV), pages 434–441, Athens, Greece, 2016. ISBN 978-1-5108-2716-5. URL https://www.proceedings.com/content/031/031280webtoc.pdf.
  22. [23]J. Tordesillas, V. Klemm, J. P. How, and M. Hutter. RAYEN: Imposition of hard convex constraints on neural networks. Int. J. Robot. Res., 2026. URL https://arxiv.org/abs/2307.08336v3. Accepted for publication.
  23. [24]R. Verschueren, G. Frison, D. Kouzoupis, J. Frey, N. van Duijkeren, A. Zanelli, B. Novoselnik, T. Albin, R. Quirynen, and M. Diehl. acados—a modular open-source framework for fast embedded optimal control. Math. Program. Comput., 14(1):147–183, 2022. doi: 10.1007/s12532-021-00208-8.DOI
  24. [25]K. P. Wabersich, A. J. Taylor, J. J. Choi, K. Sreenath, C. J. Tomlin, A. D. Ames, and M. N. Zeilinger. Data-driven safety filters: Hamilton–Jacobi reachability, control barrier functions, and predictive methods for uncertain systems. IEEE Control Syst. Mag., 43(5):137–177, 2023. doi: 10.1109/MCS.2023.3291885.DOI
  25. [26]W. Xiao, T.-H. Wang, R. Hasani, M. Chahine, A. Amini, X. Li, and D. Rus. BarrierNet: Differentiable control barrier functions for learning of safe robot control. IEEE Trans. Robot., 39(3):2289–2307, 2023. doi: 10.1109/TRO.2023.3249564.DOI

Paper details

vlnc:W_nfdb7wkj
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Engineering

ChatGPT, Codex

View statement
Looking for related papers…
Contents