tau1, gamma, initial_infecteds=infected, tmin=t1, tmax=tmax, return_full_data=True) plt.plot(times0, I0, label='fast_SIS') plt.plot( times1, I1 ) #the first two have the same parameters, so the transition should be as if it were a single simulation plt.plot(times2, I2) #the infectiousness reduced, so a sharp change should be visible #now for fun, redo with Gillespie times0, S0, I0, infection_time, recovery_time = EoN.Gillespie_SIS( G, tau0, gamma, rho=rho, tmax=t0, return_full_data=True) infected = set(node for node in infection_time if node not in recovery_time or infection_time[node][-1] > recovery_time[node][-1]) times1, S1, I1, infection_time, recovery_time = EoN.Gillespie_SIS( G, tau0, gamma, initial_infecteds=infected, tmin=t0, tmax=t1, return_full_data=True) infected = set(node for node in infection_time if node not in recovery_time or infection_time[node][-1] > recovery_time[node][-1]) times2, S2, I2, infection_time, recovery_time = EoN.Gillespie_SIS(
import EoN import networkx as nx import matplotlib.pyplot as plt # генерируем граф малого мира, с n=100 вершинами, # Каждый узел связан с k=4 ближайшими соседями в кольцевой топологии, # p=0.6 вероятность повторного соединения g=nx.watts_strogatz_graph(n=100, k=4, p=0.6) gamma = 0.2 beta = 3.2 nx_kwargs = {} # Выполняет моделирование SIS для эпидемий в сетях с взвешенными границами или без них # в аргумента - граф, tau=скорость передачи, gamma=скорость восстановления sim = EoN.Gillespie_SIS(g, tau = beta, gamma=gamma, return_full_data=True) for i in range(0,5,1): sim.display(time = i, **nx_kwargs) plt.axis('off') plt.title("Iteration {}".format(i)) plt.draw() plt.show()