Combining Reinforcement Learning and Constraint Programming for Combinatorial Optimization

Quentin Cappart, Thierry Moisan, Louis-Martin Rousseau, Isabeau Prémont-Schwarz, André A. Ciré

Combinatorial Optimization Problems (COPs)—such as routing delivery trucks, scheduling tasks, or optimizing financial portfolios—are notoriously difficult because the number of possible solutions grows exponentially with problem size. Historically, researchers have relied on two distinct approaches: exact algorithms like Constraint Programming (CP), which guarantee optimality but scale poorly, and learning-based heuristics like Deep Reinforcement Learning (DRL), which are fast but cannot guarantee feasibility or optimality. This paper introduces a hybrid framework that bridges these two worlds.

The Hybrid Framework: Dynamic Programming as a Bridge

The core innovation of this research is using Dynamic Programming (DP) as a "Rosetta Stone" to translate between the learning and solving phases. Because DP naturally defines states, actions, and transitions, it maps cleanly to both an RL environment (a Markov Decision Process) and a CP model (variables and constraints).

The hybrid framework architecture showing the learning phase, the unifying DP representation, and the solving phase.

Methodology

  1. Unifying Representation: The COP is first formulated as a DP model.
  2. RL Encoding: The DP is translated into an RL environment where an agent (using DQN or PPO) learns to navigate the state space. To handle variable problem sizes, the authors employ Graph Attention Networks (GAT) or Set Transformers.
  3. CP Encoding: The same DP is translated into a CP model, where transitions become constraints and rewards become the objective function.
  4. Hybrid Search: The trained RL agent is integrated into the CP solver as a value-selection heuristic. The solver uses strategies like Depth-First Branch-and-Bound (BaB) or Restart-Based Search (RBS), guided by the neural network's "intuition."
  5. Caching: To mitigate the computational cost of neural network inference, a cache stores and reuses predictions for previously visited states, reducing heuristic execution time from 34ms to 0.16ms per node.

Experimental Results

The authors evaluated their framework on three classic NP-hard problems: the Traveling Salesman Problem with Time Windows (TSPTW), Portfolio Optimization (PORT), and the 0-1 Knapsack Problem (KNAP).

Performance on TSPTW

On the most challenging 100-city TSPTW instances, the hybrid BaB-DQN* method (with caching) proved optimality in 91% of cases within an average of 15 minutes. In stark contrast, standard CP models, Google's OR-Tools, and standalone RL agents failed to solve a single instance of this size.

Performance comparison on TSPTW instances of varying sizes (20, 50, and 100 cities).

Generality and Robustness

  • Portfolio Optimization: The hybrid approach successfully handled discrete, non-linear versions of the portfolio problem, outperforming specialized non-linear solvers like KNITRO and APOPT on smaller instances and remaining competitive on larger ones.
  • Knapsack Problem: While dedicated integer programming solvers (like COIN-OR) remain superior for linear problems, the hybrid RBS-PPO method proved to be the strongest among all non-MIP baselines.

Key Insights

  • Reward Shaping: For highly constrained problems like TSPTW, the authors designed a two-part reward system that prioritizes finding any feasible solution before focusing on optimization.
  • Generality: Unlike many machine learning approaches for optimization that are hardcoded for specific problems (like TSP), this framework can handle non-linear constraints and objectives simply by updating the underlying DP formulation.

Limitations and Future Work

Despite the success of caching, neural network inference remains a bottleneck in the solver loop. Future research directions include compressing neural networks via knowledge distillation to speed up inference and extending the RL agent to learn variable ordering in addition to value selection. Additionally, the framework's performance currently depends on the availability of a data generator that accurately reflects real-world instance distributions.

Summary updated

BibTeX
@inproceedings{cappart2021combining,
  author = {Quentin Cappart and Thierry Moisan and Louis-Martin Rousseau and Isabeau Prémont-Schwarz and André A. Ciré},
  title = {{Combining Reinforcement Learning and Constraint Programming for Combinatorial Optimization}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i5.16484},
}
Figure