def _resolve_optimizer(optimizer_info): """Resolve the optimization routine from the given information dictionary. Args: optimizer_info (dict): the optimization dictionary with at least 'name' for the optimizer and settings for the optimizer settings Returns: optimizer: the optimization routine """ name = optimizer_info['name'] settings = deepcopy(optimizer_info.get('settings', {}) or {}) optimizer = get_optimizer_by_name(name) if 'optimizers' in settings and settings['optimizers']: settings['optimizers'] = [ _resolve_optimizer(info) for info in settings['optimizers'] ] if 'optimizer' in settings and settings['optimizer']: settings['optimizer'] = _resolve_optimizer(settings['optimizer']) if 'starting_point_generator' in settings and settings[ 'starting_point_generator']: cls = getattr(mot.cl_routines.optimizing.random_restart, list(settings['starting_point_generator'].keys())[0]) settings['starting_point_generator'] = cls( **list(settings['starting_point_generator'].values())[0]) return optimizer(**settings)
def __init__(self): """Storage class for communication between the options dialog and the main frame""" self.use_model_default_optimizer = True self.double_precision = False self.optimizer = mdt.configuration.get_general_optimizer_name() self.patience = mdt.configuration.get_general_optimizer_settings( )['patience'] if self.patience is None: self.patience = get_optimizer_by_name( self.optimizer).default_patience self.recalculate_all = False
def get_optimizer(self): if self.use_model_default_optimizer: return None optimizer = get_optimizer_by_name(self.optimizer) return optimizer(patience=self.patience)
def _update_default_patience(self): optimizer = get_optimizer_by_name(OptimOptions.optim_routines[ self.optimizationRoutine.currentText()]) self.patience.setText(str(optimizer.default_patience))