Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeR888 committed Jan 27, 2021
1 parent bed8006 commit 594a74d
Show file tree
Hide file tree
Showing 12 changed files with 728 additions and 518 deletions.
420 changes: 420 additions & 0 deletions models/HIV_Vis.ipynb

Large diffs are not rendered by default.

68 changes: 37 additions & 31 deletions models/MJP/MJPRuntime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


import pyabc
import matplotlib.pyplot as plt
import os
Expand All @@ -12,32 +6,40 @@
import scipy as sp
import time

path="/p/project/fitmulticell/felipe/scripts/Batch_pyABC/programs/MJP"

db_path = ("sqlite://")
logfile_path="/home/felipe/testresults/MJPAcceptanceRates.csv"

import argparse

# In[ ]:
parser = argparse.ArgumentParser(description='Parse necessary arguments')
parser.add_argument('-pt', '--port', type=str, default="50004",
help='Which port should be used?')
parser.add_argument('-ip', '--ip', type=str,
help='Dynamically passed - BW: Login Node 3')
parser.add_argument('-nd','--nodes', type=int, default=8, help='How many nodes are used')

args = parser.parse_args()

port=6358
port = args.port
host = args.ip
nodes=args.nodes

eps_list=[10, 5, 3, 2, 1, 0.8, 0.66]
eps=pyabc.ListEpsilon(eps_list)
#eps=pyabc.MedianEpsilon(500, median_multiplier=0.8)
# Set constants

eps_list=[10, 5, 3, 2, 1, 0.85, 0.75, 0.66]
eps=pyabc.ListEpsilon(eps_list)
max_nr_pop=len(eps_list)
min_eps=0.66
pop_sizes = [32, 64, 128, 256, 512, 1024, 2048]
iters_PPP = 15
iters_ori = 10
resultfilepath = "/home/freck/sampling/log/MJPruntimeresults.txt"
pop_sizes = [64, 256, 1024, 4096]
iters_PPP = 25
iters_ori = 25
resultfilepath = os.path.join(path, "results/MJPruntimeresultsN"+str(nodes))
resultfile = open(resultfilepath, "w")
resultfile.write("Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total Walltime\n")
resultfile.close()


# In[ ]:
# Define the model


def h(x, pre, c):
Expand Down Expand Up @@ -98,10 +100,6 @@ def gillespie(x, c, pre, post, max_t):

return np.array(t_store), np.array(x_store)


# In[ ]:


MAX_T = 0.1

class Model1:
Expand Down Expand Up @@ -137,13 +135,13 @@ def distance(x, y):
prior = pyabc.Distribution(rate=pyabc.RV("uniform", 0, 100))


# In[ ]:
# Run inference in Look-Ahead mode


redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host="131.220.224.226",
redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host=host,
port=port,
look_ahead = True,
look_ahead_delay_evaluation = True)
look_ahead = True,
look_ahead_delay_evaluations=False)

histories=[]
runtimes=np.zeros(iters_PPP)
Expand All @@ -152,7 +150,11 @@ def distance(x, y):
totalstarttime =time.time()
for i in range(iters_PPP):
starttime=time.time()


db_path = "sqlite:///" + os.path.join(path,
"results/database",
"MJPLAdatabase"+str(i))

abc = pyabc.ABCSMC(models = Model1(),
parameter_priors = prior,
distance_function = distance,
Expand Down Expand Up @@ -181,9 +183,9 @@ def distance(x, y):
resultfile.close()


# In[ ]:
# Run in Standard mode

redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host="131.220.224.226",
redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host=host,
port=port,
look_ahead = False)

Expand All @@ -194,15 +196,19 @@ def distance(x, y):
totalstarttime =time.time()
for i in range(iters_ori):
starttime=time.time()


db_path_ori = "sqlite:///" + os.path.join(path,
"results/database",
"MJPORIdatabase"+str(i))

abc = pyabc.ABCSMC(models = Model1(),
parameter_priors = prior,
distance_function = distance,
population_size = pop_size,
sampler = redis_sampler,
eps = eps)

abc.new(db_path, observations)
abc.new(db_path_ori, observations)
history = abc.run(minimum_epsilon=min_eps, max_nr_populations=max_nr_pop)

