Example #1
0
tc.gillespie_node_based_SIS(fwP_el, SIS)
end = time.time()

print("node-based simulation on edge_lists took", end - start, "seconds")

pl.plot(SIS.time, SIS.I)

start = time.time()
SIS = tc.SIS(N,
             t_run_total * 2,
             infection_rate,
             recovery_rate,
             N // 2,
             seed=seed,
             verbose=True)
tc.gillespie_SIS(fwP_ec, SIS, verbose=True)
end = time.time()

print("edge-based simulation on edge_changes took", end - start, "seconds")

pl.plot(SIS.time, SIS.I)

start = time.time()
SIS = tc.SIS(N,
             t_run_total * 2,
             infection_rate,
             recovery_rate,
             N // 2,
             seed=seed)
tc.gillespie_SIS(fwP_el, SIS)
end = time.time()
Example #2
0
    print(mean_k)
    eta = R0 * rho / mean_k

    i_sample = np.zeros_like(t_sample)

    successful = 0

    for meas in range(N_meas):

        sis = tc.SIS(N,
                     t_simulation,
                     eta,
                     rho,
                     number_of_initially_infected=10)

        tc.gillespie_SIS(tn, sis)

        t = np.array(sis.time)
        i = np.array(sis.I, dtype=float) / N

        this_sample = tc.sample_a_function(t, i, t_sample)

        if this_sample[-1] > 0.0:
            successful += 1
            i_sample += this_sample

        ax[2].plot(t_sample, this_sample, c=line.get_color(), alpha=0.1)

    ax[1].plot(t_sample, i_sample / successful)

pl.show()
Example #3
0
tmax = 10.0
seed = 7925
R0 = 1.2
recovery_rate = 1.0
infection_rate = R0 / (N - 1) * recovery_rate

complete_graph = tc.complete_graph(N)

start = time.time()
SIS = tc.SIS(N,
             t_run_total * 2,
             infection_rate,
             recovery_rate,
             N // 2,
             seed=seed)
tc.gillespie_SIS(complete_graph, SIS)
end = time.time()

print("simulation on edge_lists took", end - start, "seconds")

pl.plot(SIS.time, SIS.I)

mv_SIS = tc.MARKOV_SIS(N,
                       t_run_total * 2,
                       infection_rate,
                       recovery_rate,
                       0.01,
                       N // 2,
                       seed=seed)

start = time.time()
Example #4
0
P = [ 0.5 ] 
rewiring_rate = [ (0.0,1.0) ]
t_run_total = 500.0
tmax = 1000.0
seed = 7925
infection_rate = 1.0
recovery_rate = 0.1

E = flockwork_P_equilibrium_configuration(N,P[0])

fwP_ec = tc.flockwork_P_varying_rates(E,N,P,t_run_total,rewiring_rate,tmax,seed=seed)
fwP_el = tc.convert(fwP_ec)

start = time.time()
SIS = tc.SIS(N,t_run_total*2,infection_rate,recovery_rate,N//2,seed = seed)
tc.gillespie_SIS(fwP_ec,SIS)
end = time.time()

print("simulation on edge_changes took", end-start,"seconds")

pl.plot(SIS.time, SIS.I)

start = time.time()
SIS = tc.SIS(N,t_run_total*2,infection_rate,recovery_rate,N//2,seed = seed)
tc.gillespie_SIS(fwP_el,SIS)
end = time.time()

print("simulation on edge_lists took", end-start,"seconds")

pl.plot(SIS.time, SIS.I)
Example #5
0
            t = np.array(SIS.time)
            I = np.array(SIS.I)

            this_pl, = pl.plot(t, I, 's', ms=2, alpha=0.5, mfc='None')
            mean_I_1 = tc.time_average(t, I, tmax=t_run_total)

            SIS = _tc.SIS(N,
                          t_run_total,
                          infection_rate,
                          recovery_rate,
                          number_of_initially_infected=N,
                          sampling_dt=1)

            tn = _tc.activity_model(N, k / (N - 1.), omega, t_run_total)
            tc.gillespie_SIS(tn, SIS)

            t = np.array(SIS.time)
            I = np.array(SIS.I)

            mean_I_2 = tc.time_average(t, I, tmax=t_run_total)

            curve_1.append(mean_I_1)
            curve_2.append(mean_I_2)
            this_pl, = pl.plot(t,
                               I,
                               '-',
                               lw=1,
                               alpha=0.5,
                               c=this_pl.get_color())