import numpy as np
from scipy.integrate import odeint
import time
# Define the SIR model
def sir_model(y, t, beta, gamma):
S, I, R = y
dS = -beta * S * I
dI = beta * S * I - gamma * I
dR = gamma * I
return [dS, dI, dR]
# Initial state values
initial_state = [0.99, 0.01, 0.0]
# Parameters
beta = 0.3
gamma = 0.1
# Time points
times = np.linspace(0, 1600, 1601)
# Solve the system of ODEs
start_time = time.time()
for i in range(0, 100):
output = odeint(sir_model, initial_state, times, args=(beta, gamma))
end_time = time.time()
python_runtime = end_time - start_time
print("Runtime for scipy.integrate.odeint in Python:")