-
Notifications
You must be signed in to change notification settings - Fork 0
/
Running And Analyzing A Simulation With A Drug.py
27 lines (27 loc) · 1.26 KB
/
Running And Analyzing A Simulation With A Drug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Enter your definition for simulationWithDrug in this box
def simulationWithDrug(numViruses, maxPop, maxBirthProb, clearProb, resistances,
mutProb, numTrials):
steps = 300
treatOnStep = 150
trialResultsTot = [[] for s in range(steps)]
trialResultsRes = [[] for s in range(steps)]
for __ in range(numTrials):
viruses = [ResistantVirus(maxBirthProb, clearProb,
resistances.copy(), mutProb)
for v in range(numViruses)]
patient = TreatedPatient(viruses, maxPop)
for step in range(steps):
if step == treatOnStep:
patient.addPrescription("guttagonol")
patient.update()
trialResultsTot[step].append(patient.getTotalPop())
trialResultsRes[step].append(patient.getResistPop(["guttagonol"]))
resultsSummaryTot = [sum(l) / float(len(l)) for l in trialResultsTot]
resultsSummaryRes = [sum(l) / float(len(l)) for l in trialResultsRes]
pylab.plot(resultsSummaryTot, label="Total Virus Population")
pylab.plot(resultsSummaryRes, label="Resistant Virus Population")
pylab.title("ResistantVirus simulation")
pylab.xlabel("time step")
pylab.ylabel("# viruses")
pylab.legend()
pylab.show()