Dear Matthew, On Thu, Aug 29, 2013 at 09:21:20AM -0700, Matthew Weippert wrote: > I believe there is a bug in sage's Combinations.random_element(). > Unfortunately, it's difficult (but not impossible) to reproduce. I need to > search millions of combinations from a large set. In many cases, > Combinations.random_element() works great. But if I have a largest enough > set, then it will crash overnight, after 100's of thousands of calls. The > crash always seems to be in the call to cardinality just before randint > and unrank. The number of trials before the crash appears to be dependent > on the random seed, as well as the cardinality of the set. I'm guessing > the gap sub-process is getting gummed up somehow - maybe a memory leak?
Thanks for the report. For the sake of curiosity, did you keep around the error message? > Rather than re-creating the bug, I propose that the value returned from > cardinality be cached in the Combinations class. Making calls to a gap > subprocess sounds like a heavy-weight thing to do for every random call. This code is pretty old and certainly could use some love in the direction of #12913. For your specific issue, if there is no repetition (is this your case?), the cardinality should really be computed using binomial rather than by calling GAP, and then no caching would be needed. And when there are repetitions, it would make sense to have an implementation in Sage (e.g. recursive, with caching, possibly by just delegating the work to an appropriate lazy power series). For the short term, if there is no repetition in your use case, maybe you can use Subsets instead? > Should I submit an "enhancement" ticket? Sure! You might want to have a look at http://wiki.sagemath.org/combinat/Weirdness. Cheers, Nicolas -- Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net> http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-combinat-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-combinat-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-combinat-devel. For more options, visit https://groups.google.com/groups/opt_out.