1 from __future__
import print_function
5 if sys.version_info >= (3, 0):
12 __all__ = [
'InteractiveCostTuning']
23 self.master.winfo_toplevel().title(
"Interactive Cost Tuning")
34 for k
in list(problem.get_task_maps().keys()):
36 r = problem.get_rho(k)
39 self.cost_task_map_names.append(k)
46 tk.Label(self.
master, text=k).grid(row=i, column=0)
48 self.
entries[k].grid(row=i, column=1, pady=4)
52 tk.Label(self.
master, text=
'Filename').grid(row=n_cost_task_maps, column=0, pady=4)
54 self.
entries[
'filename'].grid(row=n_cost_task_maps, column=1, pady=4)
55 self.
entries[
'filename'].insert(0,
'FilenameHere')
58 tk.Button(self.
master, text=
"Set", command=self.
set_button).grid(row=n_cost_task_maps+1, column=0, pady=4)
59 tk.Button(self.
master, text=
"Save", command=self.
save_button).grid(row=n_cost_task_maps+1, column=1, pady=4)
60 tk.Button(self.
master, text=
"Reset", command=self.
reset_button).grid(row=n_cost_task_maps+2, column=0, pady=4)
61 tk.Button(self.
master, text=
"Quit", command=self.
quit_button).grid(row=n_cost_task_maps+2, column=1, pady=4)
64 """Sets rho parameters in entries into Exotica problem.""" 65 print(
"Setting cost parameters:")
68 rho = float(eval(userin))
69 self.
entries[k].delete(0,
'end')
71 self.problem.set_rho(k, rho)
72 print(
" {}\t{}".format(k, rho))
75 """Saves current rho parameters in entries to file in home dir.""" 79 t = int(round(time() * 1000))
80 filename =
"%s/%s_%d.costparams" % (os.environ[
'HOME'], self.
entries[
'filename'].get(), t)
83 with open(filename,
'w')
as fout:
84 fout.write(
'<Cost>\n')
86 fout.write(
' <Task Task="{}" Rho="{}"/>\n'.format(k, float(eval(self.
entries[k].get()))))
87 fout.write(
'</Cost>\n')
88 print(
"Saved cost parameters to %s" % filename)
91 """Resets entries/exotica to original cost terms as specified in xml.""" 92 print(
"Resetting cost parameters:")
97 self.
entries[k].delete(0,
'end')
101 self.problem.set_rho(k, rho)
103 print(
" {}\t{}".format(k, rho))
106 """Quits interactive cost tuning.""" 107 print(
"Quitting interactive cost tuning...")
111 """Starts tk mainloop."""
def __init__(self, problem)