endtime=time.time()
Expand Down
9 changes: 9 additions & 0 deletions models/MJP/Testresults/MJPruntimeresultsN1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total Walltime
64, True, 25, 4.700620365142822, 0.13697168159373632, 117.5156397819519
256, True, 25, 15.175513916015625, 0.6333949294039781, 379.3879358768463
1024, True, 25, 57.17575264930725, 1.7556208926126167, 1429.3938932418823
4096, True, 25, 225.16033295631408, 20.54652997972526, 5629.008406877518
64, False, 25, 5.944116010665893, 0.2227856101115552, 148.60300469398499
256, False, 25, 17.454330921173096, 0.46063299201262, 436.35836267471313
1024, False, 25, 61.75151098251343, 1.459239199916629, 1543.7878587245941
4096, False, 25, 240.39604927062987, 11.982908250319703, 6009.9013130664825
9 changes: 9 additions & 0 deletions models/MJP/Testresults/MJPruntimeresultsN16.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total Walltime
64, True, 25, 3.6584749889373778, 0.18036533743039637, 91.46195960044861
256, True, 25, 6.604058866500854, 0.08443480460212013, 165.1015546321869
1024, True, 25, 15.505275402069092, 0.10716168320144735, 387.631977558136
4096, True, 25, 51.484131298065186, 0.4895708407641618, 1287.1033625602722
64, False, 25, 4.0463243675231935, 0.10558147371895357, 101.15820908546448
256, False, 25, 7.240054292678833, 0.07247017450751954, 181.00145149230957
1024, False, 25, 16.147134351730347, 0.04671725590648293, 403.6784393787384
4096, False, 25, 55.55671684265137, 0.12557241191903684, 1388.918003320694
9 changes: 9 additions & 0 deletions models/MJP/Testresults/MJPruntimeresultsN2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total Walltime
64, True, 25, 2.3337471866607666, 0.03421874610674276, 58.34378480911255
256, True, 25, 5.730166301727295, 0.025145039378067304, 143.2542543411255
1024, True, 25, 19.686495542526245, 0.2325956414434404, 492.1624667644501
4096, True, 25, 74.84271800994873, 0.7970013313419991, 1871.0680329799652
64, False, 25, 3.443028507232666, 0.06957789079959312, 86.07583379745483
256, False, 25, 7.611031665802002, 0.06346520408220876, 190.27588510513306
1024, False, 25, 23.34336711883545, 0.2188870054553896, 583.5842604637146
4096, False, 25, 87.57662706375122, 0.4119207400624099, 2189.4157552719116
9 changes: 9 additions & 0 deletions models/MJP/Testresults/MJPruntimeresultsN4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total Walltime
64, True, 25, 3.0797416877746584, 0.030239835974786366, 76.99363803863525
256, True, 25, 7.817548322677612, 0.04627855143839497, 195.43878698349
1024, True, 25, 26.264585189819336, 0.4129806619917486, 656.6147060394287
4096, True, 25, 101.04926258087158, 3.6060764224627535, 2526.231638431549
64, False, 25, 3.6492793560028076, 0.026694120594938794, 91.23208713531494
256, False, 25, 10.680523872375488, 11.654824619263968, 267.01317858695984
1024, False, 25, 30.21081015586853, 6.013050001153057, 755.2703273296356
4096, False, 25, 112.19126895904542, 1.5008914598140322, 2804.781801223755
9 changes: 9 additions & 0 deletions models/MJP/Testresults/MJPruntimeresultsN8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total Walltime
64, True, 25, 3.8386583042144777, 0.08122198631975298, 95.9665584564209
256, True, 25, 7.660666446685791, 0.10431252323847692, 191.51674270629883
1024, True, 25, 22.234130668640137, 0.42869506850045136, 555.8533442020416
4096, True, 25, 74.61447005271911, 31.34629550457708, 1865.3618392944336
64, False, 25, 3.965095729827881, 0.09609020697370997, 99.12750816345215
256, False, 25, 7.706383352279663, 0.09192487934859454, 192.65967750549316
1024, False, 25, 20.228655223846435, 1.7993651052167394, 505.71645617485046
4096, False, 25, 72.90948188781738, 27.49854118781281, 1822.73712515831
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total Walltime
64, Ori, 8, 91.42149505019188, 292.9593020957442, 734.9711499214172
256, Ori, 8, 345.26164323091507, 207.21000418344875, 2764.3773238658905
1024, Ori, 8, 1362.1188804209232, 2964.038945602262, 10900.209585428238
64, PPP, 8, 93.32252585887909, 327.3567601288613, 749.1319305896759
256, PPP, 8, 348.73482516407967, 812.6784226509708, 2793.88960647583
1024, PPP, 8, 1384.8556591272354, 968.7753512668869, 11082.6002471447
64, Stat, 5, 96.72240819931031, 152.72086997927926, 484.7231469154358
256, Stat, 5, 356.30815567970274, 508.12290408978004, 1782.915586233139
1024, Stat, 5, 1376.2829179763794, 1209.382377898872, 6882.824419498444
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ Pop size, Look_ahead, Repetitions, Runtime Expectation, Runtime Variance, total
64, PPP, 18, 25.816566122902763, 188.4127050137668, 469.52601766586304
256, PPP, 18, 44.75276900662316, 355.68264332277374, 810.4895243644714
1024, PPP, 18, 86.24677246146732, 982.001131821476, 1557.9515907764435
4096, PPP, 18, 171.21058615048727, 1762.042142831896, 3089.6374735832214
64, Stat, 3, 100.2330223719279, 4.8570529993189036, 302.1996114253998
256, Stat, 3, 109.11439990997314, 53.35862398350082, 328.8534586429596
45 changes: 31 additions & 14 deletions models/Tumor/TumorModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@


