Several examples related to the article Counting and generating permutations in regular classes, implemented in Sage

This archive contains

  • Boltzmann_with_running_example.sws: the worksheet for the running example of the paper and the Boltzmann sampling part. An html version is also provided for those who have not yet installed Sage.
  • generating.sage and generating2.sage: the files for the continuous recursive method. Instructions are given just below.

Open sage in a shell and run the file generating_rec.sage with the command attach (i.e. write %attach generating.sage in the shell). This will generates a permutation without blocks of two consecutive descents; alternatively one can copy the code and past it into a notebook to run it.

Several other examples are commented in the file, one can uncomment them and run the file again (after having saved it).

The preprocessing takes the major amount of time. If one wants to generate permutations without doing again the preprocessing, it can run the file generating_rec2.sage (i.e. write %attach generating2.sage) after having run generating.sage at least one time.

Below : an example of 3 permutations without two consecutive descents of size 100:

sage: %attach generating.sage

[75, 76, 7, 72, 81, 64, 77, 55, 97, 15, 95, 18, 98, 32, 93, 17, 67, 12, 49, 85, 22, 50, 21, 68, 57, 87, 27, 41, 52, 61, 91, 26, 30, 59, 33, 73, 5, 54, 39, 43, 28, 44, 14, 62, 11, 80, 40, 47, 45, 66, 56, 69, 86, 19, 78, 90, 37, 71, 51, 99, 13, 48, 4, 34, 83, 100, 1, 6, 46, 82, 9, 35, 60, 29, 84, 20, 58, 79, 2, 38, 96, 10, 23, 88, 3, 53, 94, 36, 89, 16, 31, 24, 63, 8, 74, 42, 65, 70, 92, 25]

sage: %attach generating2.sage

[35, 20, 79, 98, 91, 99, 76, 78, 23, 54, 77, 13, 72, 97, 29, 47, 60, 6, 87, 88, 37, 61, 64, 43, 89, 80, 93, 1, 71, 4, 55, 16, 49, 53, 58, 27, 28, 44, 17, 19, 40, 41, 42, 65, 46, 68, 8, 26, 12, 24, 92, 25, 36, 9, 86, 59, 74, 95, 21, 30, 57, 22, 66, 7, 81, 10, 38, 90, 18, 83, 85, 52, 73, 3, 34, 100, 45, 56, 51, 84, 62, 70, 2, 48, 67, 75, 94, 11, 50, 5, 15, 14, 69, 31, 63, 32, 82, 39, 96, 33]

sage: %attach generating2.sage

[59, 13, 81, 52, 64, 70, 79, 35, 62, 3, 57, 80, 95, 10, 93, 43, 89, 94, 24, 53, 38, 39, 41, 49, 68, 1, 82, 91, 29, 87, 72, 83, 84, 34, 46, 40, 42, 2, 44, 18, 100, 21, 25, 85, 4, 12, 11, 32, 78, 55, 75, 50, 77, 97, 8, 60, 76, 26, 74, 33, 63, 30, 96, 99, 56, 90, 31, 86, 28, 47, 16, 92, 6, 17, 71, 14, 45, 69, 54, 88, 37, 48, 61, 7, 58, 22, 23, 20, 98, 15, 51, 9, 67, 5, 65, 27, 66, 73, 19, 36]