43 lines
791 B
Python
43 lines
791 B
Python
|
#!/usr/bin/python2.6
|
||
|
|
||
|
import sys
|
||
|
from grid.DD import random_grid
|
||
|
from baker import get_phis, run_baker
|
||
|
from baker.tools import exact_func, smberror, improved_answer
|
||
|
from glob import glob
|
||
|
from os import remove
|
||
|
|
||
|
FILE_PREFIX='/tmp/qhull-'
|
||
|
|
||
|
for g in glob('%s*' % FILE_PREFIX):
|
||
|
remove(g)
|
||
|
|
||
|
try:
|
||
|
total_points = int(sys.argv[1])
|
||
|
total_tries = int(sys.argv[2])
|
||
|
except:
|
||
|
print "usage: app.py total_points total_tries"
|
||
|
sys.exit(1)
|
||
|
|
||
|
|
||
|
print "total points", total_points
|
||
|
|
||
|
|
||
|
|
||
|
d = {True: 0, False: 0}
|
||
|
for i in xrange(total_tries):
|
||
|
g = random_grid(total_points)
|
||
|
|
||
|
open('%s%0.3d.txt' % (FILE_PREFIX, i), 'w').write(g.for_qhull())
|
||
|
|
||
|
X = [0.3, 0.3]
|
||
|
exact = exact_func(X)
|
||
|
|
||
|
try:
|
||
|
answer = g.run_baker(X)
|
||
|
d[improved_answer(answer, exact)] += 1
|
||
|
except smberror as e:
|
||
|
print e
|
||
|
|
||
|
print d
|