Abstract
We provide several algorithms for the exact, uniform random sampling of Latin squares and Sudoku matrices via probabilistic divide-and-conquer (PDC). Our approach divides the sample space into smaller pieces, samples each separately, and combines them in a manner which yields an exact sample from the target distribution. We demonstrate, in particular, a version of PDC in which one of the pieces is sampled using a brute force approach, which we dub almost deterministic second half, as it is a generalization to a previous application of PDC for which one of the pieces is uniquely determined given the others.
Similar content being viewed by others
Notes
This number can be simplified to 71 after taking more symmetries into account [18].
1.8 GHz Intel Core i7.
References
Arratia, R., DeSalvo, S.: Poisson and independent process approximation for random combinatorial structures with a given number of components, and near-universal behavior for low rank assemblies. arXiv preprint arXiv:1606.04642 (2016)
Arratia, R., DeSalvo, S.: Probabilistic divide-and-conquer: a new exact simulation method, with integer partitions as an example. Comb. Probab. Comput. 25(3), 324–351 (2016)
Colbourn, C.J.: The complexity of completing partial latin squares. Discrete Appl. Math. 8(1), 25–30 (1984)
Dahl, G.: Permutation matrices related to sudoku. Linear Algebra Appl. 430(8), 2457–2463 (2009)
DeSalvo, S.: Probabilistic divide-and-conquer: deterministic second half. arXiv preprint arXiv:1411.6698 (2014)
DeSalvo, S.: Improvements to exact Boltzmann sampling using probabilistic divide-and-conquer and the recursive method. arXiv preprint arXiv:1608.07922 (2016)
Devroye, L.: Nonuniform random variate generation. Handb. Oper. Res Manag. Sci. 13, 83–121 (2006)
Diaconis, P., Sturmfels, B., et al.: Algebraic algorithms for sampling from conditional distributions. Ann. Stat. 26(1), 363–397 (1998)
Duchon, P., Flajolet, P., Louchard, G., Schaeffer, G.: Boltzmann samplers for the random generation of combinatorial structures. Combin. Probab. Comput. 13(4–5), 577–625 (2004)
Felgenhauer, B., Jarvis, F.: Mathematics of sudoku i. Math. Spectr. 39(1), 15–22 (2006)
Flajolet, P., Sedgewick, R.: Analytic Combinatorics. Cambridge University Press, Cambridge (2009)
Fontana, R.: Fractions of permutations. an application to sudoku. J. Stat. Plan. Inference 141(12), 3697–3704 (2011)
Fontana, R.: Random latin squares and sudoku designs generation. arXiv preprint arXiv:1305.3697 (2013)
Fontana, R., Rapallo, F., Rogantin, M.P.: Markov bases for sudoku grids. In: Advanced Statistical Methods for the Analysis of Large Data-Sets, pages 305–315. Springer, (2012)
Godsil, C.D., McKay, B.D.: Asymptotic enumeration of latin rectangles. J. Comb. Theory Ser. B 48(1), 19–44 (1990)
Huber, M.L.: Perfect Simulation. Chapman & Hall/CRC Monographs on Statistics & Applied Probability. Taylor & Francis, (2015)
Jacobson, M.T., Matthews, P.: Generating uniformly distributed random latin squares. J. Comb. Des. 4(6), 405–437 (1996)
Jarvis, F..: Website of Frazer Jarvis. http://www.afjarvis.staff.shef.ac.uk/sudoku/bertram.html (2005)
Jerrum, M., Sinclair, A., Vigoda, E.: A polynomial-time approximation algorithm for the permanent of a matrix with nonnegative entries. J. ACM 51(4), 671–697 (2004). (electronic)
Levin, D.A., Peres, Y., Wilmer, E.L.: Markov Chains and Mixing Times. American Mathematical Soc, Providence (2009)
Newton, P.K., DeSalvo, S.A.: The shannon entropy of sudoku matrices. In: Proceedings of the Royal Society of London A: Mathematical, Physical and Engineering Sciences, page rspa20090522. The Royal Society (2010)
Nijenhuis, A., Wilf, H.S.: A method and two algorithms on the theory of partitions. J. Comb. Theory Ser. A 18, 219–222 (1975)
Nijenhuis, A., Wilf, H.S.: Combinatorial algorithms. Academic Press, Inc. [Harcourt Brace Jovanovich, Publishers], New York-London, second edition, 1978. For computers and calculators, Computer Science and Applied Mathematics (1978)
Random Struct. Algor. Exact sampling with coupled markov chains and applications to statistical mechanics. 9(1–2), 223–252 (1996)
Ridder, A.: Counting the number of sudoku’s by importance sampling simulation (2013)
Russell, E., Jarvis, F.: Mathematics of sudoku II. Math. Spectr. 39(2), 54–58 (2006)
Sloane, N.J.A.: Online Encyclopedia of Integer Sequences. Published electronically at http://www.oeis.org/
Stones, D.S.: The many formulae for the number of Latin rectangles. Electron. J. Comb. 17(1), Article 1 46 (2010)
van Lint, J.H., Wilson, R.M.: A Course in Combinatorics, 2nd edn. Cambridge University Press, Cambridge (2001)
Von Neumann, J.: Various techniques used in connection with random digits. Appl. Math Ser. 12(36–38), 1 (1951)
Yordzhev, K.: On the number of disjoint pairs of s-permutation matrices. Discrete Appl. Math. 161(18), 3072–3079 (2013)
Yordzhev, K.: Random permutations, random sudoku matrices and randomized algorithms. arXiv preprint arXiv:1312.0192, (2013)
Acknowledgments
The author would like to acknowledge helpful conversations with James Zhao and Edo Liberty, and also helpful comments from an anonymous reviewer.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
Cite this article
DeSalvo, S. Exact Sampling Algorithms for Latin Squares and Sudoku Matrices via Probabilistic Divide-and-Conquer. Algorithmica 79, 742–762 (2017). https://doi.org/10.1007/s00453-016-0223-y
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00453-016-0223-y