13from __future__
import absolute_import, division, print_function
19from comet_ml
import Experiment
26import matplotlib.pyplot
as plt
31from subprocess
import check_output
as qx
46parameters = [(initial_radius, spacing)
for initial_radius
in range(1, 4)
for spacing
in np.arange(1, 2.5, 0.5)]
52 for parameter_pair
in parameters:
55 experiment = Experiment(api_key=os.environ[
'COMET_API_KEY'], project_name=
"cdt-plusplus", team_name=
"ucdavis")
59 hyper_params = {
'simplices': 12000,
'foliations': 12}
60 experiment.log_multiple_params(hyper_params)
62 init_radius = parameter_pair[0]
64 radial_factor = parameter_pair[1]
66 command_line =
"../build/src/initialize --s -n" + str(experiment.get_parameter(
"simplices")) \
67 +
" -t" + str(experiment.get_parameter(
"foliations")) +
" -i" + str(init_radius) \
68 +
" -f" + str(radial_factor)
69 args = shlex.split(command_line)
78 for line
in output.splitlines():
79 if line.startswith(
"Minimum timevalue"):
80 s = re.findall(
'\d+', line)
81 result[1] = float(s[0])
82 elif line.startswith(
"Maximum timevalue"):
83 s = re.findall(
'\d+', line)
84 result[2] = float(s[0])
85 elif line.startswith(
"Final number"):
87 s = re.findall(
'\d+', line)
89 result[0] = float(s[0])
90 elif line.startswith(
"Timeslice"):
91 t = re.findall(
'\d+', line)
95 print(
'Initial radius is: {}'.format(init_radius))
96 print(
'Radial factor is: {}'.format(radial_factor))
98 print(
"Timeslice {} has {} spacelike faces.".format(element[0], element[1]))
102 score = ((result[0] - experiment.get_parameter(
"simplices"))/(experiment.get_parameter(
"simplices")))*100
105 experiment.log_metric(
"Error %", score)
106 experiment.log_other(
"Min Timeslice", result[1])
107 experiment.log_other(
"Max Timeslice", result[2])
112 for element
in graph:
113 timeslice.append(int(element[0]))
114 volume.append(int(element[1]))
115 plt.plot(timeslice, volume)
116 plt.xlabel(
'Timeslice')
117 plt.ylabel(
'Volume (spacelike faces)')
118 plt.title(
'Volume Profile')
120 experiment.log_figure(figure_name=
"Volume per Timeslice", figure=plt)
124except cm.exceptions.NoMoreSuggestionsAvailable
as NoMore:
125 print(
"No more suggestions.")
127except (TypeError, KeyError):
131 traceback.print_exc()
133print(
"All done with parameter optimization, look at Comet.ml for results.")