i think part of my problem (why i'm not always getting win), is that i do not guarantee that the simplex contains the point (especially with the random clounds; i think that the connectivity-based lookup is doing that fine
This commit is contained in:
parent
9836fdcbfe
commit
f089848a1b
22
bin/test.py
22
bin/test.py
@ -8,24 +8,30 @@ from baker.tools import exact_func_3D
|
||||
try:
|
||||
total_points = int(sys.argv[1])
|
||||
except:
|
||||
total_points = 100
|
||||
total_points = 20
|
||||
|
||||
|
||||
print total_points
|
||||
g = simple_random_grid(total_points)
|
||||
|
||||
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
|
||||
|
||||
X = [0.5, 0.3, 0.4]
|
||||
X = [0.3, 0.3, 0.4]
|
||||
|
||||
R, S = g.get_simplex_and_nearest_points(X, extra_points = 3, simplex_size=4)
|
||||
R, S = g.get_simplex_and_nearest_points(X, extra_points = 6, simplex_size=4)
|
||||
|
||||
|
||||
print "R", R
|
||||
print "S", S
|
||||
print "R\n", R
|
||||
print "S\n", S
|
||||
|
||||
exact = exact_func_3D(X)
|
||||
print "exact solution: %0.6f" % exact
|
||||
|
||||
print "phi values: ", get_phis_3D(X, R.points)
|
||||
phis = get_phis_3D(X, R.points)
|
||||
print "phi values (should all be positive): ", phis
|
||||
if [i for i in phis if i < 0.0]:
|
||||
print "problems"
|
||||
sys.exit(1)
|
||||
|
||||
r = run_baker_3D(X, R, S)
|
||||
|
||||
print 'qlin' , r['qlin']
|
||||
@ -34,5 +40,7 @@ print 'final', r['final']
|
||||
|
||||
if abs(r['final'] - exact) <= abs(r['qlin'] - exact):
|
||||
print "win"
|
||||
sys.exit(0)
|
||||
else:
|
||||
print "failure"
|
||||
sys.exit(2)
|
||||
|
@ -111,8 +111,10 @@ def run_baker(X, R, S):
|
||||
S = extra points
|
||||
"""
|
||||
|
||||
# calculate values only for the triangle
|
||||
# calculate values only for the simplex triangle
|
||||
phi, qlin = qlinear(X, R)
|
||||
if [i for i in phi if i <= 0.0]:
|
||||
print "failure"
|
||||
|
||||
if len(S.points) == 0:
|
||||
answer = {
|
||||
|
Loading…
Reference in New Issue
Block a user