Ejemplo n.º 1
0
def fordens(n,denslist, repeats=100):
    rl={}
    for d in denslist:
        ee = bfu.dens2edgenum(d,n)
        l=[checker(n,ee)[-1] for i in range(repeats)]
        rl[d] = (round(scipy.mean(l),3),round(scipy.std(l),3))
    return rl
Ejemplo n.º 2
0
def getAring(n,
             density=0.1,
             st=0.5,
             verbose=True,
             dist='flatsigned',
             permute=False):
    keeptrying = True
    plusedges = bfutils.dens2edgenum(density, n)
    while keeptrying:
        G = gk.ringmore(n, plusedges, permute=permute)
        try:
            A = transitionMatrix4(G, minstrength=st, distribution=dist)
            try:
                s = A.shape
                keeptrying = False
            except AttributeError:
                keeptrying = True
        except ValueError:
            if verbose:
                print "!!! Unable to find strong links for a stable matrix !!!"
                print "*** trying a different graph"
    return {
        'graph': G,
        'transition': A,
        'converges': len(bfutils.call_undersamples(G))
    }
Ejemplo n.º 3
0
def getAring(n, density=0.1, st=0.5, verbose=True, dist='flatsigned', permute=False):
    keeptrying = True
    plusedges = bfutils.dens2edgenum(density,n)
    while keeptrying:
        G = gk.ringmore(n, plusedges, permute=permute)
        try:
            A = transitionMatrix4(G, minstrength=st, distribution=dist)
            try:
                s = A.shape
                keeptrying = False
            except AttributeError:
                keeptrying = True
        except ValueError:
            if verbose:
                print "!!! Unable to find strong links for a stable matrix !!!"
                print "*** trying a different graph"
    return {'graph':      G,
            'transition': A,
            'converges':  len(bfutils.call_undersamples(G))}
Ejemplo n.º 4
0
    '3': {
        '4': set([(0, 1)])
    },
    '4': {
        '1': set([(0, 1)])
    },
}

#d2l.matrix_unfold(l[0],2,1,R=5, w_gap=1, h_gap=2, mname='TT1')

n = 20
dens = 0.07

for i in range(10):
    print i
    g = bfu.ringmore(n, bfu.dens2edgenum(dens, n))
    gl = bfu.all_undersamples(g)
    zkl.save(gl, 'list1.zkl')

    # output file
    foo = open('figures/shipfig_figure.tex', 'wb')
    sys.stdout = foo
    listplot('list1.zkl', width=17, R=6)
    sys.stdout = sys.__stdout__  # remember to reset sys.stdout!
    foo.flush()
    foo.close()
    PPP = os.getcwd()
    os.chdir('figures')
    os.system('pdflatex --shell-escape shipfig.tex 2>&1 > /dev/null')
    os.system('mv shipfig.pdf /tmp/all_graphs_' + str(n) + 'nodes_density_' +
              str(dens) + '_' + str(i) + '.pdf')
Ejemplo n.º 5
0
densities = {6: [0.2, 0.25, 0.3, 0.35],
             8: [0.3],
             10:[0.1],# 0.15, 0.2, 0.25, 0.3],
             15:[0.25, 0.3],
             20:[0.1],# 0.15, 0.2, 0.25, 0.3],
             25:[0.1],
             30:[0.1],
             35:[0.1],
             40:[0.1],
             50:[0.05, 0.1],
             60:[0.05, 0.1]}

for nodes in [15]:
    z = {}
    pool=Pool(processes=PNUM)
    for dens in densities[nodes]:
        print "{:2}: {:8} : {:10}  {:10}".format('id', 'density', 'eq class', 'time')
        e = bfutils.dens2edgenum(dens, n=nodes)
        eqclasses = pool.map(functools.partial(fan_wrapper, n=nodes, k=e),
                             range(REPEATS))
        z[dens] = eqclasses
        zkl.save(z[dens],
                 socket.gethostname().split('.')[0]+\
                     '_nodes_'+str(nodes)+'_density_'+str(dens)+'_newp_.zkl')
        print ''
        print '----'
        print ''
    pool.close()
    pool.join()
    zkl.save(z,socket.gethostname().split('.')[0]+'_nodes_'+str(nodes)+'_newp_.zkl')
Ejemplo n.º 6
0
             10:[.2],
             15:[0.2],
             20:[0.1],# 0.15, 0.2, 0.25, 0.3],
             25:[0.1],
             30:[0.1],
             35:[0.1],
             40:[0.1],
             50:[0.05, 0.1],
             60:[0.05, 0.1]}

for nodes in [5]:
    z = {}
    #pool=Pool(processes=PNUM)
    for dens in densities[nodes]:
        print "{:2}: {:8} : {:10} : {:10}  {:10}".format('id', 'densityi(G)', 'density(H)', 'eq class', 'time')
        e = bfutils.dens2edgenum(dens, n=nodes)

        eqclasses = []
        for x in pool.imap(functools.partial(ra_wrapper, n=nodes, k=e),
                           range(REPEATS)):
            eqclasses.append(x)
            z[dens] = eqclasses
            zkl.save(eqclasses,
                     socket.gethostname().split('.')[0]+\
                     '_nodes_'+str(nodes)+'_density_'+\
                     str(dens)+'_'+KEY+'_.zkl')

        print ''
        print '----'
        print ''
        #pool.close()