In [22]:
%matplotlib inline
In [23]:
import datetime
dts = str(datetime.datetime.now())
date_time_str = dts[:10] + "-" + dts[11:13] + "-" + dts[14:16]
print date_time_str
In [24]:
import numpy as np
import bga_4_0 as bga
import manifold_reflected_brownian_motion as mrbm
import triangle_geometry as ti
import matplotlib.pyplot as plt
import polyhedra as poly
bga = reload(bga)
mrbm = reload(mrbm)
In [25]:
manifold_name = 'building_game'
#poly_name = 'tetrahedron'
poly_name = 'octahedron'
#poly_name = 'icosahedron'
unary_boundary_name = 'self_intersection'
binary_boundary_name = 'dihedrals'
stat_name = 'bg_attachment'
In [26]:
err_tol = 10**-12
h = 0.05
N = 10**7
hist_min = 0.0
hist_max = np.pi
hist_bins = 1000
In [27]:
verts, face_inds, cents = getattr(poly, poly_name)()
V, E, F, S, species, f_types, adj_list, dual = bga.get_poly(poly_name)
ints, ids, paths, shell_int, shell_paths, edges, shell_edge = bga.get_bg_ss(poly_name)
In [ ]:
def run_ints(int_list, N, output_rate, archive_rate):
"""
Get list of ints to run. Create MRBM instance for each int.
Run each int for output_rate samples and dump data. Repeat until
each int has N samples. Output to a non-overwritten file every
archive_rate_iterations.
"""
int_dict = {}
for int_num in int_list:
print "Loading", poly_name, "intermediate", str(int_num) + "..."
x0, links, lengths, faces = bga.load_bg_int(poly_name, int_num)
# Construct kwargs
standard_kwarg = {'poly_name': poly_name,
'int_num': int_num}
manifold_kwargs = {'poly_name': poly_name,
'int_num': int_num,
'fixed_com': True,
'fixed_rotation': True}
unary_boundary_kwargs = standard_kwarg
binary_boundary_kwargs =standard_kwarg #############################################################333
stat_kwargs = standard_kwarg
kwargs = {'manifold_name': manifold_name,
'stat_name': stat_name,
'manifold_kwargs': manifold_kwargs,
'stat_kwargs': stat_kwargs,
'record_hist': True,
'hist_min': hist_min,
'hist_max': hist_max,
'hist_bins': hist_bins,
'err_tol': err_tol}
# Initialize process
z = mrbm.MRBM(x0, h, **kwargs)
In [28]:
for int_num in range(1, len(ints)):
print "Loading", poly_name, "intermediate", str(int_num) + "..."
x0, links, lengths, faces = bga.load_bg_int(poly_name, int_num)
# Construct kwargs
standard_kwarg = {'poly_name': poly_name,
'int_num': int_num}
manifold_kwargs = {'poly_name': poly_name,
'int_num': int_num,
'fixed_com': True,
'fixed_rotation': True}
unary_boundary_kwargs = standard_kwarg
binary_boundary_kwargs =standard_kwarg #############################################################333
stat_kwargs = standard_kwarg
kwargs = {'manifold_name': manifold_name,
'stat_name': stat_name,
'manifold_kwargs': manifold_kwargs,
'stat_kwargs': stat_kwargs,
'record_hist': True,
'hist_min': hist_min,
'hist_max': hist_max,
'hist_bins': hist_bins,
'err_tol': err_tol}
# Initialize process
z = mrbm.MRBM(x0, h, **kwargs)
if len(z.stat(x0)) == 0:
print '\tNo angles to compute.'
continue
# Sample
print "\tSampling..."
#print '\t',
z.sample(N=N,
record_trace=False,
record_stats=False,
progress_bar=True,
bar_width=20)
print "\tWriting results to file..."
filename = "./results/full_run/"
filename += poly_name + "_"
filename += str(int_num) + "_"
filename += date_time_str + ".csv"
z.write_histograms(filename)