예제 #1
0
        if args.n >= max_n:
            print "WARNING: given n is greater than or equal to maximum in database. Above list may be incomplete."
        sys.exit(0)

    # Automation mode:
    # find the the largest n currently in the database,
    # and figure out which partitions of n still need to be generated.
    n = cur.execute("SELECT max(n) FROM specht").fetchone()[0]
    if args.regen or not n:
        n = 2
    while True:
        p_gen = partition_gen(n)
        for p in p_gen:
            p = Partition(*p)
            p2 = p.conjugate()
            if p.is_2special() and p2.is_2special():
                p_str = ",".join(map(str, p.vals))
                p2_str = ",".join(map(str, p2.vals))
                # see if candidate or conjugate is already in db; otherwise compute & insert solution.
                in_db = cur.execute("SELECT * FROM specht WHERE partition=?",
                                    (p_str, )).fetchone()
                if in_db != None and not args.regen:  # with --regen, override existing db contents
                    continue
                if p.num_row_perms() > p2.num_row_perms():
                    faster_p = p
                else:
                    faster_p = p2
                if args.verbosity > 0:
                    print "Next partition: {}".format(faster_p)
                if args.c:
                    print 1