We propose a Reinforcement Learning (RL) based control design framework for handling complex tasks. The approach extends the concept of Reward Machines (RM) with Signal Temporal Logic (STL) formulas that can be used for event generation. The use of STL allows not only a more efficient representation of rewards for complex tasks but also guiding the training process to converge towards behaviors satisfying specified requirements. We also propose an implementation of the framework that leverages the STL online monitoring algorithms. We illustrate the framework with three case studies (minigrid, cart-pole and high-way environments) with non-trivial tasks.
Figures & tables
Figure 1
Fig. 1 : The minigrid environment Unlockenv with bigger grid size.
Fig. 2 : Reward machine of the Minigrid agent
Fig. 3 : Results from training an agent in the Unlock environment from a extended grid size 12x12 in MiniGrid. Blue: vanilla; orange: RM state in observation with STL specification during training.
Grid Size
Algorithm
Mean Reward ± Std
Mean Len Episode ± Std
6
Specs
0.9494±0.0221
16.2±7.09
6
Vanilla
0.1756±0.3927
238.2±111.36
7
Specs
0.9720±0.0062
12.2±2.68
7
Vanilla
0.9715±0.0060
12.4±2.61
8
Specs
0.9631±0.0128
21.0±7.28
8
Vanilla
0.7670±0.4290
121.2±218.63
TABLE I : Performance comparison per grid size of RM+STL vs Vanilla
Fig. 4 : Results achieved by the trained models when evaluated on larger grid sizes.
Fig. 5 : The cart-pole environment, augmented with target regions A and B defined as STL predicates μA and μB .
Fig. 6 : Reward machines of the cart pole: R1 encodes the task to go to region A and then to region B and stay there. R2 enforces episode termination when the formula φstuck defined in formula ( 1 ) is true.
Fig. 7 : Test results of a single episode using the sub-optimal trained model (i) and using a successfully trained one (ii).
Fig. 8 : Results for 10 training instances with (green) and without (gray) R2 encoding STL formula φstuck as terminal condition. With R2 , the performance of the policy consistently reaches an accumulated reward of 3.000, indicating that the task is successfully completed, whereas with only R1 , the performance of some policies remains around 800, indicating that only the region A is reached in most episodes.
Formula
hz
Interpretation
μdangeri=∣xi∣<.1∧∣yi∣<.1
0
car i is in front and too close
μdanger=∨i=14μdangeri
0
A car is in front and too close
φtail=□[0,10]μdanger
10
Too close for too long
μfast=vxego>25
0
ego vehicle goes fast
φlazy=□[0,10]¬μfast
10
safe for 10 steps
φfast = ◊[0,85]□[0,15]μfast
100
always accelerates eventually
TABLE II : Formulas characterizing driving behaviors and used in the RM in Figure 9 . Short horizon formula ( hz≤10 ) are used as event formulas. Long horizon formulas ( hz=100 ) are for agent evaluation past training.
Fig. 9 : Reward machine and formulas for the highway-env environment.
Fig. 10 : Training results for different values of rewards and penalties. Every 1e5 steps, the agent is tested for 100 episodes and all formulas are evaluated to give a complete picture of the current performance. All values lead to improving performance, lower values of pleft increase the rate of satisfaction of φright , which is consistent with the formulas and RM.
Signal temporal logic (STL) provides a formal language for specifying real-time properties of real-valued observations, along with a quantitative robustness score for monitoring satisfaction. Control synthesis from STL specifications is of interest since manual controller design becomes infeasible as real-world systems grow in complexity. Moreover, many modern autonomous and AI-enabled systems lack accurate and complete system models, which makes optimization-based synthesis approaches unsuitable and motivates learning-based control. Prior work uses STL robustness scores as rewards in reinforcement learning (RL) to obtain control policies satisfying given specifications; however, robustness depends on execution history, leading to intractable state space expansion for general long-horizon specifications with arbitrarily nested temporal operators. This work introduces a novel automata-based approach that provides an efficient memory mechanism and associated Markovian rewards suitable for RL frameworks. Our approach constructs a timed alternating automaton from the given STL specifications, augments the state space with automaton locations and clock valuations, and derives rewards from the automaton acceptance condition. We empirically demonstrate that our approach learns policies that achieve higher robustness scores and satisfaction rates than those learned by existing approaches using robustness-based rewards.
This paper addresses the control problem for robotic systems, including non-holonomic and underactuated platforms operating under unknown dynamics and strict actuator limits to satisfy complex high-level specifications. We denote these high-level specifications using Signal Temporal Logic (STL) and propose a novel time-aware Reinforcement Learning (RL) framework that leverages the geometric properties of Spatiotemporal Tubes (STTs). While traditional analytical STT controllers often struggle to enforce input constraints, and existing RL approaches rely on memory-intensive state history, our method natively overcomes both limitations. By mapping the logical and temporal complexities of the full class of STL into time-varying geometric boundaries, we directly constrain the multidimensional system state without relying on scalar robustness metrics. Augmenting the state space with time, we train a time-aware Soft Actor-Critic (SAC) agent using a continuous, geometry-aware reward function that eliminates the need to explicitly evaluate complex logical semantics during execution. The proposed framework offers a history-free, computationally efficient approach to learn continuous control policies that ensure robust satisfaction of specifications while strictly adhering to system input constraints.
Vaishnavi Jagabathula, P Sangeerth, Pushpak Jagtap
Centre for Cyber-Physical Systems, IISc, Bangalore, India
Reward Machines (RMs) are an established mechanism in Reinforcement Learning (RL) to represent and learn sparse, temporally extended tasks with non-Markovian rewards. RMs rely on high-level information in the form of labels that are emitted by the environment alongside the observation. However, this concept requires manual user input for each environment and task. The user has to create a suitable labeling function that computes the labels. These limitations lead to poor applicability in widely adopted RL frameworks. We propose Symbolic Reward Machines (SRMs) together with the learning algorithms QSRM and LSRM to overcome the limitations of RMs. SRMs consume only the standard output of the environment and process the observation directly through guards that are represented by symbolic formulas. In our evaluation, our SRM methods outperform the baseline RL approaches and generate the same results as the existing RM methods. At the same time, our methods adhere to the widely used environment definition and provide interpretable representations of the task to the user.
Thomas Krug, Daniel Neider
TU Dortmund University · Research Center Trustworthy Data Science and Security