Пример #1
0
def main():
    rc = Client()
    dview = rc[:]
    networks = [gnp(40, p) for p in np.arange(0, 0.9, 0.1)]
    opinions = [rand.rand(40) for p in np.arange(0, 0.9, 0.1)]
    asyncs = dview.map_sync(f1, zip(networks, opinions))
    print[res for res in asyncs]
Пример #2
0
def main():
    rc = Client()
    dview = rc[:]
    networks = [gnp(40, p) for p in np.arange(0, 0.9, 0.1)]
    opinions = [rand.rand(40) for p in np.arange(0, 0.9, 0.1)]
    asyncs = dview.map_sync(f1, zip(networks, opinions))
    print [res for res in asyncs]
Пример #3
0
def test():
    import numpy as np
    from numpy import diag
    import numpy.random as rand
    from numpy.linalg import norm, inv

    import models
    from viz import plotNetwork
    from util import gnp, barabasi_albert, from_edgelist, rowStochastic

    rand.seed(1233)
    #A, N = from_edgelist('./networks/facebook_combined.txt')
    N = 2000 
    A = gnp(N,0.02)
    A = rowStochastic(A)
    s = rand.rand(N)
    max_rounds = 1000
    #A = gnp(N, 0.12, rand_weights=True)
    B = diag(rand.rand(N)) * 0.5
    #models.deGroot(A, s, max_rounds)
    models.friedkinJohnsen(A, s, max_rounds, conv_stop=False)