def main(): for p1 in p1_range: for p3 in p3_range: # create the simulation object sim = SIRS(p1=p1, p2=0.5, p3=p3, create_anim=False, x_dim=20, y_dim=20) sim.count_infected_sites = True print(p1, p3) inf_array = sim.simulate() avg = np.mean(inf_array) / float(sim.sweep) susc = np.var(inf_array) / float(sim.sweep) with open(out_file, 'a+') as f: f.write(' '.join( (str(p1), str(p3), str(avg), str(susc), '\n')))
def main(): for frac in frac_range: print(frac) # create the simulation object sim = SIRS(p1=0.5, p2=0.5, p3=0.5, create_anim=False, immune_frac=frac, x_dim=20, y_dim=20) sim.count_infected_sites = True inf_array = sim.simulate() #inf_array_sq = [val*val for val in inf_array] avg = np.mean(inf_array) / float(sim.sweep) susc = np.std(inf_array) / float(sim.sweep) with open(out_file, 'a+') as f: f.write(' '.join((str(frac), str(avg), '\n')))
def main(): print('reading in the input data...') with open('SIRS_input.dat', 'r') as f: config = json.load(f, object_pairs_hook=OrderedDict) x_dim = config["x dimension"] y_dim = config["y dimension"] p1 = config["p1"] p2 = config["p2"] p3 = config["p3"] anim = ast.literal_eval(config["create animation"]) frac = config["fraction of immune agents"] print('setting up the simulation...') sim = SIRS(x_dim=x_dim, y_dim=y_dim, p1=p1, p2=p2, p3=p3, create_anim=anim, immune_frac=frac) print("running the simulation...") sim.simulate()
def MC_vac(): a = create_lambda(1, 2, 4.0) b = create_lambda(0, 0, 1.0) c = create_lambda(0, 0, 0.5) d = create_lambda(0, 0, 0.1) d_i = create_lambda(0, 0, 0.0) e = create_lambda(0, 0, 0.1) f_A = create_lambda(1.0, 1000.0, 0.0) f_B = create_lambda(1.0, 1000.0, 10.0) f_C = create_lambda(1.0, 1000.0, 50.0) f_D = create_lambda(1.0, 1000.0, 100.0) sirs_A = SIRS(400.0, a, b, c, d, d_i, e, f_A) sirs_B = SIRS(400.0, a, b, c, d, d_i, e, f_B) sirs_C = SIRS(400.0, a, b, c, d, d_i, e, f_C) sirs_D = SIRS(400.0, a, b, c, d, d_i, e, f_D) (t_array_A, S_avg_A, S_array_A, I_avg_A, I_array_A, R_avg_A, R_array_A) = sirs_A.MC_vac(300.0, 100.0, 20.0) (t_array_B, S_avg_B, S_array_B, I_avg_B, I_array_B, R_avg_B, R_array_B) = sirs_B.MC_vac(300.0, 100.0, 20.0) (t_array_C, S_avg_C, S_array_C, I_avg_C, I_array_C, R_avg_C, R_array_C) = sirs_C.MC_vac(300.0, 100.0, 20.0) (t_array_D, S_avg_D, S_array_D, I_avg_D, I_array_D, R_avg_D, R_array_D) = sirs_D.MC_vac(300.0, 100.0, 20.0) plt.subplot(221) plt.plot(t_array_A, S_avg_A, color='#F4C430', label="S") plt.plot(t_array_A, I_avg_A, color='indigo', label="I") plt.plot(t_array_A, R_avg_A, color='red', label="R") plt.plot(t_array_A, S_array_A, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_A, I_array_A, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_A, R_array_A, '-', color='red', alpha=0.3) # red for R plt.title("f(t) = 1.0 * sin(1000 * t) + 0.0") plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population A : S/N = ", S_avg_A[-1] / N) print("population A : I/N = ", I_avg_A[-1] / N) print("population A : R/N = ", R_avg_A[-1] / N) plt.legend() plt.subplot(222) plt.plot(t_array_B, S_avg_B, color='#F4C430', label="S") plt.plot(t_array_B, I_avg_B, color='indigo', label="I") plt.plot(t_array_B, R_avg_B, color='red', label="R") plt.plot(t_array_B, S_array_B, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_B, I_array_B, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_B, R_array_B, '-', color='red', alpha=0.3) # red for R #plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) # + ", d_i = " + str(d_i(0)) + ", e = " + str(e(0))) plt.title("f(t) = 1.0 * sin(1000 * t) + 10.0") plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population B : S/N = ", S_avg_A[-1] / N) print("population B : I/N = ", I_avg_A[-1] / N) print("population B : R/N = ", R_avg_A[-1] / N) plt.legend() plt.subplot(223) plt.plot(t_array_C, S_avg_C, color='#F4C430', label="S") plt.plot(t_array_C, I_avg_C, color='indigo', label="I") plt.plot(t_array_C, R_avg_C, color='red', label="R") plt.plot(t_array_C, S_array_C, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_C, I_array_C, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_C, R_array_C, '-', color='red', alpha=0.3) # red for R #plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) # + ", d_i = " + str(d_i(0)) + ", e = " + str(e(0))) plt.title("f(t) = 1.0 * sin(1000 * t) + 50.0") plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population C : S/N = ", S_avg_A[-1] / N) print("population C : I/N = ", I_avg_A[-1] / N) print("population C : R/N = ", R_avg_A[-1] / N) plt.legend() plt.subplot(224) plt.plot(t_array_D, S_avg_D, color='#F4C430', label="S") plt.plot(t_array_D, I_avg_D, color='indigo', label="I") plt.plot(t_array_D, R_avg_D, color='red', label="R") plt.plot(t_array_D, S_array_D, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_D, I_array_D, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_D, R_array_D, '-', color='red', alpha=0.3) # red for R #plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) # + ", d_i = " + str(d_i(0)) + ", e = " + str(e(0))) plt.title("a(t) = 2.0 * sin(0.5 * t) + 100.0") plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population A : S/N = ", S_avg_A[-1] / N) print("population A : I/N = ", I_avg_A[-1] / N) print("population A : R/N = ", R_avg_A[-1] / N) plt.legend() plt.show()
def MC_deadly(): a = create_lambda(0, 0, 4.0) b = create_lambda(0, 0, 1.0) c = create_lambda(0, 0, 0.5) d = create_lambda(0, 0, 0.1) d_i_A = create_lambda(0, 0, 0.0) d_i_B = create_lambda(0, 0, 1.0) d_i_C = create_lambda(0, 0, 1.5) d_i_D = create_lambda(0, 0, 2.0) e = create_lambda(0, 0, 0.1) sirs_A = SIRS(400.0, a, b, c, d, d_i_A, e) sirs_B = SIRS(400.0, a, b, c, d, d_i_B, e) sirs_C = SIRS(400.0, a, b, c, d, d_i_C, e) sirs_D = SIRS(400.0, a, b, c, d, d_i_D, e) (t_array_A, S_avg_A, S_array_A, I_avg_A, I_array_A, R_avg_A, R_array_A) = sirs_A.MC_vital(300.0, 100.0, 100.0) (t_array_B, S_avg_B, S_array_B, I_avg_B, I_array_B, R_avg_B, R_array_B) = sirs_B.MC_vital(300.0, 100.0, 100.0) (t_array_C, S_avg_C, S_array_C, I_avg_C, I_array_C, R_avg_C, R_array_C) = sirs_C.MC_vital(300.0, 100.0, 100.0) (t_array_D, S_avg_D, S_array_D, I_avg_D, I_array_D, R_avg_D, R_array_D) = sirs_D.MC_vital(300.0, 100.0, 100.0) plt.subplot(221) plt.plot(t_array_A, S_avg_A, color='#F4C430', label="S") plt.plot(t_array_A, I_avg_A, color='indigo', label="I") plt.plot(t_array_A, R_avg_A, color='red', label="R") plt.plot(t_array_A, S_array_A, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_A, I_array_A, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_A, R_array_A, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_A(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population A : S/N = ", S_avg_A[-1] / N) print("population A : I/N = ", I_avg_A[-1] / N) print("population A : R/N = ", R_avg_A[-1] / N) plt.legend() plt.subplot(222) plt.plot(t_array_B, S_avg_B, color='#F4C430', label="S") plt.plot(t_array_B, I_avg_B, color='indigo', label="I") plt.plot(t_array_B, R_avg_B, color='red', label="R") plt.plot(t_array_B, S_array_B, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_B, I_array_B, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_B, R_array_B, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_B(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population B : S/N = ", S_avg_A[-1] / N) print("population B : I/N = ", I_avg_A[-1] / N) print("population B : R/N = ", R_avg_A[-1] / N) plt.legend() plt.subplot(223) plt.plot(t_array_C, S_avg_C, color='#F4C430', label="S") plt.plot(t_array_C, I_avg_C, color='indigo', label="I") plt.plot(t_array_C, R_avg_C, color='red', label="R") plt.plot(t_array_C, S_array_C, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_C, I_array_C, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_C, R_array_C, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_C(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population C : S/N = ", S_avg_A[-1] / N) print("population C : I/N = ", I_avg_A[-1] / N) print("population C : R/N = ", R_avg_A[-1] / N) plt.legend() plt.subplot(224) plt.plot(t_array_D, S_avg_D, color='#F4C430', label="S") plt.plot(t_array_D, I_avg_D, color='indigo', label="I") plt.plot(t_array_D, R_avg_D, color='red', label="R") plt.plot(t_array_D, S_array_D, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_D, I_array_D, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_D, R_array_D, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_D(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_avg_A[-1] + I_avg_A[-1] + R_avg_A[-1] print("population A : S/N = ", S_avg_A[-1] / N) print("population A : I/N = ", I_avg_A[-1] / N) print("population A : R/N = ", R_avg_A[-1] / N) plt.legend() plt.show()
def MC_Run(): a = create_lambda(0, 0, 4.0) b_A = create_lambda(0, 0, 1.0) b_B = create_lambda(0, 0, 2.0) b_C = create_lambda(0, 0, 3.0) b_D = create_lambda(0, 0, 4.0) c = create_lambda(0, 0, 0.5) # initiating population sirs_A = SIRS(400.0, a, b_A, c) sirs_B = SIRS(400.0, a, b_B, c) sirs_C = SIRS(400.0, a, b_C, c) sirs_D = SIRS(400.0, a, b_D, c) # Running the computation (t_array_A, S_avg_A, S_array_A, I_avg_A, I_array_A, R_avg_A, R_array_A) = sirs_A.MC_(300.0, 100.0, 20.0) (t_array_B, S_avg_B, S_array_B, I_avg_B, I_array_B, R_avg_B, R_array_B) = sirs_B.MC_(300.0, 100.0, 20.0) (t_array_C, S_avg_C, S_array_C, I_avg_C, I_array_C, R_avg_C, R_array_C) = sirs_C.MC_(300.0, 100.0, 20.0) (t_array_D, S_avg_D, S_array_D, I_avg_D, I_array_D, R_avg_D, R_array_D) = sirs_D.MC_(300.0, 100.0, 20.0) plt.subplot(221) plt.plot(t_array_A, S_avg_A, color='#F4C430', label="S") plt.plot(t_array_A, I_avg_A, color='indigo', label="I") plt.plot(t_array_A, R_avg_A, color='red', label="R") plt.plot(t_array_A, S_array_A, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_A, I_array_A, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_A, R_array_A, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b_A(0)) + ", c = " + str(c(0))) plt.xlabel('Time') plt.ylabel('Population') print("population A : S/N = ", S_avg_A[-1] / 400.0) print("population A : I/N = ", I_avg_A[-1] / 400.0) print("population A : R/N = ", R_avg_A[-1] / 400.0) plt.legend() plt.subplot(222) plt.plot(t_array_B, S_avg_B, color='#F4C430', label="S") plt.plot(t_array_B, I_avg_B, color='indigo', label="I") plt.plot(t_array_B, R_avg_B, color='red', label="R") plt.plot(t_array_B, S_array_B, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_B, I_array_B, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_B, R_array_B, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b_B(0)) + ", c = " + str(c(0))) plt.xlabel('Time') plt.ylabel('Population') print("population B : S/N = ", S_avg_B[-1] / 400.0) print("population B : I/N = ", I_avg_B[-1] / 400.0) print("population B : R/N = ", R_avg_B[-1] / 400.0) plt.legend() plt.subplot(223) plt.plot(t_array_C, S_avg_C, color='#F4C430', label="S") plt.plot(t_array_C, I_avg_C, color='indigo', label="I") plt.plot(t_array_C, R_avg_C, color='red', label="R") plt.plot(t_array_C, S_array_C, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_C, I_array_C, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_C, R_array_C, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b_C(0)) + ", c = " + str(c(0))) plt.xlabel('Time') plt.ylabel('Population') print("population C : S/N = ", S_avg_C[-1] / 400.0) print("population C : I/N = ", I_avg_C[-1] / 400.0) print("population C : R/N = ", R_avg_C[-1] / 400.0) plt.legend() plt.subplot(224) plt.plot(t_array_D, S_avg_D, color='#F4C430', label="S") plt.plot(t_array_D, I_avg_D, color='indigo', label="I") plt.plot(t_array_D, R_avg_D, color='red', label="R") plt.plot(t_array_D, S_array_D, '-', color='#F4C430', alpha=0.3) # #F4C430 = saffron plt.plot(t_array_D, I_array_D, '-', color='indigo', alpha=0.3) # indigo for I plt.plot(t_array_D, R_array_D, '-', color='red', alpha=0.3) # red for R plt.title("a = " + str(a(0)) + ", b = " + str(b_D(0)) + ", c = " + str(c(0))) plt.xlabel('Time') plt.ylabel('Population') print("population D : S/N = ", S_avg_D[-1] / 400.0) print("population D : I/N = ", I_avg_D[-1] / 400.0) print("population D : R/N = ", R_avg_D[-1] / 400.0) plt.legend() plt.show()
def RK4_a (): a = create_lambda(0, 0, 4.0) b_A = create_lambda(0, 0, 1.0) b_B = create_lambda(0, 0, 2.0) b_C = create_lambda(0, 0, 3.0) b_D = create_lambda(0, 0, 4.0) c = create_lambda(0,0, 0.5) sirs_A = SIRS(400.0, a, b_A, c) sirs_B = SIRS(400.0, a, b_A, c) sirs_C = SIRS(400.0, a, b_C, c) sirs_D = SIRS(400.0, a, b_D, c) (t_array_A, S_array_A, I_array_A, R_array_A) = sirs_A.RK4(300.0, 100.0, 20.0) (t_array_B, S_array_B, I_array_B, R_array_B) = sirs_B.RK4(300.0, 100.0, 20.0) (t_array_C, S_array_C, I_array_C, R_array_C) = sirs_C.RK4(300.0, 100.0, 20.0) (t_array_D, S_array_D, I_array_D, R_array_D) = sirs_D.RK4(300.0, 100.0, 20.0) plt.subplot(221) plt.plot (t_array_A, S_array_A, color = '#F4C430', label="S") plt.plot (t_array_A, I_array_A, color = 'indigo', label="I") plt.plot (t_array_A, R_array_A, color = 'red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b_A(0)) + ", c = " + str(c(0))) plt.xlabel ('Time') plt.ylabel ('Population') print ("population A : S/N = ", S_array_A[-1]/400.0) print ("population A : I/N = ", I_array_A[-1]/400.0) print ("population A : R/N = ", R_array_A[-1]/400.0) plt.legend() plt.subplot(222) plt.plot (t_array_B, S_array_B, color = '#F4C430', label="S") plt.plot (t_array_B, I_array_B, color = 'indigo', label="I") plt.plot (t_array_B, R_array_B, color = 'red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b_B(0)) + ", c = " + str(c(0))) plt.xlabel ('Time') plt.ylabel ('Population') print ("population B : S/N = ", S_array_B[-1]/400.0) print ("population B : I/N = ", I_array_B[-1]/400.0) print ("population B : R/N = ", R_array_B[-1]/400.0) plt.legend() plt.subplot(223) plt.plot (t_array_C, S_array_C, color = '#F4C430', label="S") plt.plot (t_array_C, I_array_C, color = 'indigo', label="I") plt.plot (t_array_C, R_array_C, color = 'red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b_C(0)) + ", c = " + str(c(0))) plt.xlabel ('Time') plt.ylabel ('Population') print ("population C : S/N = ", S_array_C[-1]/400.0) print ("population C : I/N = ", I_array_C[-1]/400.0) print ("population C : R/N = ", R_array_C[-1]/400.0) plt.legend() plt.subplot(224) plt.plot (t_array_D, S_array_D, color = '#F4C430', label="S") plt.plot (t_array_D, I_array_D, color = 'indigo', label="I") plt.plot (t_array_D, R_array_D, color = 'red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b_D(0)) + ", c = " + str(c(0))) plt.xlabel ('Time') plt.ylabel ('Population') print ("population D : S/N = ", S_array_D[-1]/400.0) print ("population D : I/N = ", I_array_D[-1]/400.0) print ("population D : R/N = ", R_array_D[-1]/400.0) plt.legend() plt.savefig("RK_part_a.pdf")
def RK4_deadly(): a = create_lambda(0, 0, 4.0) b = create_lambda(0, 0, 1.0) c = create_lambda(0, 0, 0.5) d = create_lambda(0, 0, 0.1) d_i_A = create_lambda(0, 0, 0.0) d_i_B = create_lambda(0, 0, 1.0) d_i_C = create_lambda(0, 0, 1.5) d_i_D = create_lambda(0, 0, 2.0) e = create_lambda(0, 0, 0.1) sirs_A = SIRS(400.0, a, b, c, d, d_i_A, e) sirs_B = SIRS(400.0, a, b, c, d, d_i_B, e) sirs_C = SIRS(400.0, a, b, c, d, d_i_C, e) sirs_D = SIRS(400.0, a, b, c, d, d_i_D, e) (t_array_A, S_array_A, I_array_A, R_array_A) = sirs_A.RK4(300.0, 100.0, 200.0) (t_array_B, S_array_B, I_array_B, R_array_B) = sirs_B.RK4(300.0, 100.0, 200.0) (t_array_C, S_array_C, I_array_C, R_array_C) = sirs_C.RK4(300.0, 100.0, 200.0) (t_array_D, S_array_D, I_array_D, R_array_D) = sirs_D.RK4(300.0, 100.0, 200.0) plt.subplot(221) plt.plot(t_array_A, S_array_A, color='#F4C430', label="S") plt.plot(t_array_A, I_array_A, color='indigo', label="I") plt.plot(t_array_A, R_array_A, color='red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_A(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_array_A[-1] + I_array_A[-1] + R_array_A[-1] print("Population Size : ", N) print("population A : S/N = ", S_array_A[-1], S_array_A[-1] / N) print("population A : I/N = ", I_array_A[-1], I_array_A[-1] / N) print("population A : R/N = ", R_array_A[-1], R_array_A[-1] / N) plt.legend() plt.subplot(222) plt.plot(t_array_B, S_array_B, color='#F4C430', label="S") plt.plot(t_array_B, I_array_B, color='indigo', label="I") plt.plot(t_array_B, R_array_B, color='red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_B(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_array_B[-1] + I_array_B[-1] + R_array_B[-1] print("Population Size : ", N) print("population A : S/N = ", S_array_B[-1], S_array_B[-1] / N) print("population A : I/N = ", I_array_B[-1], I_array_B[-1] / N) print("population A : R/N = ", R_array_B[-1], R_array_B[-1] / N) plt.legend() plt.subplot(223) plt.plot(t_array_C, S_array_C, color='#F4C430', label="S") plt.plot(t_array_C, I_array_C, color='indigo', label="I") plt.plot(t_array_C, R_array_C, color='red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_C(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_array_C[-1] + I_array_C[-1] + R_array_C[-1] print("Population Size : ", N) print("population A : S/N = ", S_array_C[-1], S_array_C[-1] / N) print("population A : I/N = ", I_array_C[-1], I_array_C[-1] / N) print("population A : R/N = ", R_array_C[-1], R_array_C[-1] / N) plt.legend() plt.subplot(224) plt.plot(t_array_D, S_array_D, color='#F4C430', label="S") plt.plot(t_array_D, I_array_D, color='indigo', label="I") plt.plot(t_array_D, R_array_D, color='red', label="R") plt.title("a = " + str(a(0)) + ", b = " + str(b(0)) + ", c = " + str(c(0)) + ", d = " + str(d(0)) + ", d_i = " + str(d_i_D(0)) + ", e = " + str(e(0))) plt.xlabel('Time') plt.ylabel('Population') N = S_array_D[-1] + I_array_D[-1] + R_array_D[-1] print("Population Size : ", N) print("population A : S/N = ", S_array_D[-1], S_array_D[-1] / N) print("population A : I/N = ", I_array_D[-1], I_array_D[-1] / N) print("population A : R/N = ", R_array_D[-1], R_array_D[-1] / N) plt.legend() plt.show()