On Wed, 26 Nov 2014, Simon King wrote:
If it is not collectable by Python's cyclic garbage collector, then
there is a bug. Can you open a trac ticket for it, putting me as Cc?
Maybe I first show whole code. This uses C-code that I am packaging, see
http://trac.sagemath.org/ticket/14110
%timeit
import subprocess
def generate_posets(n):
cmd=["/home/jm58660/sage/local/bin/genposets"]
args=[str(n), 'o']
sp=subprocess.Popen(cmd+args, shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
reader=iter(lambda: sp.stdout.read(2+2*n), '')
while True:
bin=reader.next()[2:]
L=[]
for i in range(0, n):
t=ord(bin[1+2*i])*256+ord(bin[2*i])
for j in range(0, n):
if (t << j) & 32768:
L.append((i,j))
G=DiGraph()
G.add_vertices(range(0, n))
G.add_edges(L)
yield Poset(G, facade = True)
import scipy
from scipy import linalg
for n in range(11,12):
nn=0
mm=Posets(n).cardinality()
print "Posets of size", str(n), "are", str(mm)
minimum=1
for P in generate_posets(n):
nn += 1
if nn%20000==0:
print 100.0*nn/mm
M=scipy.matrix(P.lequal_matrix()*P.lequal_matrix().transpose())
m=scipy.linalg.eigh(M, eigvals=(0,0), eigvals_only=True )[0]
if m<minimum:
smallest=P
minimum=m
print "Smallest eigenvalue", str(minimum)
print smallest.cover_relations()
smallest.show(figsize=4)
print "==="
It is of course possible that my smaller example eats memory only to some
constant value, and the problem is on scipy, for example. But I will check
that before opening a ticket.
--
Jori Mäntysalo