execution is killed for unknown reason

asked 2022-09-16 02:44:42 +0200

Max Alekseyev gravatar image

updated 2022-09-16 02:45:42 +0200

The following code defines a function num_classes(n) and easily computes it for $n=1,2,3,4,5$ in Sage 9.7rc0. However, for $n=6$ its computation after some time is being killed by the system without any apparent reason. I expect that $n=6$ will run some hours, but there is no single reason for it to be killed. In particular, it cannot be a memory issue (unless it's a memory leak of some kind) as the code essentially iterates over elements generated on-fly and saves the smallest ones into the set res. It does not create any big data structures and the set res cannot contain at most $n!$ ($=720$ for $n=6$) elements by design. How to figure out what goes wrong here?

import itertools
def num_classes(n):
    P = PolynomialRing(ZZ,n,'x')
    x = P.gens()

    res = set()
    for s in itertools.product( *(range(k) for k in (2..n)) ):
        f = [x[0],1-x[0]]
        for k,i in enumerate(s):
            f[i:i+1] = [f[i]*x[k+1], f[i]*(1-x[k+1])]
        g = min( sorted(map(lambda z: z.subs(dict(zip(y,t))),f)) for t in itertools.product( *((xi,1-xi) for xi in x) ) for y in Permutations(x) )

        res.add( tuple(g) )

    return len(res)
edit retag flag offensive close merge delete


Could you please provide an estimation of the time you had to wait until the computation is killed so that people that want to reproduce know how much they have to wait ?

tmonteil gravatar imagetmonteil ( 2022-09-16 09:34:46 +0200 )edit

On a different system with Sage 9.7.rc1 the answer was successfully produced within 5 hours. But I'm still wonder what to do in such a situation to debug the reason.

Max Alekseyev gravatar imageMax Alekseyev ( 2022-09-16 16:50:21 +0200 )edit