from time import time
import tumor2d

import matplotlib.pyplot as plt
from string import capwords
import os
import tempfile

import pyabc
import tumor2d

import argparse

parser = argparse.ArgumentParser(description='Parse necessary arguments')
parser.add_argument('-pt', '--port', type=str, default="50004",
help='Which port should be used?')
parser.add_argument('-ip', '--ip', type=str,
help='Dynamically passed - BW: Login Node 3')
args = parser.parse_args()

pop_size = 200
min_eps=700
min_eps_ori=min_eps
max_nr_pop=100
resultfile = open("/home/freck/sampling/log/TumorRuntimes.txt", "a")
port=6358
port = args.port
host = args.ip

nnodes = 32
pop_size = 1000
min_eps = 700
min_eps_ori = min_eps
max_nr_pop = 100
logfilepath = "/p/home/jusers/reck1/juwels/scripts/programs/results/TumorStats"+str(pop_size)+".csv"
resultfile = open("/p/home/jusers/reck1/juwels/scripts/programs/results/TumorRuntimes"+str(nnodes)+".txt", "a")

db_path = "sqlite:///" + os.path.join("/p/home/jusers/reck1/juwels/scripts/programs/results", "TumorRes"+str(pop_size)+".db")

db_path_ori = "sqlite:///" + os.path.join("/p/home/jusers/reck1/juwels/scripts/programs/results", "TumorRes_ori"+str(pop_size)+".db")

# In[2]:

Expand Down Expand Up @@ -91,7 +108,7 @@
# In[6]:


redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host="131.220.224.226", port=port, look_ahead = False)
redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host=host, port=port, look_ahead = False)

starttime=time()
abc = pyabc.ABCSMC(models=tumor2d.log_model,
Expand All @@ -100,7 +117,7 @@
population_size=pop_size,
sampler=redis_sampler)

abc.new("sqlite:////tmp/test.db", data_mean)
abc.new(db_path_ori, data_mean)
history_f = abc.run(max_nr_populations=max_nr_pop, minimum_epsilon=min_eps_ori)
endtime=time()

Expand All @@ -111,13 +128,13 @@

df, w = history_f.get_distribution(m=0,t=history_f.max_t)
pyabc.visualization.plot_kde_matrix(df, w, limits=limits);
plt.savefig("/home/freck/sampling/log/img/TumorResOri.jpg")
plt.savefig("/p/home/jusers/reck1/juwels/scripts/programs/img/TumorResOri"+str(pop_size)+".jpg")


# In[8]:


redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host="131.220.224.226", port=port, look_ahead = True, look_ahead_delay_evaluation=True, log_file="/home/freck/sampling/log/tumorlogs/statistics.csv")
redis_sampler = pyabc.sampler.RedisEvalParallelSampler(host=host, port=port, look_ahead = True, look_ahead_delay_evaluation=True, log_file=logfilepath)

starttime=time()
abc = pyabc.ABCSMC(tumor2d.log_model,
Expand All @@ -126,17 +143,17 @@
population_size=pop_size,
sampler=redis_sampler)

abc.new("sqlite:////tmp/test.db", data_mean)
abc.new(db_path, data_mean)
history = abc.run(max_nr_populations=max_nr_pop, minimum_epsilon=min_eps)
endtime=time()

resultfile.write("Ori, " + str(endtime-starttime)+", " + str(pop_size) + ", " + str(min_eps))
resultfile.write("LA, " + str(endtime-starttime)+", " + str(pop_size) + ", " + str(min_eps))

# In[10]:


df, w = history.get_distribution(m=0, t=history.max_t)
pyabc.visualization.plot_kde_matrix(df, w, limits=limits);
plt.savefig("/home/freck/sampling/log/img/TumorResPPP.jpg")
plt.savefig("/p/home/jusers/reck1/juwels/scripts/programs/img/TumorResPPP"+str(pop_size)+".jpg")


Loading

0 comments on commit 594a74d

Please sign in to comment.