def __init__(self): self.database = Database() self.table_name = None self.table_checksum = None self.refresh_rate = REFRESH_RATE self.timestamp = None self.config = None self.problem_cfg = None self.agent = None self.scheduler = None self.root = tk.Tk() self.root.title('AutoOED') self.root.protocol('WM_DELETE_WINDOW', self._quit_init) self.root.resizable(False, False) self.root.iconphoto(True, tk.Image('photo', file=get_icon_path())) self.view = GUIInitView(self.root) self.view.widget['manage_problem'].configure( command=self.manage_problem) self.view.widget['create_experiment'].configure( command=self.create_experiment) self.view.widget['load_experiment'].configure( command=self.load_experiment) self.view.widget['remove_experiment'].configure( command=self.remove_experiment) center(self.root) self.root.mainloop()
def __init__(self, root_view): self.root_view = root_view self.master_window = self.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Remove Experiment') self.widget = {} self.widget['exp_name'] = create_widget('labeled_combobox', master=self.window, row=0, column=0, columnspan=2, text='Experiment name', required=True) self.widget['remove'] = create_widget('button', master=self.window, row=1, column=0, text='Remove') self.widget['cancel'] = create_widget('button', master=self.window, row=1, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view, obj_name): self.root_view = root_view self.master_window = self.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Enter Performance') n_obj = len(obj_name) self.widget = {} frame_n_row = create_widget('frame', master=self.window, row=0, column=0, sticky=None, pady=0) self.widget['disp_n_row'] = create_widget('labeled_spinbox', master=frame_n_row, row=0, column=0, text='Number of rows', from_=1, to=int(1e10)) self.widget['set_n_row'] = create_widget('button', master=frame_n_row, row=0, column=1, text='Update') self.widget['performance_excel'] = Excel(master=self.window, rows=1, columns=n_obj + 1, width=10, title=['Row number'] + list(obj_name), dtype=[int] + [float] * n_obj, default=None, required=[True] * (n_obj + 1), required_mark=False) self.widget['performance_excel'].grid(row=1, column=0) frame_action = create_widget('frame', master=self.window, row=2, column=0, sticky=None, pady=0) self.widget['save'] = create_widget('button', master=frame_action, row=0, column=0, text='Save') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view): self.root_view = root_view self.master_window = self.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Start Evaluation') self.widget = {} frame_n_row = create_widget('frame', master=self.window, row=0, column=0, sticky=None, pady=0) self.widget['disp_n_row'] = create_widget('labeled_spinbox', master=frame_n_row, row=0, column=0, text='Number of rows', from_=1, to=int(1e10)) self.widget['set_n_row'] = create_widget('button', master=frame_n_row, row=0, column=1, text='Update') self.widget['rowid_excel'] = Excel(master=self.window, rows=1, columns=1, width=10, title=['Row number'], dtype=[int], default=None, required=[True], required_mark=False) self.widget['rowid_excel'].grid(row=1, column=0) frame_action = create_widget('frame', master=self.window, row=2, column=0, sticky=None, pady=0) self.widget['start'] = create_widget('button', master=frame_action, row=0, column=0, text='Start') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view): self.root_view = root_view self.master_window = self.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Display Settings') frame_settings = create_widget('frame', master=self.window, row=0, column=0, padx=0, pady=0) grid_configure(frame_settings, 1, 0) self.widget = {} self.widget['cellwidth'] = create_widget('labeled_spinbox', master=frame_settings, row=0, column=0, text='Cell width:', from_=50, to=300, sticky='NSEW') self.widget['precision'] = create_widget('labeled_spinbox', master=frame_settings, row=1, column=0, text='Float precision:', from_=0, to=100, sticky='NSEW') frame_action = create_widget('frame', master=frame_settings, row=2, column=0, padx=0, pady=0) grid_configure(frame_action, 0, 1) self.widget['update'] = create_widget('button', master=frame_action, row=0, column=0, text='Update') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view, n_obj): self.root_view = root_view self.master_window = self.root_view.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Export Figures') self.widget = {} if n_obj == 1: text_list = [ 'Performance Space', 'Selected Design', 'Optimum', 'Model Error' ] else: text_list = [ 'Performance Space', 'Selected Design', 'Hypervolume', 'Model Error' ] self.widget['choice'] = create_widget('radiobutton', master=self.window, row=0, column=0, text_list=text_list, default='Performance Space', orientation='vertical') frame_action = create_widget('frame', master=self.window, row=1, column=0, padx=0, pady=0, sticky=None) self.widget['export'] = create_widget('button', master=frame_action, row=0, column=0, text='Export') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view, n_obj): self.root_view = root_view self.master_window = self.root_view.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Export Statistics') self.widget = {} if n_obj == 1: self.widget['choice'] = create_widget( 'radiobutton', master=self.window, row=0, column=0, text_list=['Optimum', 'Model Error'], default='Optimum') else: self.widget['choice'] = create_widget( 'radiobutton', master=self.window, row=0, column=0, text_list=['Hypervolume', 'Model Error'], default='Hypervolume') frame_action = create_widget('frame', master=self.window, row=1, column=0, padx=0, pady=0, sticky=None) self.widget['export'] = create_widget('button', master=frame_action, row=0, column=0, text='Export') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view): self.root_view = root_view self.master_window = self.root_view.window self.window = create_widget('toplevel', master=self.master_window, title='Advanced Settings') self.widget = {} self.cfg_widget = {} # parameter section frame_param_algo = create_widget('frame', master=self.window, row=0, column=0) self.nb_param = ttk.Notebook(master=frame_param_algo) self.nb_param.grid(row=0, column=0, sticky='NSEW') self.module_frames = {} for module in ['surrogate', 'acquisition', 'solver', 'selection']: frame = tk.Frame(master=self.nb_param) self.nb_param.add(child=frame, text=module.capitalize()) grid_configure(frame, None, 0) self.module_frames[module] = frame self.nb_param.bind("<<NotebookTabChanged>>", self._change_tab) # action section frame_action = tk.Frame(master=self.window) frame_action.grid(row=1, column=0) self.widget['save'] = create_widget('button', master=frame_action, row=0, column=0, text='Save') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view): self.root_view = root_view self.master_window = self.root_view.window self.window = create_widget('toplevel', master=self.master_window, title='Create Problem') grid_configure(self.window, 0, 0) self.frame = {} for config_type, config_text in zip([ 'general', 'design_mixed', 'design_unified', 'performance', 'constraint' ], [ 'General Config', 'Design Config', 'Design Config', 'Performance Config', 'Constraint Config' ]): self.frame[config_type] = create_widget('labeled_frame', master=self.window, row=0, column=0, text=config_text, sticky='NSEW') self.frame[config_type].grid_remove() grid_configure(self.frame[config_type], 0, 0) self.curr_frame = 0 self.max_frame = len(self.frame) self.in_creating_var = False self.var_cfg = {} self.widget = { 'general': {}, 'design_mixed': {}, 'design_unified': {}, 'performance': {}, 'constraint': {}, } frame_control = create_widget('frame', master=self.window, row=1, column=0, sticky='WE', padx=0, pady=0) grid_configure(frame_control, 0, 0) self.widget['cancel'] = create_widget('button', master=frame_control, row=0, column=0, text='Cancel', sticky='W') self.widget['back'] = create_widget('button', master=frame_control, row=0, column=1, text='Back', sticky='E') self.widget['next'] = create_widget('button', master=frame_control, row=0, column=2, text='Next', sticky='E') self.widget['finish'] = create_widget('button', master=frame_control, row=0, column=2, text='Finish', sticky='E') center(self.window, self.master_window)
def __init__(self, root_view, n_obj): self.root_view = root_view self.master_window = self.root_view.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Stopping Criterion') self.widget = { 'var': {}, 'entry': {}, } frame_options = create_widget('frame', master=self.window, row=0, column=0, padx=0, pady=0) self.name_options = { 'time': 'Time', 'n_iter': 'Number of iterations', 'n_sample': 'Number of samples' } if n_obj == 1: self.name_options.update({ 'opt': 'Optimum value', 'opt_conv': 'Convergence' }) else: self.name_options.update({'hv_conv': 'Convergence'}) def check(var, entry): if var.get() == 1: entry.enable() else: entry.disable() frame_time = create_widget('frame', master=frame_options, row=0, column=0) self.widget['var']['time'] = tk.IntVar() cb_time = tk.Checkbutton(master=frame_time, variable=self.widget['var']['time'], highlightthickness=0, bd=0) cb_time.grid(row=0, column=0, sticky='W') tk.Label(master=frame_time, text=self.name_options['time'] + ': stop after').grid( row=0, column=1, sticky='W') self.widget['entry']['time'] = create_widget( 'entry', master=frame_time, row=0, column=2, class_type='float', required=True, valid_check=lambda x: x > 0, error_msg='time limit must be positive', pady=0) tk.Label(master=frame_time, text='seconds').grid(row=0, column=3, sticky='W') cb_time.configure(command=lambda: check(self.widget['var']['time'], self.widget['entry']['time'])) frame_n_iter = create_widget('frame', master=frame_options, row=1, column=0) self.widget['var']['n_iter'] = tk.IntVar() cb_n_iter = tk.Checkbutton(master=frame_n_iter, variable=self.widget['var']['n_iter'], highlightthickness=0, bd=0) cb_n_iter.grid(row=0, column=0, sticky='W') tk.Label(master=frame_n_iter, text=self.name_options['n_iter'] + ': stop after').grid( row=0, column=1, sticky='W') self.widget['entry']['n_iter'] = create_widget( 'entry', master=frame_n_iter, row=0, column=2, class_type='int', required=True, valid_check=lambda x: x > 0, error_msg='number of iterations must be positive', pady=0) tk.Label(master=frame_n_iter, text='iterations').grid(row=0, column=3, sticky='W') cb_n_iter.configure(command=lambda: check( self.widget['var']['n_iter'], self.widget['entry']['n_iter'])) frame_n_sample = create_widget('frame', master=frame_options, row=2, column=0) self.widget['var']['n_sample'] = tk.IntVar() cb_n_sample = tk.Checkbutton(master=frame_n_sample, variable=self.widget['var']['n_sample'], highlightthickness=0, bd=0) cb_n_sample.grid(row=0, column=0, sticky='W') tk.Label(master=frame_n_sample, text=self.name_options['n_sample'] + ': stop when number of samples reaches').grid(row=0, column=1, sticky='W') self.widget['entry']['n_sample'] = create_widget( 'entry', master=frame_n_sample, row=0, column=2, class_type='int', required=True, valid_check=lambda x: x > 0, error_msg='number of samples must be positive', pady=0) cb_n_sample.configure(command=lambda: check( self.widget['var']['n_sample'], self.widget['entry']['n_sample'])) if n_obj == 1: frame_opt = create_widget('frame', master=frame_options, row=3, column=0) self.widget['var']['opt'] = tk.IntVar() cb_opt = tk.Checkbutton(master=frame_opt, variable=self.widget['var']['opt'], highlightthickness=0, bd=0) cb_opt.grid(row=0, column=0, sticky='W') tk.Label(master=frame_opt, text=self.name_options['opt'] + ': stop when optimum reaches').grid(row=0, column=1, sticky='W') self.widget['entry']['opt'] = create_widget( 'entry', master=frame_opt, row=0, column=2, class_type='float', required=True, valid_check=lambda x: x > 0, error_msg='optimum value must be positive', pady=0) cb_opt.configure(command=lambda: check(self.widget['var'][ 'opt'], self.widget['entry']['opt'])) frame_opt_conv = create_widget('frame', master=frame_options, row=4, column=0) self.widget['var']['opt_conv'] = tk.IntVar() cb_opt_conv = tk.Checkbutton( master=frame_opt_conv, variable=self.widget['var']['opt_conv'], highlightthickness=0, bd=0) cb_opt_conv.grid(row=0, column=0, sticky='W') tk.Label(master=frame_opt_conv, text=self.name_options['opt_conv'] + ': stop when optimum stops to improve over past').grid( row=0, column=1, sticky='W') self.widget['entry']['opt_conv'] = create_widget( 'entry', master=frame_opt_conv, row=0, column=2, class_type='int', required=True, valid_check=lambda x: x > 0, error_msg= 'number of iterations for determining convergence must be positive', pady=0) tk.Label(master=frame_opt_conv, text='iterations').grid(row=0, column=3, sticky='W') cb_opt_conv.configure( command=lambda: check(self.widget['var']['opt_conv'], self. widget['entry']['opt_conv'])) else: frame_hv_conv = create_widget('frame', master=frame_options, row=3, column=0) self.widget['var']['hv_conv'] = tk.IntVar() cb_hv_conv = tk.Checkbutton(master=frame_hv_conv, variable=self.widget['var']['hv_conv'], highlightthickness=0, bd=0) cb_hv_conv.grid(row=0, column=0, sticky='W') tk.Label( master=frame_hv_conv, text=self.name_options['hv_conv'] + ': stop when hypervolume stops to improve over past').grid( row=0, column=1, sticky='W') self.widget['entry']['hv_conv'] = create_widget( 'entry', master=frame_hv_conv, row=0, column=2, class_type='int', required=True, valid_check=lambda x: x > 0, error_msg= 'number of iterations for determining convergence must be positive', pady=0) tk.Label(master=frame_hv_conv, text='iterations').grid(row=0, column=3, sticky='W') cb_hv_conv.configure( command=lambda: check(self.widget['var']['hv_conv'], self. widget['entry']['hv_conv'])) for key in self.name_options: self.widget['entry'][key].disable() frame_action = create_widget('frame', master=self.window, row=1, column=0, pady=0, sticky=None) self.widget['save'] = create_widget('button', master=frame_action, row=0, column=0, text='Save') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window)
def __init__(self, root_view): self.root_view = root_view self.master_window = self.root_view.root self.window = create_widget('toplevel', master=self.master_window, title='Manage Problem') grid_configure(self.window, 0, 0) self.widget = {} frame_list = create_widget('labeled_frame', master=self.window, row=0, column=0, text='Problem List') frame_list_display = create_widget('frame', master=frame_list, row=0, column=0, sticky='NS') frame_list_action = create_widget('frame', master=frame_list, row=1, column=0, padx=0, pady=0, sticky=None) frame_config = create_widget('labeled_frame', master=self.window, row=0, column=1, text='Problem Info') frame_config_display = create_widget('frame', master=frame_config, row=0, column=0, sticky='NS') frame_config_action = create_widget('frame', master=frame_config, row=1, column=0, padx=0, pady=0, sticky=None) grid_configure(frame_list, 0, 0) grid_configure(frame_config, 0, 0) self.widget['list'] = Listbox(master=frame_list_display) self.widget['list'].grid() self.widget['create'] = create_widget('button', master=frame_list_action, row=0, column=0, text='Create') self.desc = { 'name': 'Name', 'type': 'Variable type', 'n_var': 'Number of variables', 'n_obj': 'Number of objectives', 'n_constr': 'Number of constraints', 'obj_type': 'Type of objectives', } self.widget['info'] = {} for row, key in enumerate(self.desc.keys()): self.widget['info'][key] = create_widget( 'label', master=frame_config_display, row=row, column=0, text=f'{self.desc[key]}:') self.widget['update'] = create_widget('button', master=frame_config_action, row=0, column=0, text='Update') self.widget['delete'] = create_widget('button', master=frame_config_action, row=0, column=1, text='Delete') self.widget['update'].disable() self.widget['delete'].disable() center(self.window, self.master_window)
def __init__(self, root_view, first_time): self.root_view = root_view title = 'Create Experiment' if first_time else 'Update Config' self.master_window = self.root_view.root self.window = create_widget('toplevel', master=self.master_window, title=title) self.frame = {} self.widget = {} if first_time: # experiment section self.frame['exp'] = create_widget('frame', master=self.window, row=0, column=0, padx=2 * PADX) grid_configure(self.frame['exp'], 0, 0) self.widget['exp_name'] = create_widget( 'labeled_entry', master=self.frame['exp'], row=0, column=0, text='Experiment name', class_type='string', width=10, required=True, valid_check=lambda x: not x.startswith('sqlite_'), error_msg='experiment name cannot start with sqlite_') self.widget['cfg_input_type'] = create_widget( 'labeled_radiobutton', master=self.frame['exp'], row=1, column=0, label_text='Create config by', button_text_list=['User interface', 'Loading from file']) # enter config section self.frame['enter'] = tk.Frame(master=self.window) self.frame['enter'].grid(row=1 if first_time else 0, column=0, sticky='NSEW') grid_configure(self.frame['enter'], 0, 0) nb_cfg = ttk.Notebook(self.frame['enter']) nb_cfg.grid(row=0, column=0, sticky='NSEW') if first_time: # problem subsection frame_problem = tk.Frame(master=nb_cfg) grid_configure(frame_problem, 0, 0) nb_cfg.add(child=frame_problem, text='Problem') self.widget['problem_name'] = create_widget( 'labeled_combobox', master=frame_problem, row=0, column=0, text=config_map['problem']['name'], values=get_problem_list(), width=15, required=True) self.widget['init_type'] = create_widget( 'labeled_radiobutton', master=frame_problem, row=1, column=0, label_text='Initialization', button_text_list=['Random', 'From file'], default='Random') frame_random_init = create_widget('frame', master=frame_problem, row=2, column=0, padx=0, pady=0) frame_provided_init = create_widget('frame', master=frame_problem, row=2, column=0, padx=0, pady=0) grid_configure(frame_random_init, 0, 0) grid_configure(frame_provided_init, 0, 0) self.widget['n_init'] = create_widget( 'labeled_spinbox', master=frame_random_init, row=0, column=0, text=config_map['experiment']['n_random_sample'], from_=2, to=int(1e10), required=True) self.widget['set_x_init'], self.widget[ 'disp_x_init'] = create_widget( 'labeled_button_entry', master=frame_provided_init, row=0, column=0, label_text='Path of initial design variables', button_text='Browse', width=30, required=True, valid_check=lambda x: os.path.exists(x), error_msg='file of initial design variables does not exist' ) self.widget['set_y_init'], self.widget[ 'disp_y_init'] = create_widget( 'labeled_button_entry', master=frame_provided_init, row=1, column=0, label_text='Path of initial performance values', button_text='Browse', width=30, valid_check=lambda x: os.path.exists(x), error_msg= 'file of initial performance values does not exist') def set_random_init(): frame_provided_init.grid_remove() frame_random_init.grid() def set_provided_init(): frame_random_init.grid_remove() frame_provided_init.grid() for text, button in self.widget['init_type'].widget.items(): if text == 'Random': button.configure(command=set_random_init) elif text == 'From file': button.configure(command=set_provided_init) else: raise NotImplementedError set_random_init() # optimization subsection frame_opt = tk.Frame(master=nb_cfg) grid_configure(frame_opt, 0, 0) nb_cfg.add(child=frame_opt, text='Optimization') self.widget['algo_name'] = create_widget( 'labeled_combobox', master=frame_opt, row=0, column=0, text=config_map['algorithm']['name'], values=get_algorithm_list(), required=True) self.widget['n_process'] = create_widget( 'labeled_spinbox', master=frame_opt, row=1, column=0, text=config_map['algorithm']['n_process'], from_=1, to=int(1e10), default=cpu_count()) self.widget['async'] = create_widget( 'labeled_combobox', master=frame_opt, row=2, column=0, text=config_map['algorithm']['async'], default='None', values=get_hp_class_names('async')) self.widget['set_advanced'] = create_widget('button', master=frame_opt, row=3, column=0, text='Advanced Settings', sticky=None) # evaluation subsection frame_eval = tk.Frame(master=nb_cfg) grid_configure(frame_eval, 0, 0) nb_cfg.add(child=frame_eval, text='Evaluation') self.widget['n_worker'] = create_widget( 'labeled_spinbox', master=frame_eval, row=0, column=0, text=config_map['experiment']['n_worker'], from_=1, to=int(1e10)) # load config section if first_time: self.frame['load'] = create_widget('frame', master=self.window, row=1, column=0, padx=2 * PADX) grid_configure(self.frame['load'], 0, 0) self.widget['set_cfg_path'], self.widget[ 'disp_cfg_path'] = create_widget( 'labeled_button_entry', master=self.frame['load'], row=0, column=0, label_text='Path of config file', button_text='Browse', width=30, required=True, valid_check=lambda x: os.path.exists(x), error_msg='config file does not exist') def set_enter_input(): self.frame['load'].grid_remove() self.frame['enter'].grid() self.widget['save'].enable() def set_load_input(): self.frame['enter'].grid_remove() self.frame['load'].grid() self.widget['save'].enable() for text, button in self.widget['cfg_input_type'].widget.items(): if text == 'User interface': button.configure(command=set_enter_input) elif text == 'Loading from file': button.configure(command=set_load_input) else: raise NotImplementedError self.frame['enter'].grid_remove() self.frame['load'].grid_remove() # action section frame_action = tk.Frame(master=self.window) frame_action.grid(row=2 if first_time else 1, column=0, columnspan=3) self.widget['save'] = create_widget( 'button', master=frame_action, row=0, column=0, text='Create' if first_time else 'Update') self.widget['cancel'] = create_widget('button', master=frame_action, row=0, column=1, text='Cancel') center(self.window, self.master_window) self.cfg_widget = {} if first_time: self.cfg_widget.update({ 'problem': { 'name': self.widget['problem_name'], }, }) self.cfg_widget.update({ 'algorithm': { 'name': self.widget['algo_name'], 'n_process': self.widget['n_process'], 'async': self.widget['async'], }, 'experiment': { 'n_worker': self.widget['n_worker'], }, })