|
|
@@ -42,7 +42,66 @@ class SyntheticDeseaseData:
|
|
|
else:
|
|
|
print('Data has to be generated before plotting!') # Fabienne war hier
|
|
|
|
|
|
-
|
|
|
+class SI(SyntheticDeseaseData):
|
|
|
+ def __init__(self, plotter:Plotter, N=59e6, I_0=1, simulation_time=500, time_points=100, alpha=0.191, beta=0.05) -> None:
|
|
|
+ """This class is able to generate synthetic data of the SI groups for the reduced SIR model. This is done by utiling the SIR model.
|
|
|
+
|
|
|
+ Args:
|
|
|
+ plotter (Plotter): Plotter object to plot dataset curves.
|
|
|
+ N (int, optional): Size of the population. Defaults to 59e6.
|
|
|
+ I_0 (int, optional): Initial size of the infectious group. Defaults to 1.
|
|
|
+ simulation_time (int, optional): Real time for that the synthetic data is supposed to be generated in days. Defaults to 500.
|
|
|
+ time_points (int, optional): Number of time sample points. Defaults to 100.
|
|
|
+ alpha (float, optional): Factor dictating how many people per timestep go from 'Infectious' to 'Removed'. Defaults to 0.191.
|
|
|
+ beta (float, optional): Factor dictating how many people per timestep go from 'Susceptible' to 'Infectious'. Defaults to 0.05.
|
|
|
+ """
|
|
|
+
|
|
|
+ self.N = N
|
|
|
+ self.S_0 = N - I_0
|
|
|
+ self.I_0 = I_0
|
|
|
+
|
|
|
+ self.alpha = alpha
|
|
|
+ self.beta = beta
|
|
|
+
|
|
|
+ super().__init__(simulation_time, time_points, plotter)
|
|
|
+
|
|
|
+ def differential_eq(self, y, t, alpha, beta):
|
|
|
+ """In this function implements the differential equation of the SIR model will be implemented.
|
|
|
+
|
|
|
+ Args:
|
|
|
+ y (tuple): Vector that holds the current state of the three groups.
|
|
|
+ t (_): not used
|
|
|
+ alpha (_): not used
|
|
|
+ beta (_): not used
|
|
|
+
|
|
|
+ Returns:
|
|
|
+ tuple: Change amount for each group.
|
|
|
+ """
|
|
|
+ S, I = y
|
|
|
+ dSdt = -self.beta * ((S * I) / self.N)
|
|
|
+ dIdt = self.beta * ((S * I) / self.N) - self.alpha * I
|
|
|
+ return dSdt, dIdt
|
|
|
+
|
|
|
+ def generate(self):
|
|
|
+ """This funtion generates the data for this configuration of the SIR model.
|
|
|
+ """
|
|
|
+ y_0 = self.S_0, self.I_0
|
|
|
+ self.data = odeint(self.differential_eq, y_0, self.t, args=(self.alpha, self.beta)).T
|
|
|
+ super().generate()
|
|
|
+
|
|
|
+ def plot(self, title=''):
|
|
|
+ """Plot the data which was generated.
|
|
|
+ """
|
|
|
+ super().plot(('Susceptible', 'Infectious'), title=title)
|
|
|
+
|
|
|
+ def save(self, name=''):
|
|
|
+ if self.generated:
|
|
|
+ COVID_Data = np.asarray([self.t, *self.data])
|
|
|
+
|
|
|
+ np.savetxt('datasets/SI_data.csv', COVID_Data, delimiter=",")
|
|
|
+ else:
|
|
|
+ print('Data has to be generated before plotting!')
|
|
|
+
|
|
|
|
|
|
class SIR(SyntheticDeseaseData):
|
|
|
def __init__(self, plotter:Plotter, N=59e6, I_0=1, R_0=0, simulation_time=500, time_points=100, alpha=0.191, beta=0.05) -> None:
|