Пример #1
0
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)
Пример #2
0
N = 1000
t_sim = 10000 * N
t_eq = 10000 * N
t_total = t_sim + t_eq
lambda_ = 1.0
b0 = 0.6
b1 = 0.8

plot_size = False

print "simulating"
result = tc.ZSBB_model([],
                       N,
                       lambda_,
                       b0,
                       b1,
                       t_sim,
                       t_equilibration=t_eq,
                       seed=1346,
                       record_sizes_and_durations=True)
print "done"

fig, ax = pl.subplots(1, 3, figsize=(12, 4))

x, y = get_hist_from_list(
    np.array(result.contact_durations, dtype=float) / float(N))
#x,y = get_hist_from_counter(Counter(result.contact_durations))
ax[1].plot(x, y, 's')
y2 = (1 + x)**(-2 * b1 - 1)
ax[1].plot(x, y2 / y2.sum())
x, y = get_hist_from_list(
Пример #3
0
# ========= plot properties ==============
socio_result = tc.measure_group_sizes_and_durations(socio)
fig, ax, data = temporal_network_group_analysis(socio_result,
                                                time_unit=socio.time_unit)
fig.tight_layout()
traj = tc.get_edge_trajectories(socio)
draw_edges(traj.trajectories, ax=ax[3])

# ========== generate surrogate from ZSBB model ======
ZSBB_params = estimate_ZSBB_args(socio, group_sizes_and_durations=socio_result)
ZSBB_params['b0'] = 0.51
ZSBB_params['b1'] = 1.0
ZSBB_params['lambda'] = 0.9

zsbb = tc.ZSBB_model(**ZSBB_params)
this_t0 = zsbb.t0
zsbb.t0 = 0.
zsbb.tmax -= this_t0
zsbb.t = [(t - this_t0) / zsbb.tmax * (socio.tmax - socio.t[0])
          for t in zsbb.t]
zsbb.tmax = socio.tmax - socio.t[0]

# bin the result because the original network is binned, too
#zsbb_binned = tc.bin(zsbb,N_time_steps=int((zsbb.tmax-zsbb.t0) / (socio_binned.N / 5.0)))
zsbb_binned = tc.bin(zsbb, dt=20.)

print(ZSBB_params)

# plot properties
result = tc.measure_group_sizes_and_durations(zsbb_binned)
Пример #4
0
    import tacoma as tc
    import matplotlib.pyplot as pl
    from tacoma.analysis import temporal_network_group_analysis
    
    # THESE TESTS ARE DEPRECATED

    test = tc.dtu_week()
    rewiring_rate = test.gamma
    P = test.P

    fw = tc.flockwork_P_varying_rates([],100,P,24*3600,rewiring_rate,tmax=24*3600*7)
    fw_binned = tc.sample(fw,dt=300)
    fw_binned_result = tc.measure_group_sizes_and_durations(fw_binned)

    kwargs = get_ZSBB_parameters(fw_binned,fw_binned_result,fit_discrete=True,dt=300.)
    print("lambda =", kwargs['lambda'])
    print("b0 =", kwargs['b0'])
    print("b1 =", kwargs['b1'])
    kwargs['t_run_total'] = (len(fw_binned.t) + 1)*kwargs['N']
    zsbb = tc.ZSBB_model(**kwargs)
    zsbb_binned = tc.sample(zsbb,dt=kwargs['N'])
    zsbb_binned_result = tc.measure_group_sizes_and_durations(zsbb_binned)


    fig, ax, data = temporal_network_group_analysis(fw_binned_result)
    temporal_network_group_analysis(zsbb_binned_result,
                                    time_normalization_factor = 300./kwargs['N'],
                                    ax=ax)

    pl.show()