Skip to content

Mybranch #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Command.py
Original file line number Diff line number Diff line change
@@ -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()

22 changes: 22 additions & 0 deletions Iterator.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions demo_COVID.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys

import command
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion population.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions python_corona_simulation
Submodule python_corona_simulation added at a5dddd