def _make_phoenics_object(self, objective, passive_angles=None, conf=None, *args, **kwargs): if conf is not None: if hasattr(conf, 'readlines'): bird = phoenics.Phoenics(config_file=conf) else: bird = phoenics.Phoenics(config_dict=conf) return bird op = objective.extract_variables() if passive_angles is not None: for i, thing in enumerate(op): if thing in passive_angles.keys(): op.remove(thing) config = {"general": {"auto_desc_gen": "False", "batches": 5, "boosted": "False", "parallel": "False"}} config['parameters'] = [ {'name': k, 'periodic': 'True', 'type': 'continuous', 'size': 1, 'low': 0, 'high': 2 * pi} for k in op] if self._minimize is True: config['objectives'] = [{"name": "Energy", "goal": "minimize"}] else: config['objectives'] = [{"name": "Energy", "goal": "maximize"}] for k,v in kwargs.items(): if hasattr(k, "lower") and k.lower() in config["general"]: config["general"][k.lower()] = v if not self.silent: print("Phoenics config:\n") print(config) bird = phoenics.Phoenics(config_dict=config) return bird
def _make_phoenics_object(self, objective, passive_angles=None, conf=None, *args, **kwargs): """ instantiate phoenics, to perform optimization. Parameters ---------- objective: Objective: the objective to optimize over. passive_angles: dict, optional: a dictionary of angles not to optimize over. conf: optional: a user built configuration object or file, from which to initialize a phoenics object. For advanced users only. args kwargs Returns ------- phoenics.Phoenics a phoenics object configured to optimize an objective. """ if conf is not None: if hasattr(conf, 'readlines'): bird = phoenics.Phoenics(config_file=conf) else: bird = phoenics.Phoenics(config_dict=conf) return bird op = objective.extract_variables() if passive_angles is not None: for i, thing in enumerate(op): if thing in passive_angles.keys(): op.remove(thing) config = {"general": {"auto_desc_gen": "False", "batches": 5, "boosted": "False", "parallel": "False"}} config['parameters'] = [ {'name': k, 'periodic': 'True', 'type': 'continuous', 'size': 1, 'low': 0, 'high': 2 * pi} for k in op] if self._minimize is True: config['objectives'] = [{"name": "Energy", "goal": "minimize"}] else: config['objectives'] = [{"name": "Energy", "goal": "maximize"}] for k,v in kwargs.items(): if hasattr(k, "lower") and k.lower() in config["general"]: config["general"][k.lower()] = v if not self.silent: print("Phoenics config:\n") print(config) bird = phoenics.Phoenics(config_dict=config) return bird