Value Ordering for Finding All Solutions

Barbara M. Smith, Paula SturdyIJCAI 2005

Abstract

In Constraint Satisfaction Problems (CSPs), the order in which variables are assigned values is a well-studied heuristic for finding a single solution quickly. However, conventional wisdom has long held that value ordering is irrelevant when the goal is to find all solutions, as the entire search space must eventually be traversed. This paper debunks this myth, showing that when modern "binary branching" is employed, a strategic value ordering can prune the search space by up to 50%. The key lies in the propagation of the negative constraint—the information that a specific value was not chosen—which can trigger significant domain reductions in other variables.

The Mechanics of Branching

Solvers typically navigate CSPs by selecting a variable and branching on its possible values. Historically, this was done via $k$-way branching, where a node with $k$ possible values creates $k$ independent children. In this model, the order of those children indeed has no impact on the total number of nodes visited when searching for all solutions.

Modern solvers, however, frequently use binary branching. In this approach, the solver makes a choice: either "Variable $X$ equals value $V$" (the left branch) or "Variable $X$ does not equal value $V$" (the right branch).

Binary branching search tree showing the propagation of value exclusions.

The critical insight is that the right branch ($X \neq V$) is a new constraint. This constraint can be propagated through the problem's existing constraints to shrink the domains of other variables before the next branching decision is made. Consequently, the order in which values are tried determines which negative constraints are added first, potentially pruning entire subtrees that a $k$-way branching solver would be forced to explore.

Methodology and Heuristics

The authors evaluated the impact of value ordering across several combinatorial benchmarks, including Golomb Rulers, Graceful Labeling of graphs, Langford’s Problem, and $n$-Queens. They compared $k$-way branching against binary branching using various heuristics:

  • Increasing/Decreasing Order: Selecting values from smallest to largest or vice versa.
  • dualsdf: A heuristic for permutation problems that selects values appearing in the fewest remaining domains.
  • Anti-promise: A heuristic designed to maximize the impact of symmetry-breaking constraints by intentionally picking "difficult" values.

The effectiveness of these orderings is most pronounced in problems featuring monotonic constraints (e.g., $X < Y$) or global constraints (e.g., allDifferent). For instance, if $X < Y$ and the solver determines $X \neq 1$, it may immediately propagate that $Y$ cannot be 2, reducing the search space for $Y$ before it is even selected for branching.

Experimental Results

The most dramatic results were observed in the Golomb Ruler problem. Finding an 11-mark ruler using an increasing value order with binary branching required only 117,251 backtracks. In contrast, $k$-way branching required 227,815 backtracks—a reduction of nearly 50%.

Search effort (backtracks) for Golomb Rulers using different value orderings.

Similar trends were seen in Graceful Labeling, where specific value orderings combined with binary branching were twice as fast as $k$-way branching for certain variable orders. However, the authors noted a trade-off: while binary branching consistently reduces the number of backtracks, it introduces computational overhead due to the additional propagation steps at every right branch. In problems with "weak" constraints that don't lead to significant domain reductions, such as $n$-Queens without symmetry breaking, $k$-way branching can occasionally be faster in terms of total wall-clock time despite performing more search.

Synergy with Symmetry Breaking

The paper also highlights a powerful synergy between value ordering and Symmetry Breaking During Search (SBDS). By using an "anti-promise" value ordering, the solver can intentionally trigger symmetry-breaking constraints earlier in the search process. This proactive pruning prevents the solver from exploring symmetric regions of the search space, leading to significant efficiency gains that are unavailable to $k$-way branching.

Conclusion

This research demonstrates that value ordering is a vital consideration for all-solutions search in modern CSP solvers. By leveraging the pruning power of negative constraints in binary branching, search effort can be halved in many combinatorial problems. Future work suggests that solvers could be enhanced to automatically detect the most effective value ordering by analyzing the underlying constraint graph, moving toward more autonomous and efficient constraint satisfaction.

Summary updated

BibTeX
@inproceedings{smith2005value,
  author = {Barbara M. Smith and Paula Sturdy},
  title = {{Value Ordering for Finding All Solutions}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2005},
}
Figure