observer = axelrod_aurora_test1.AxelrodObserver(printby)
term = axelrod_aurora_test1.AxelrodTerminator(checkby)
for i in range(0,len(square_dim_list)):
    xdim = square_dim_list[i]
    ydim = square_dim_list[i]
    g = igraph.Graph.Lattice([xdim,ydim], nei=1, directed=False, circular=False)
    env = axelrod_aurora_test1.AxelrodEnvironment(g)
    for k in range(0,N):
        this_s_time = time.clock()
        # get this simulation's seed
        curseed = seedlist[place]
        place = place + 1
        np.random.seed(curseed)
        timeobj = dworp.BasicTime(n_tsteps)
        # reset all the agent states
        agents = [axelrod_aurora_test1.Site(v,num_features,num_traits) for v in g.vs]
        # ensuring reproducibility by setting the seed
        scheduler = dworp.RandomOrderScheduler(np.random.RandomState(curseed+1))
        sim = dworp.TwoStageSimulation(agents, env, timeobj, scheduler, observer,terminator=term)
        sim.run()
        lastcount = observer.computenumregions(0,agents,env)
        allresults[i,k] = lastcount
        this_e_time = time.clock()
        alltimings[i,k] = this_e_time - this_s_time
try:
    end_time = time.clock()
    sim_time_minutes = float(end_time-start_time)/60.0
    print("simulation finished after %.2f minutes" % (sim_time_minutes))
except:
    print("error here")
    pdb.set_trace()
示例#2
0
 ydim = square_dim_list[i]
 g = igraph.Graph.Lattice([xdim, ydim],
                          nei=1,
                          directed=False,
                          circular=False)
 env = axelrod_aurora_test1.AxelrodEnvironment(g)
 for k in range(0, N):
     this_s_time = time.clock()
     # get this simulation's seed
     curseed = seedlist[place]
     place = place + 1
     np.random.seed(curseed)
     timeobj = dworp.BasicTime(n_tsteps)
     # reset all the agent states
     agents = [
         axelrod_aurora_test1.Site(v, num_features, num_traits)
         for v in g.vs
     ]
     # ensuring reproducibility by setting the seed
     scheduler = dworp.RandomOrderScheduler(
         np.random.RandomState(curseed + 1))
     sim = dworp.TwoStageSimulation(agents,
                                    env,
                                    timeobj,
                                    scheduler,
                                    observer,
                                    terminator=term)
     sim.run()
     lastcount = observer.computenumregions(0, agents, env)
     allresults[i, k] = lastcount
     this_e_time = time.clock()
示例#3
0
allresults = np.zeros([len(features_list), len(numtraits_list), N])
place = 0
for i in range(0, len(features_list)):
    num_features = features_list[i]
    for j in range(0, len(numtraits_list)):
        num_traits = numtraits_list[j]
        for k in range(0, N):
            # get this simulation's seed
            curseed = seedlist[place]
            place = place + 1
            np.random.seed(curseed)
            g = igraph.Graph.Lattice([xdim, ydim],
                                     nei=1,
                                     directed=False,
                                     circular=False)
            agents = [axelrod_aurora_test1.Site(v) for v in g.vs]
            env = axelrod_aurora_test1.AxelrodEnvironment(g)
            time = dworp.BasicTime(n_tsteps)
            # ensuring reproducibility by setting the seed
            scheduler = dworp.RandomOrderScheduler(
                np.random.RandomState(curseed + 1))
            observer = axelrod_aurora_test1.AxelrodObserver(printby)
            term = axelrod_aurora_test1.AxelrodTerminator(checkby)
            sim = dworp.TwoStageSimulation(agents,
                                           env,
                                           time,
                                           scheduler,
                                           observer,
                                           terminator=term)
            sim.run()
            lastcount = observer.computenumregions(0, agents, env)