Counting Linear Extensions in Practice: MCMC Versus Exponential Monte Carlo

Topi Talvitie, Kustaa Kangas, Teppo Mikael Niinimäki, Mikko Koivisto

Counting the number of ways to totally order a partially ordered set (poset)—known as counting linear extensions—is a classic problem in combinatorics with heavy-duty applications in Bayesian inference, preference reasoning, and sequence analysis. Unfortunately, it is also #P-complete, meaning we don't expect to find an exact polynomial-time algorithm anytime soon.

In this paper, researchers from the University of Helsinki and Aalto University bridge the gap between theoretical complexity and practical performance. They introduce a new approximation scheme that, surprisingly, leverages exact exponential-time algorithms to outperform standard Markov Chain Monte Carlo (MCMC) methods by orders of magnitude on moderately sized problems.

Enhancing MCMC with Structure Decomposition

The authors first improve the standard "Telescopic Product" MCMC estimator by introducing Structure Decomposition. By using a Quicksort-like heuristic to choose pivot elements, they can recursively split a poset into disjoint components using known reduction rules. This significantly reduces the number of samples needed and the complexity of each sampling step.

Structure Decomposition of a poset into smaller components.

This tweak proves that even for MCMC, respecting the combinatorial properties of the poset (like connectivity and series-parallel components) yields a 1–2 order of magnitude speedup.

Adaptive Relaxation Monte Carlo (ARMC)

The paper's centerpiece is Adaptive Relaxation Monte Carlo (ARMC). Instead of building up a total order (the MCMC approach), ARMC starts with the full poset and relaxes it by removing constraints until the problem becomes small enough for an exact dynamic programming (DP) algorithm to solve.

The algorithm partitions the elements into small blocks of size $k$, ignores constraints between different blocks, and uses exact DP to count extensions in this relaxed version. Finally, it uses Monte Carlo sampling to estimate a "correction factor"—the probability that a random linear extension of the relaxed poset also satisfies the original, removed constraints.

Balancing DP and sampling time in ARMC as a function of block size k.

The authors include an Adaptive Balancing strategy that automatically tunes the block size $k$ to find the "sweet spot" where the time spent on exact DP and the time spent on sampling are balanced, as shown in the plots above.

Key Results and Practical Performance

The authors evaluated their schemes on several classes of posets ranging from 8 to 512 elements, including random DAGs and real-world Bayesian Networks.

  • ARMC Dominance: On almost all test cases with up to ~100–200 elements, ARMC was the clear winner. In many instances, it provided a factor-of-2 approximation in seconds, while the best MCMC methods took hours.
  • MCMC Scaling: As predicted by theory, MCMC growth is polynomial. While slower initially, MCMC will eventually overtake ARMC as $n$ approaches 500+, where the exponential cost of the DP phase becomes prohibitive.
  • The "Exponential Wall": Exact DP algorithms for this problem are highly optimized. ARMC exploits this by pushing the DP as far as it can go before handing the rest of the work to a statistical estimator.

Limitations and Future Work

While powerful, ARMC faces memory constraints during the exact DP phase ($O(2^n)$ in the worst case). On very dense or large posets, the algorithm may run out of RAM. Future work could involve more "intelligent" search strategies for choosing which constraints to remove or leveraging parallelization, which might shift the advantage back to MCMC in high-performance computing environments.

Summary updated

BibTeX
@inproceedings{talvitie2018counting,
  author = {Topi Talvitie and Kustaa Kangas and Teppo Mikael Niinimäki and Mikko Koivisto},
  title = {{Counting Linear Extensions in Practice: MCMC Versus Exponential Monte Carlo}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.11528},
}
Figure