Abstract
Robots and autonomous agents often complete goal-based tasks with limited resources, relying on imperfect models and sensor measurements. In particular, reinforcement learning (RL) and feedback control can be used to help a robot achieve a goal. Taking advantage of this body of work, this paper formulates general computation as a feedback-control problem, which allows the agent to autonomously overcome some limitations of standard procedural language programming: resilience to errors and early program termination. Our formulation considers computation to be trajectory generation in the program's variable space. The computing then becomes a sequential decision making problem, solved with reinforcement learning (RL), and analyzed with Lyapunov stability theory to assess the agent's resilience and progression to the goal. We do this through a case study on a quintessential computer science problem, array sorting. Evaluations show that our RL sorting agent makes steady progress to an asymptotically stable goal, is resilient to faulty components, and performs less array manipulations than traditional Quicksort and Bubble sort.
Introduction
Traditional computer science relies heavily on two assumptions: total correctness (the hardware will execute instructions flawlessly) and program-initiated termination (the algorithm runs until it decides it is finished). However, in extreme environments like space or high-radiation zones—and increasingly in densely packed modern microchips—"soft errors" like bit flips can silently corrupt memory and calculations.
Standard algorithms are brittle in these scenarios. If a soft error occurs during Quicksort, the final array might be completely unsorted. Furthermore, traditional algorithms offer no guarantees about the quality of their output if they are interrupted before completion. This paper reimagines general computation as a feedback-control problem, using reinforcement learning (RL) to create algorithms that are inherently resilient to hardware faults and soft errors. By treating an array-sorting task as a dynamical system, the authors train an RL agent that not only sorts arrays with fewer element manipulations than Quicksort or Bubble sort, but also guarantees steady progress even if interrupted or subjected to faulty comparisons.
Methodology
The authors frame computation as a discrete-time dynamical system where the program's variables represent the "state" and the instructions are "actions" that transform that state.
MDP Formulation
Array sorting is modeled as a Markov Decision Process (MDP). The state is the array itself, and the action space consists of removing an element and inserting it at a new position. Unlike traditional sorting algorithms that follow a rigid sequence of steps, the RL agent greedily evaluates the array at every step to pick the optimal element to move.
Learning and Stability
The reward function penalizes out-of-order adjacent elements and gives a massive bonus for a fully sorted array. Approximate Value Iteration (AVI) is used to learn a state-value function based on two features: the number of adjacent out-of-order elements, and a metric grouping similar elements together. To prove the algorithm works reliably, the authors apply Lyapunov stability theory from control engineering. They mathematically prove that the learned value function acts as a control Lyapunov function, meaning the system's "energy" (unsortedness) strictly decreases over time.
Key Results and Resilience
The RL agent was trained on 6-element arrays and evaluated on arrays of varying lengths up to 100 elements.
Efficiency in Array Manipulations
In an error-free environment, the RL agent required significantly fewer array changes than traditional methods. For a 100-element random array, RL sort averaged 284 moves, compared to 846 for Quicksort and 2,466 for Bubble sort.
Fault Tolerance
When a 5% failure rate was introduced to the comparison operator, Quicksort failed catastrophically (average Euclidean distance error from a sorted array was 255.8 for a 100-element array). In contrast, RL sort maintained an incredibly low error of 0.5, successfully absorbing the faulty comparisons. Empirical tests showed that RL sort maintains a non-zero probability of successfully sorting an array even when the comparison failure rate approaches 50%.
Discussion
By viewing a computer program as a robot navigating a state space, robust control theories can be applied to software. The algorithm doesn't care how the array got into its current state (even if a bit flip caused it); it just looks at the current state and takes the best next step. Because the RL sort is proven to be asymptotically stable via Lyapunov theory, it makes monotonic progress. If the system runs out of time or power and terminates early, the array is guaranteed to be more sorted than when it started.
The primary limitation of this approach is the computational complexity of the action selection phase. Because the agent evaluates every possible insertion action at every step, the decision-making overhead is $O(d_s^2)$. While it minimizes array manipulations, it maximizes compute time per step. Future work could involve hardware acceleration or parallelizing the greedy policy evaluation to reduce the time complexity to $O(\log d_s)$.
Summary updated