diff --git a/Command.py b/Command.py new file mode 100644 index 0000000..b77efa8 --- /dev/null +++ b/Command.py @@ -0,0 +1,28 @@ +from abc import abstractmethod +import simulation +import utils +import visualiser +class command(): + @abstractmethod + def __init__(self,name): + self.name=name + + @abstractmethod + def excute(self): + pass + + +class simulateCommand(command): + def excute(self): + simulation.run() + +class savefileCutCommand(command): + def excute(self,folder): + utils.check_folder(folder) + + + +class pltCommand(command): + def excute(self): + visualiser.plot_sir() + diff --git a/Iterator.py b/Iterator.py new file mode 100644 index 0000000..a7007e9 --- /dev/null +++ b/Iterator.py @@ -0,0 +1,22 @@ +from abc import abstractmethod + + +class iterator(): + @abstractmethod + def getNext(self): + pass + + @abstractmethod + def hasMore(self): + pass + +class populationIterator(iterator): + def __init__(self,tracker): + self.tracker=tracker + self.currentposition=0 + def getNext(self): + if(self.hasMore()): + self.currentposition+=1 + return self.tracker[self.currentposition] + def hasMore(self): + return self.currentposition < len(self.tracker) \ No newline at end of file diff --git a/demo_COVID.py b/demo_COVID.py index 2443544..2b7b15b 100644 --- a/demo_COVID.py +++ b/demo_COVID.py @@ -1,6 +1,6 @@ import os import sys - +import command import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation @@ -433,6 +433,6 @@ def update(frame, population, destinations, pop_size, infection_range=0.01, treatment_factor, healthcare_capacity, age_dependent_risk, treatment_dependent_risk, visualise, verbose,) - + command.excute(plt) animation = FuncAnimation(fig, update, fargs = fargs, frames = simulation_steps, interval = 33) plt.show() \ No newline at end of file diff --git a/population.py b/population.py index 2879a8b..8e7a86b 100644 --- a/population.py +++ b/population.py @@ -10,7 +10,7 @@ from motion import get_motion_parameters from utils import check_folder - +import iterator def initialize_population(Config, mean_age=45, max_age=105, xbounds=[0, 1], ybounds=[0, 1]): '''initialized the population for the simulation diff --git a/python_corona_simulation b/python_corona_simulation new file mode 160000 index 0000000..a5dddd3 --- /dev/null +++ b/python_corona_simulation @@ -0,0 +1 @@ +Subproject commit a5dddd3e13d2bb768a9294d85ab27329be9a21dd