from __future__ import print_function import tacoma as tc dyn_RGG = tc.dynamic_RGG(N=3, t_run_total=10, mean_link_duration=2.0) test_list = tc.edge_lists(dyn_RGG) #test_list.copy_from(dyn_RGG) print(test_list.t, dyn_RGG.t) print(test_list.tmax, dyn_RGG.tmax) print(test_list.edges) print(dyn_RGG.edges) print(test_list.N, dyn_RGG.N) zsbb = tc.ZSBB_model([], 3, 0.6, 0.6, 0.6, t_run_total=100) test_list = tc.edge_changes(zsbb) print(test_list.t, zsbb.t) print(test_list.t0, zsbb.t0) print(test_list.tmax, zsbb.tmax) print(test_list.edges_in) print(zsbb.edges_in) print(test_list.edges_out) print(zsbb.edges_out) print(test_list.N, zsbb.N)
import tacoma as tc ec = tc.convert(tc.dynamic_RGG(3, 3, mean_link_duration=1.)) C = tc.edge_changes() C.N = 3 C.edges_initial = [(0, 1)] C.t0 = 0.0 C.tmax = 3.0 C.t = [1.0, 2.0] C.edges_in = [ [(1, 2), (0, 2)], [ (0, 1), ], ] C.edges_out = [ [(0, 1)], [(1, 2), (0, 2)], ] fw_args = tc.get_flockwork_P_args(C, dt=1.) print fw_args.rewiring_rate print fw_args.P print fw_args.__dict__
import tacoma as tc from rocsNWL import draw import matplotlib.pyplot as pl import networkx as nx from collections import Counter import numpy as np import time N = 400 start = time.time() edge_lists = tc.dynamic_RGG( N=N, t_run_total=1000, mean_link_duration=5., periodic_boundary_conditions_for_link_building=True, record_sizes_and_durations=True, #verbose = True) seed=2335) end = time.time() print("needed", end - start, "seconds") G = nx.Graph() G.add_edges_from(edge_lists.edges[-1]) G.add_nodes_from(list(range(N))) #draw(G) #pl.show()
socio_binned, dt=(socio_binned.tmax - socio_binned.t[0]) / 120.) fwP = tc.flockwork_P_varying_rates(**fwP_params) fwP_binned = tc.bin(fwP, dt=20.) #fwP_binned = fwP result = tc.measure_group_sizes_and_durations(fwP_binned) fig, ax, data = temporal_network_group_analysis(result, time_unit=socio.time_unit) fig.tight_layout() traj = tc.get_edge_trajectories(fwP_binned) draw_edges(traj.trajectories, ax=ax[3], time_unit=socio.time_unit) # ============== generate surrogate network from dynamic RGG model ============== dRGG_params = estimate_dynamic_RGG_args(socio_binned, group_sizes_and_durations=socio_result) dRGG = tc.dynamic_RGG(**dRGG_params) result = tc.measure_group_sizes_and_durations(dRGG) fig, ax, data = temporal_network_group_analysis(result, time_normalization_factor=20., time_unit=socio.time_unit) fig.tight_layout() traj = tc.get_edge_trajectories(dRGG) draw_edges(traj.trajectories, ax=ax[3], time_normalization_factor=20., time_unit=socio.time_unit) fig.savefig('talk/dyn_RGG.pdf') pl.show()
import matplotlib.pyplot as pl import DynGillEpi as gill import numpy as np N = 50 t_run_total = 10 complete_graph = [] for i in range(N - 1): for j in range(i + 1, N): complete_graph.append((i, j)) new_list = [complete_graph for g in range(t_run_total)] N_meas = 10 L_ = tc.dynamic_RGG(50, t_run_total=t_run_total, mean_link_duration=2) L = tc.edge_lists() L.copy_from(L_) L.t = [0., 0.1, 4.0, 4.1, 5.2, 6.9, 7.5, 8.1, 8.5, 9.0] #print len(L.edges) L.edges = new_list etas = np.logspace(-0.1, 0.5, 10) R0 = np.logspace(-0.1, 1, 10) rho = 1.0 etas = R0 * rho / (N - 1.) #R0 = etas * (N-1.)/rho tc_vals = np.zeros((len(etas), N_meas)) dyn_vals = np.zeros((len(etas), N_meas))
import tacoma as tc import numpy as np import matplotlib.pyplot as pl N = 10 t_run = 10000 result = tc.dynamic_RGG( N=N, t_run_total=t_run, mean_link_duration=10., periodic_boundary_conditions_for_link_building=False, record_sizes_and_durations=True, critical_density=1.0, #verbose = True) seed=2335) this = tc.edge_lists(result) second_result = tc.measure_group_sizes_and_durations_for_edge_lists( this, #verbose=True, ) #print result.durations #print second_result.contact_durations #print result.size_histograms #print second_result.size_histograms print(("all size histograms are the same:", all([