Last active
August 29, 2018 15:46
-
-
Save kaivalyar/38eedc29dc3f23565b370c296c32850a to your computer and use it in GitHub Desktop.
PracMLN MC-SAT Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import sys | |
import os | |
import time | |
from pracmln import query | |
from pracmln import MLN, Database, query | |
def main(arg='.'): | |
#if (len(sys)) | |
pth = os.path.join(arg, 'wts.pybpll.smoking-train-smoking.mln') | |
mln = MLN(mlnfile=pth, grammar='StandardGrammar') | |
pth = os.path.join(arg, 'smoking-test-smaller.db') | |
db = Database(mln, dbfile=pth) | |
#with open(os.path.join(arg, 'man_performance.txt'), 'a') as fl: | |
start = time.time() | |
#t = 1000* timeit.timeit("test(False)", setup="from __main__ import test, set; set()", number=10) | |
query(queries='Cancer,Smokes,Friends', method='MC-SAT', mln=mln, db=db, verbose=False, multicore=True).run() | |
t1 = time.time()-start | |
#print('single core exact inference test: {}'.format(t)) | |
#fl.write(str(t)) | |
#fl.write('\t(SingleCore)\n') | |
start = time.time() | |
#t = 1000* timeit.timeit("test(True)", setup="from __main__ import test, set; set()", number=10) | |
query(queries='Cancer,Smokes,Friends', method='MC-SAT', mln=mln, db=db, verbose=False, multicore=False).run() | |
t2 = time.time()-start | |
#print('multi core exact inference test: {}'.format(t)) | |
print('Inference, MC-SAT, {}, {}'.format(t1, t2)) | |
#fl.write(str(t)) | |
#fl.write('\t(MultiCore)\n') | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
main() | |
else: | |
main(sys.argv[1]) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PYTHONPATH="${PYTHONPATH}:/home/kaivalya/ ... /PracMLN/python3/" | |
source ~/.prac3/bin/activate | |
python3 test.py .. >> ../cython_summary.csv | |
deactivate | |
PYTHONPATH="" | |
source ~/p3/bin/activate | |
python3 test.py .. >> ../python_summary.csv | |
deactivate | |
PYTHONPATH="${PYTHONPATH}:/home/kaivalya/ ... /PracMLN/python3/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment