Programmable Restoration Granularity in Constraint Programming

Yong LinarXiv 2016

Introduction

In Constraint Programming (CP), solving complex combinatorial problems requires exploring vast search trees. When a solver encounters a dead end (a failure), it must backtrack to a previous valid state. This process, known as restoration, is a critical component of solver performance. Historically, CP systems have relied on fixed restoration strategies: Copying (fast but memory-intensive), Recomputation (memory-efficient but CPU-intensive), or Trailing/Recollection (a middle-ground approach).

However, search trees are rarely uniform. The stable "trunk" at the top of a tree behaves differently than the volatile "branches" at the bottom where most failures occur. This paper introduces a method to dynamically adjust "restoration granularity," allowing solvers to switch strategies based on their position in the search tree to optimize both memory and execution speed.

The Problem: One-Size-Fits-All Restoration

Traditional CP solvers apply a single restoration strategy across the entire search space. This is often inefficient because the computational cost of saving state information is wasted in areas of the tree where backtracking is infrequent. Conversely, in areas with high failure rates, the cost of re-running logic from scratch can lead to significant performance bottlenecks. The authors argue that restoration should be "programmable" and adaptive to the specific topology of the search.

Methods: Border Levels and Aspect-Oriented Programming

The authors propose a hybrid prototype integrated into the Gecode library, utilizing two primary innovations:

1. The "Border Level" Strategy

This heuristic monitors the search process to identify a transition point. Until the first failure is detected, the solver assumes the path is stable and utilizes pure recomputation, storing minimal state data. Once a failure occurs, that depth is marked as the "border level." Below this border, the solver switches to a more intensive hybrid of copying and recollection to handle frequent backtracking efficiently.

Table 1: Search tree statistics showing the depth of the first failure and the distribution of failures across different tree segments.

As shown in the data above, many problems exhibit a long initial path without failures. For instance, in the Queens(200) benchmark, the first failure does not occur until depth 164, meaning any state saved before that point is redundant.

2. Aspect-Oriented Programming (AOP)

To maintain code modularity, the authors treat restoration as a "crosscutting concern." Using AspectC++, they decouple restoration logic from the core search engine. This allows different restoration behaviors to be "plugged in" at specific points (pointcuts) in the search process without cluttering the primary algorithm with complex conditional logic.

Key Results

The hybrid prototype was evaluated against four classic benchmarks: Queens(200), Queens-S(200), Knights(22), and Sport-League(22). The results demonstrate that programmable granularity can achieve massive memory savings while maintaining competitive runtimes.

Table 2: Performance comparison of Recomputation, Recollection, and the proposed Prototype across various benchmarks.

Performance Highlights:

  • Memory Efficiency: For the Queens-S(200) problem, the prototype required only 542 KB of memory, a significant reduction compared to 1,485 KB for recomputation and 3,974 KB for recollection.
  • Stability in Complex Trees: In the Knights(22) problem, memory consumption was nearly halved (2,333 KB vs. ~4,500 KB for other methods) while maintaining a runtime of 1,744ms, which was faster than the standard recomputation approach (1,858ms).
  • Negligible Overhead: In almost all test cases, the runtime of the hybrid prototype remained within a few percentage points of the fastest specialized method, proving that the overhead of switching strategies dynamically is minimal.

Conclusion and Future Work

By treating restoration granularity as a programmable aspect of the search, the authors have shown that solvers can be made significantly more memory-efficient without sacrificing speed. While the current "first failure" heuristic is effective, future work may involve developing more sophisticated, dynamic heuristics that can adapt to multiple border levels or different types of constraints, such as continuous or set-based variables. This research paves the way for more flexible, user-customized solvers that can handle increasingly large-scale combinatorial problems.

Summary updated

BibTeX
@misc{lin2016programmable,
  author = {Yong Lin},
  title = {{Programmable Restoration Granularity in Constraint Programming}},
  year = {2016},
  eprint = {1601.06517},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1601.06517},
}
Figure