Commit 4f1191dc authored by Antoine Cully's avatar Antoine Cully
Browse files

add notes for benchmark pages in docs.

parent e7f9f512
......@@ -53,6 +53,7 @@ import threading
from waflib import Logs
plotting_ok = True
try:
import plot_bo_benchmarks
import plot_regression_benchmarks
......
......@@ -158,7 +158,19 @@ def clean_labels(k1, k2):
if k2[-2:len(k2)] == ', ':
k2 = k2[0:-2]
return k1, k2
def get_notes():
notes={'branin':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/branin.html>`_.',
'ellipsoid':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/rothyp.html>`_.',
'goldsteinprice':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/goldpr.html>`_.',
'hartmann3':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/hart3.html>`_.',
'hartmann6':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/hart6.html>`_.',
'rastrigin':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/rastr.html>`_ (note, the input space has been rescaled and shifted to have the minimum at [1,1,1,1], instead of [0,0,0,0]',
'sixhumpcamel':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/camel6.html>`_.',
'sphere':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/spheref.html>`_.'};
return notes
# plot a single function
def plot(func_name, data, rst_file):
# set the figure size
......@@ -210,10 +222,13 @@ def plot(func_name, data, rst_file):
ax.set_yticklabels([])
ax.set_title("Wall clock time (s)")
notes=get_notes()
name = func_name.split('.')[0]
fig.savefig("benchmark_results/fig_benchmarks/" + name + ".png")
rst_file.write(name + "\n")
rst_file.write("-----------------\n\n")
rst_file.write(notes[name] + " \n\n")
rst_file.write(str(len(da_acc[0])) + " replicates \n\n")
rst_file.write(".. figure:: fig_benchmarks/" + name + ".png\n\n")
......
......@@ -188,6 +188,36 @@ def plot_ax(ax, data, points, labely, disp_legend=True, disp_xaxis=False):
return replicates
def get_notes():
notes={'Rastrigin':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/rastr.html>`_.',
'Pistonsimulation':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/piston.html>`_.',
'Step':'Step function: for :math:`x\in[-2; 2]` :\n.. math::\n f(x) = \\begin{cases} 0, &\\mbox{if x<=0} \\\\ 1, &\\mbox{otherwise} \\end{cases}',
'Robotarm':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/robot.html>`_.',
'Gramacylee':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/grlee12.html>`_.',
'Planarinversedynamicsii':'Approximation of the second motor\'s torque in the inverse dynamics of a Planar 2D Arm. Details are given at the bottom of this page.',
'Planarinversedynamicsi':'Approximation of the first motor\'s torque in the inverse dynamics of a Planar 2D Arm. Details are given at the bottom of this page.',
'Otlcircuit':'Details about the function can be found `here <https://www.sfu.ca/~ssurjano/otlcircuit.html>`_.'};
return notes
def planarinversedynamics_math():
res="""Inverse Dynamics of a Planar 2D Arm (I \& II): for :math:`\ddot{q}\in[-2\pi; 2\pi]^2`; :math:`\dot{q}\in[-2\pi; 2\pi]^2`; :math:`q\in[-pi; pi]^2`
.. math::
\\begin{gather}
\\tau (q,\dot{q},\\ddot{q})=\\textbf{M}(q)\\ddot{q}+ \\textbf{C}(q,\\dot{q})\\dot{q}\\\\
\\textrm{where:}\\\\
\\textbf{M}(q)=\\begin{bmatrix}
0.2083 + 0.1250\\cos(q_2)& 0.0417 + 0.0625\\cos(q_2))\\\\
0.0417 + 0.0625\\cos(q_2)& 0.0417
\\end{bmatrix}
\\\\
\\textbf{C}(q,\\dot{q})=\\begin{bmatrix}
-0.0625 \\sin(q_2) \\dot{q}_2& -0.0625 \\sin(q_2)(\\dot{q}_1 + \\dot{q}_2)\\\\
0.0625 \\sin(q_2)\\dot{q}_1& 0
\\end{bmatrix}
\\\\
\\end{gather}\n\n"""
return res
def plot_data(bench, func, dim, mses, query_times, learning_times, points, rst_file):
name = func+'_'+str(dim)
fig, ax = plt.subplots(3, sharex=True)
......@@ -199,9 +229,10 @@ def plot_data(bench, func, dim, mses, query_times, learning_times, points, rst_f
fig.tight_layout()
fig.savefig('regression_benchmark_results/'+bench+'_figs/'+name+'.png')
close()
notes=get_notes()
rst_file.write(func.title() + " in " + str(dim) + "D\n")
rst_file.write("-----------------\n\n")
rst_file.write(notes[func.title()] + " \n\n")
rst_file.write(str(replicates) + " replicates \n\n")
rst_file.write(".. figure:: fig_benchmarks/" + bench + "_figs/" + name + ".png\n\n")
......@@ -254,6 +285,7 @@ def plot_all():
points,times_learn,times_query,mses = load_data()
print('data loaded')
plot(points,times_learn,times_query,mses,rst_file)
rst_file.write("------------------\n\n")
rst_file.write(planarinversedynamics_math())
if __name__ == "__main__":
plot_all()
\ No newline at end of file
plot_all()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment