2010-04-29 22:29:35 -07:00
|
|
|
#!/usr/bin/env python
|
2010-03-18 22:32:24 -07:00
|
|
|
|
|
|
|
import sys
|
2010-03-20 16:10:02 -07:00
|
|
|
from grid.DDD import random_grid
|
2010-03-18 22:32:24 -07:00
|
|
|
from baker import get_phis_3D, run_baker_3D
|
2010-04-29 22:29:35 -07:00
|
|
|
from baker.tools import smblog
|
|
|
|
from baker.tools import exact_func_3D, smberror, improved_answer
|
|
|
|
from grid.simplex import contains
|
|
|
|
|
2010-03-18 22:32:24 -07:00
|
|
|
try:
|
|
|
|
total_points = int(sys.argv[1])
|
|
|
|
except:
|
2010-03-18 22:50:40 -07:00
|
|
|
total_points = 20
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.info(total_points)
|
2010-03-20 16:10:02 -07:00
|
|
|
g = random_grid(total_points)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
|
|
|
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
|
|
|
|
|
2010-04-29 22:29:35 -07:00
|
|
|
X = [0.5, 0.3, 0.4]
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
R, S = g.get_simplex_and_nearest_points(X, extra_points = 6, simplex_size=4)
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.info("Containing Simplex: %s" % contains(X, R.points))
|
2010-03-18 22:32:24 -07:00
|
|
|
|
|
|
|
exact = exact_func_3D(X)
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.info("exact solution: %0.6f" % exact)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
phis = get_phis_3D(X, R.points)
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.info("phi values (should all be positive): %s %s" % (phis, sum(phis)))
|
2010-03-18 22:50:40 -07:00
|
|
|
if [i for i in phis if i < 0.0]:
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.error("problems")
|
2010-03-18 22:50:40 -07:00
|
|
|
|
2010-03-20 16:10:02 -07:00
|
|
|
try:
|
|
|
|
r = run_baker_3D(X, R, S)
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.info("run_baker manual: %s" % improved_answer(r, exact))
|
2010-04-23 08:58:30 -07:00
|
|
|
except smberror as e:
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.error(e)
|
2010-04-23 08:58:30 -07:00
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
answer = g.run_baker(X)
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.info("run_baker from grid: %s" % improved_answer(answer, exact))
|
2010-03-20 16:10:02 -07:00
|
|
|
except smberror as e:
|
2010-04-29 22:29:35 -07:00
|
|
|
smblog.error(e)
|