COOL-MC: A Comprehensive Tool for Reinforcement Learning and Model Checking

Dennis Gross, Nils Jansen, Sebastian Junges, Guillermo A. Pérez · DOI

TL;DR

This paper introduces COOL-MC, a novel tool that bridges the gap between reinforcement learning (RL) and formal model checking. It allows researchers to train RL agents in standard environments like OpenAI Gym and then rigorously verify their learned policies against formal specifications using the Storm model checker, offering guarantees on safety and performance.

What Problem Does This Paper Address?

Deep reinforcement learning (RL) has shown remarkable success in training agents for complex dynamic systems. However, a critical challenge is ensuring that these learned policies behave safely and reliably, especially in safety-critical domains like transportation or energy. Traditional RL reward functions often lack the expressiveness to encode complex safety requirements, and it's difficult to guarantee that a policy trained to a certain point is sufficient. While model checking offers a way to formally verify system properties, integrating it with state-of-the-art deep RL policies has been hindered by incompatibilities between RL environments and formal models, as well as a lack of mature, tightly integrated tools. This paper addresses this gap by providing a unified framework for training and verifying RL policies.

Methods

COOL-MC integrates the popular OpenAI Gym for RL training with the probabilistic model checker Storm. Its core methodology involves:

  • Simulator for RL Training: It uses OpenAI Gym environments to train RL policies. These environments can be directly mapped to Markov Decision Processes (MDPs) that are compatible with Storm.
  • On-the-Fly Model Builder: A key innovation is the ability to build an induced Discrete-Time Markov Chain (DTMC) from a trained RL policy during the verification process. This is achieved using Storm's callback functions, which query the neural network policy for actions at each state and incrementally expand the model. This approach is architecture-agnostic for the RL policies.
  • Formal Abstractions: To bridge potential discrepancies between the RL environment and the formal model, COOL-MC supports two types of abstractions:
  • Feature Abstraction: This allows for creating "permissive" policies that group certain state features, enabling analysis of best- and worst-case performance bounds.
  • Feature Remapping: This technique transforms feature values before feeding them into the policy, allowing for evaluation under different or abstracted feature representations.
  • Algorithms for Performance Bounds: The tool provides algorithms to compute bounds on the performance of these abstracted (permissive) policies.

Datasets

The paper evaluates COOL-MC on several standard OpenAI Gym benchmarks, including:

  • Frozen Lake: A grid-world environment where the agent must reach a goal, with a probabilistic movement mechanic (slippery ice).
  • Taxi: An environment where the agent must pick up and transport passengers to destinations while managing fuel.
  • Collision Avoidance: A 2D grid world with moving obstacles.
  • Smart Grid: An environment for energy production distribution control.
  • Stock Market: A simplified stock market simulation.
  • James Bond & Crazy Climber: Atari game abstractions.

The authors also mention that COOL-MC can handle MDPs from the Quantitative Verification Benchmark Set.

Key Insights and Ideas

  • Bridging the RL-Verification Chasm: The most significant insight is the successful integration of state-of-the-art RL training with formal model checking, a feat that has been challenging due to practical incompatibilities.
  • On-the-Fly DTMC Construction: Building the induced DTMC incrementally from the policy is a clever way to handle complex neural network policies without requiring explicit, potentially massive, formal models beforehand. This makes verification more scalable.
  • The Power of Abstraction: Feature abstraction and remapping are crucial for making verification tractable and for analyzing policies under uncertainty or with limited sensor information. This allows for a more nuanced understanding of policy behavior beyond just a single outcome.
  • Guarantees for RL Agents: The tool moves beyond simply training RL agents to providing formal guarantees, which is essential for deploying RL in safety-critical applications.

Key Results

  • Successful Verification: COOL-MC successfully verified trained RL policies on various benchmarks, demonstrating its practical applicability. For instance, in the Frozen Lake environment, it showed that a trained policy learned to account for the slippery ice, achieving a high probability of reaching the goal.
  • Performance Bounds: The tool was able to compute performance bounds for permissive policies in the Taxi environment, illustrating how abstractions can provide insights into worst-case scenarios.
  • Scalability: While large MDPs can overwhelm Storm, COOL-MC's DTMC construction can handle up to 11x11 collision avoidance environments with a certain slickness, though model building time can be a bottleneck. For example, a 10x10 collision avoidance MDP with 1M states and ~29M transitions was manageable.
  • Benchmark Performance: Table 1 provides a comprehensive overview of benchmark performance, detailing states, transitions, build times, and check times for various environments and policies.

Limitations and Future Work

  • Scalability Bottleneck: The paper acknowledges that model building time can be a bottleneck for very large state spaces, even if model checking itself is efficient.
  • Future Work: The authors plan to:
  • Directly incorporate safe RL approaches.
  • Extend the model expressivity to handle Partially Observable MDPs (POMDPs).

Summary updated

BibTeX
@inproceedings{gross2022cool,
  author = {Dennis Gross and Nils Jansen and Sebastian Junges and Guillermo A. Pérez},
  title = {{COOL-MC: A Comprehensive Tool for Reinforcement Learning and Model Checking}},
  booktitle = {SETTA},
  year = {2022},
  doi = {10.1007/978-3-031-21213-0\_3},
}
Figure