NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Structure Detection for Contextual Reinforcement Learning

Tianyue Zhou, Jung-Hoon Cho, Cathy Wu

Abstract

Contextual Reinforcement Learning (CRL) tackles the problem of solving a set of related Contextual Markov Decision Processes (CMDPs) that vary across different context variables. Traditional approaches—independent training and multi-task learning—struggle with either excessive computational costs or negative transfer. A recently proposed multi-policy approach, Model-Based Transfer Learning (MBTL), has demonstrated effectiveness by strategically selecting a few tasks to train and zero-shot transfer. However, CMDPs encompass a wide range of problems, exhibiting structural properties that vary from problem to problem. As such, different task selection strategies are suitable for different CMDPs. In this work, we introduce Structure Detection MBTL (SD-MBTL), a generic framework that dynamically identifies the underlying generalization structure of CMDP and selects an appropriate MBTL algorithm. For instance, we observe Mountain structure in which generalization performance degrades from the training performance of the target task as the context difference increases. We thus propose M/GP-MBTL, which detects the structure and adaptively switches between a Gaussian Process-based approach and a clustering-based approach. Extensive experiments on synthetic data and CRL benchmarks—covering continuous control, traffic control, and agricultural management—show that M/GP-MBTL surpasses the strongest prior method by 12.49% on the aggregated metric. These results highlight the promise of online structure detection for guiding source task selection in complex CRL environments.

Introduction

Real-world reinforcement learning often involves families of related tasks that share underlying dynamics but differ in key parameters—like a robot carrying different payload weights or a traffic grid managing varying vehicle inflows. These are modeled as Contextual Markov Decision Processes (CMDPs).

To solve CMDPs, standard options like independent training (training a separate policy for every context) or multi-task learning (training one universal policy) often fail due to prohibitive computational costs or "negative transfer," where dissimilar tasks interfere with each other. A more efficient alternative is multi-policy training: training expert policies on a small subset of "source tasks" and zero-shot transferring them to the rest. However, this introduces a significant challenge: how to choose the optimal source tasks. Existing methods like Model-Based Transfer Learning (MBTL) often rely on a rigid Gaussian Process (GP) approach, which may not be optimal for the diverse structural properties found across different CMDPs.

The SD-MBTL Framework

The authors propose Structure Detection Model-Based Transfer Learning (SD-MBTL), a meta-framework that observes early generalization performance, detects the structural pattern of the CMDP, and routes the task-selection job to the best-suited algorithm.

The SD-MBTL framework dynamically detects CMDP structure to select the most appropriate task selection algorithm.

A key contribution is the identification of the MOUNTAIN structure. In this structure, generalization performance drops linearly as the distance between the source and target contexts increases. The framework is instantiated as M/GP-MBTL, which operates as follows:

  1. Structure Detection: It uses variance and slope criteria to check if the CMDP follows the MOUNTAIN structure.
  2. M-MBTL: If a MOUNTAIN structure is detected, it employs a novel sequential clustering algorithm. Since the generalization gap acts like a simple distance metric, finding the best tasks reduces to a fast, sample-efficient clustering problem.
  3. GP-MBTL: If the structure is not detected, it falls back to a revised Gaussian Process-based Bayesian Optimization approach to handle more complex, non-linear generalization gaps.

Experimental Evaluation

The approach was evaluated across synthetic and real-world CMDP benchmarks with 3D to 7D context spaces:

  • Continuous Control: CartPole and BipedalWalker (varying mass, length, friction, etc.).
  • Traffic Control: IntersectionZoo (varying traffic inflow and autonomous vehicle penetration).
  • Agricultural Management: CyclesGym (varying weather conditions).

Results and Discussion

The experimental results demonstrate that M/GP-MBTL effectively leverages structure detection to improve performance across diverse environments.

Performance comparison of M/GP-MBTL against baselines across various CRL benchmarks.

Key findings include:

  • Superior Aggregated Performance: M/GP-MBTL outperforms the previous state-of-the-art (GP-MBTL) by 12.49% on the aggregated metric (0.2930 vs 0.1681).
  • Adaptive Dominance: On tasks following the MOUNTAIN structure (e.g., CyclesGym), the clustering-based M-MBTL dominates. On tasks violating it (e.g., IntersectionZoo), the GP-MBTL fallback successfully maintains high performance, proving the effectiveness of the online detector.
  • Computational Efficiency: M-MBTL offers significant speedups over GP-MBTL by avoiding the heavy cost of retraining Gaussian Processes at every step.

Conclusion

SD-MBTL demonstrates that generalization in RL is not random but follows predictable functional structures. By dynamically switching between specialized algorithms like clustering and robust ones like Gaussian Processes, the framework achieves the "best of both worlds." Future work will explore richer CMDP structures and further refine the efficiency of structure inference in massive context spaces.

Summary updated

BibTeX
@inproceedings{zhou2026structure,
  author = {Tianyue Zhou and Jung-Hoon Cho and Cathy Wu},
  title = {{Structure Detection for Contextual Reinforcement Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i34.40137},
}
Figure