Improved Algorithms for Counting Solutions in Constraint Satisfaction Problems

  • Ola Angelsmark
  • Peter Jonsson
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2833)


Counting the number of solutions to CSP instances has vast applications in several areas ranging from statistical physics to artificial intelligence. We provide a new algorithm for counting the number of solutions to binary Csp s which has a time complexity ranging from \(\mathcal{O}\left((d/4 \cdot \alpha^4)^n\right)\) to \(\mathcal{O}\left((\alpha+\alpha^5 + \lfloor d/4-1 \rfloor \cdot \alpha^4)^n\right)\) (where α ≈ 1.2561) depending on the domain size d ≥ 3. This is substantially faster than previous algorithms, especially for small d. We also provide an algorithm for counting k-colourings in graphs and its running time ranges from \(\mathcal{O}\left(\lfloor\log_2 k\rfloor^n\right)\) to \(\mathcal{O}\left(\lfloor\log_2 k+1\rfloor^n\right)\) depending on k ≥ 4. Previously, only an \(\mathcal{O}\left(1.8171^n\right)\) time algorithm for counting 3-colourings were known, and we improve this upper bound to \(\mathcal{O}\left(1.7879^n\right)\).


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Angelsmark, O., Jonsson, P., Linusson, S., Thapper, J.: Determining the number of solutions to a binary csp instance. In: Van Hentenryck, P. (ed.) CP 2002. LNCS, vol. 2470, p. 327. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  2. 2.
    Aspvall, B., Plass, M.F., Tarjan, R.E.: A linear time algorithm for testing the truth of certain quantified Boolean formulas. Information Processing Letters 8(3), 121–123 (1979)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Bayardo Jr, R.J., Pehoushek, J.D.: Counting models using connected components. In: Proceedings of the 17th National Conference on Artificial Intelligence and 12th Conference on Innovative Applications of Artificial Intelligence AAAI/IAAI, pp. 157–162 (2000)Google Scholar
  4. 4.
    Beigel, R.: Finding maximum independent sets in sparse and general graphs. In: Proceedings of the Tenth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA-1999), pp. 856–857 (1999)Google Scholar
  5. 5.
    Bulatov, A., Dalmau, V.: Towards a dichotomy theorem for the counting constraint satisfaction problem. Technical report, Computing Laboratory, Oxford University (2003), Available from Google Scholar
  6. 6.
    Creignou, N., Hermann, M.: Complexity of generalized satisfiability counting problems. Information and Computation 125, 1–12 (1996)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Dahllöf, V., Jonsson, P., Wahlström, M.: Counting satisfying assignments in 2-SAT and 3-SAT. In: Ibarra, O.H., Zhang, L. (eds.) COCOON 2002. LNCS, vol. 2387, pp. 535–543. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  8. 8.
    Darwiche, A.: On the tractable counting of theory models and its applications to truth maintenance and belief revision. Journal of Applied Non-Classical Logic 11(1–2), 11–34 (2001)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Dubois, O.: Counting the number of solutions for instances of satisfiability. Theoretical Computer Science 81(1), 49–64 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Dyer, M., Greenhill, C.: The complexity of counting graph homomorphisms. Random Structures and Algorithms 17, 260–289 (2000)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Jeavons, P.G., Cohen, D.A., Pearson, J.K.: Constraints and universal algebra. Annals of Mathematics and Artificial Intelligence 24, 51–67 (1998)zbMATHCrossRefMathSciNetGoogle Scholar
  12. 12.
    Jégou, P.: Decomposition of domains based on the micro-structure of finite constraint-satisfaction problems. In: Proceedings of the 11th (US) National Conference on Artificial Intelligence (AAAI 1993), Washington DC, USA, July 1993, pp. 731–736; American Association for Artificial Intelligence (1993)Google Scholar
  13. 13.
    Kullman, O.: New methods for 3-SAT decision and worst-case analysis. Theoretical. Computer Science 223, 1–72 (1999)CrossRefMathSciNetGoogle Scholar
  14. 14.
    Kumar, V.: Algorithms for constraint-satisfaction problems: A survey. AI Magazine 13(1), 32–44 (1992)Google Scholar
  15. 15.
    Littman, M.L., Pitassi, T., Impagliazzo, R.: On the complexity of counting satisfying assignments (2001) (unpublished manuscript)Google Scholar
  16. 16.
    Montanari, U.: Networks of constraints: Fundamental properties and applications to picture processing. Information Sciences 7, 95–132 (1974)CrossRefMathSciNetGoogle Scholar
  17. 17.
    Roth, D.: On the hardness of approximate reasoning. Artificial Intelligence 82, 273–302 (1996)CrossRefMathSciNetGoogle Scholar
  18. 18.
    Satish Kumar, T.K.: A model counting characterization of diagnoses. In: Proceedings of the Thirteenth International Workshop on Principles of Diagnosis, pp. 70–76 (2002)Google Scholar
  19. 19.
    Valiant, L.G.: The complexity of computing the permanent. Theoretical Computer Science 8(2), 189–201 (1979)zbMATHCrossRefMathSciNetGoogle Scholar
  20. 20.
    Valiant, L.G.: The complexity of enumeration and reliability problems. SIAM Journal on Computing 8(3), 410–421 (1979)zbMATHCrossRefMathSciNetGoogle Scholar
  21. 21.
    Wahlström, M.: An algorithm for #2SAT. Technical report, Department of Computer Science, Linköping, Sweden. In preparation. Preliminary version (2003), available from

Copyright information

© Springer-Verlag Berlin Heidelberg 2003

Authors and Affiliations

  • Ola Angelsmark
    • 1
  • Peter Jonsson
    • 1
  1. 1.Department of Computer and Information ScienceLinköpings UniversitetLinköpingSweden

Personalised recommendations