Learning to Shape Rewards using a Game of Switching Controls

David Mguni, Jianhong Wang, Taher Jafferjee, Nicolas Perez Nieves, Wenbin Song, Yaodong Yang, Feifei Tong, Hui Chen, Jiangcheng Zhu, Yali Du, Jun Wang

In reinforcement learning (RL), "sparse rewards" represent a significant hurdle to efficient training. When an agent only receives feedback upon completing a complex task, it often wanders aimlessly for millions of steps. While "Reward Shaping"—adding intermediate rewards—can mitigate this, it typically requires human experts to manually design these functions, a process that is often error-prone and labor-intensive.

This paper introduces ROSA (Reinforcement Learning Optimising Shaping Algorithm), a framework that automates reward shaping by framing it as a strategic game between two agents.

The ROSA Framework: A Game of Two Partners

ROSA treats the learning process as a two-player, non-zero-sum Markov Game involving a Controller and a Shaper. The Controller is the primary agent tasked with solving the environment, while the Shaper acts as a "teacher" that provides supplemental rewards to guide the Controller toward the goal.

The Switching Control Mechanism

A key innovation in ROSA is the use of switching controls. Instead of attempting to provide a reward at every timestep, the Shaper makes a binary decision at each state: whether or not to "switch on" a shaping reward. This approach offers several advantages:

  • Efficiency: It reduces the Shaper's decision space to identifying critical "bottleneck" states or subgoals.
  • Focus: An associated switching cost incentivizes the Shaper to be selective, focusing only on states that are truly instrumental to the Controller's success.

Theoretical Guarantees

The authors utilize Potential-Based Reward Shaping to ensure two critical properties:

  1. Policy Invariance: The addition of the Shaper does not alter the optimal policy of the original task, preventing the agent from "cheating" by maximizing artificial rewards.
  2. Convergence: The system is formally proven to reach a stable Markov Perfect Equilibrium.

Experimental Evaluation

The authors evaluated ROSA across a variety of environments, including didactic mazes, classic control tasks (Sparse Cartpole), and complex Atari games (Gravitar, Solaris, and Super Mario Brothers).

ROSA ignores 'red herring' distractions that trap curiosity-based methods like RND.

Key Findings

  • Overcoming the 'TV Problem': In environments with 'red herrings'—novel but useless areas—curiosity-based methods like RND often get distracted. ROSA successfully ignores these distractions because they do not contribute to the Controller's goal.
  • Subgoal Discovery: Analysis of the Shaper’s behavior shows it naturally learns to reward 'bottleneck' states, such as doorways, effectively decomposing complex tasks into manageable stages.
  • Plug-and-Play Versatility: ROSA is algorithm-agnostic. The authors demonstrated significant performance gains when integrating ROSA with established algorithms like PPO and TRPO.
ROSA markedly improves the performance of PPO and TRPO.

Discussion and Conclusion

ROSA represents a significant step toward autonomous reward shaping. By framing the problem as a game of switching controls, it provides a robust mechanism for discovering subgoals without the need for human intervention or the risk of policy distraction common in curiosity-based methods.

While ROSA shows superior performance and stability across diverse benchmarks, it does introduce some computational overhead by training two agents simultaneously. Additionally, performance can be sensitive to the 'switching cost' hyperparameter. Future work may involve developing methods to dynamically tune this cost during training to further enhance autonomy.

Summary updated

Abstract

Reward shaping (RS) is a powerful method in reinforcement learning (RL) for overcoming the problem of sparse or uninformative rewards. However, RS typically relies on manually engineered shaping-reward functions whose construction is time-consuming and error-prone. It also requires domain knowledge which runs contrary to the goal of autonomous learning. We introduce Reinforcement Learning Optimising Shaping Algorithm (ROSA), an automated RS framework in which the shaping-reward function is constructed in a novel Markov game between two agents. A reward-shaping agent (Shaper) uses switching controls to determine which states to add shaping rewards and their optimal values while the other agent (Controller) learns the optimal policy for the task using these shaped rewards. We prove that ROSA, which easily adopts existing RL algorithms, learns to construct a shaping-reward function that is tailored to the task thus ensuring efficient convergence to high performance policies. We demonstrate ROSA's congenial properties in three carefully designed experiments and show its superior performance against state-of-the-art RS algorithms in challenging sparse reward environments.
BibTeX
@inproceedings{mguni2023learning,
  author = {David Mguni and Jianhong Wang and Taher Jafferjee and Nicolas Perez Nieves and Wenbin Song and Yaodong Yang and Feifei Tong and Hui Chen and Jiangcheng Zhu and Yali Du and Jun Wang},
  title = {{Learning to Shape Rewards using a Game of Switching Controls}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i10.26371},
}
Figure