Skip to main content

Practically Uniform Solution Sampling in Constraint Programming

  • Conference paper
  • First Online:
Integration of Constraint Programming, Artificial Intelligence, and Operations Research (CPAIOR 2022)

Abstract

The ability to sample solutions of a constrained combinatorial space has important applications in areas such as probabilistic reasoning and hardware/software verification. A highly desirable property of such samples is that they should be drawn uniformly at random, or at least nearly so. For combinatorial spaces expressed as sat models, approaches based on universal hashing provide probabilistic guarantees about sampling uniformity. In this short paper, we apply that same approach to cp models, for which hashing functions take the form of linear constraints in modular arithmetic. We design an algorithm to generate an appropriate combination of linear modular constraints given a desired sample size. We evaluate empirically the sampling uniformity and runtime efficiency of our approach, showing it to be near-uniform at a fraction of the time needed to draw from the complete set of solutions.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 69.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 89.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    i.e. each congruent to one of \(\{0,1,\ldots ,c[i]\}\). We need to add \(\boldsymbol{b}\) in the inequalities because otherwise the probability that e.g. the null solution \(\boldsymbol{x=0}\) satisfies the inequality would be equal to 1.

  2. 2.

    https://en.wikipedia.org/wiki/Trial_division.

  3. 3.

    The sampling method is implemented in the MiniCPBP solver https://github.com/PesantGilles/MiniCPBP and our examples on how to use the method are available https://github.com/363734/UniformSampling.

  4. 4.

    The statistical library used is “Apache Commons Mathematics Library” (https://commons.apache.org/proper/commons-math/).

References

  1. Chakraborty, S., Meel, K.S., Mistry, R., Vardi, M.Y.: Approximate probabilistic inference via word-level counting. In: Schuurmans, D., Wellman, M.P. (eds.) Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence, 12–17 February 2016, Phoenix, Arizona, USA, pp. 3218–3224. AAAI Press (2016)

    Google Scholar 

  2. Chakraborty, S., Meel, K.S., Vardi, M.Y.: A scalable approximate model counter. In: Schulte, C. (ed.) CP 2013. LNCS, vol. 8124, pp. 200–216. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-40627-0_18

    Chapter  Google Scholar 

  3. Domshlak, C., Hoffmann, J.: Probabilistic planning via heuristic forward search and weighted model counting. J. Artif. Intell. Res. 30, 565–620 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  4. Dutra, R.T.: Efficient sampling of SAT and SMT solutions for testing and verification. Ph.D. thesis, University of California, Berkeley (2019)

    Google Scholar 

  5. Fichte, J.K., Hecher, M., Hamiti, F.: The model counting competition 2020. J. Exp. Algorithmics (JEA) 26, 1–26 (2021)

    Article  MathSciNet  MATH  Google Scholar 

  6. Gogate, V., Dechter, R.: A new algorithm for sampling CSP solutions uniformly at random. In: Benhamou, F. (ed.) CP 2006. LNCS, vol. 4204, pp. 711–715. Springer, Heidelberg (2006). https://doi.org/10.1007/11889205_56

    Chapter  Google Scholar 

  7. Meel, K.S., et al.: Constrained sampling and counting: universal hashing meets SAT solving. In: Darwiche, A. (ed.) Beyond NP, Papers from the 2016 AAAI Workshop, Phoenix, Arizona, USA, 12 February 2016, volume WS-16-05 of AAAI Workshops. AAAI Press (2016)

    Google Scholar 

  8. Perez, G., Régin, J.-C.: MDDs: sampling and probability constraints. In: Beck, J.C. (ed.) CP 2017. LNCS, vol. 10416, pp. 226–242. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-66158-2_15

    Chapter  Google Scholar 

  9. Pesant, G., Meel, K.S., Mohammadalitajrishi, M.: On the usefulness of linear modular arithmetic in constraint programming. In: Stuckey, P.J. (ed.) CPAIOR 2021. LNCS, vol. 12735, pp. 248–265. Springer, Cham (2021). https://doi.org/10.1007/978-3-030-78230-6_16

    Chapter  MATH  Google Scholar 

  10. Sang, T., Beame, P., Kautz, H.A.: Performing Bayesian inference by weighted model counting. In: AAAI, vol. 5, pp. 475–481 (2005)

    Google Scholar 

  11. Vavrille, M., Truchet, C., Prud’homme, C.: Solution sampling with random table constraints. In: Michel, L.D. (ed.) 27th International Conference on Principles and Practice of Constraint Programming, CP 2021, Montpellier, France (Virtual Conference), 25–29 October 2021. LIPIcs, vol. 210, pp. 56:1–56:17. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2021)

    Google Scholar 

Download references

Acknowledgements

We thank the anonymous reviewers for their constructive criticism which helped us improve the original version of the paper. Financial support for this research was provided in part by NSERC Discovery Grants 218028/2017 and 05953/2016.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hélène Verhaeghe .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Pesant, G., Quimper, CG., Verhaeghe, H. (2022). Practically Uniform Solution Sampling in Constraint Programming. In: Schaus, P. (eds) Integration of Constraint Programming, Artificial Intelligence, and Operations Research. CPAIOR 2022. Lecture Notes in Computer Science, vol 13292. Springer, Cham. https://doi.org/10.1007/978-3-031-08011-1_22

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-08011-1_22

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-08010-4

  • Online ISBN: 978-3-031-08011-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics