Beispiel #1
0
def optimize_chemist(func_caller,
                     worker_manager,
                     budget,
                     mode=None,
                     init_pool=None,
                     acq='hei',
                     options=None,
                     reporter='default'):
    """ Chemist optimization from a function caller. """
    if options is None:
        reporter = get_reporter(reporter)
        options = load_options(all_chemist_args, reporter=reporter)

    # TODO: what is this option?
    if acq is not None:
        options.acq = acq

    if mode is not None:
        options.mode = mode

    # Initial queries
    if not hasattr(options,
                   'pre_eval_points') or options.pre_eval_points is None:
        if init_pool is None:
            init_pool = get_initial_pool()
        options.get_initial_points = lambda n: init_pool[:n]

    return (Chemist(func_caller,
                    worker_manager,
                    options=options,
                    reporter=reporter)).optimise(budget)
def get_mol_opt_arguments():
    """ Returns arguments for NN Optimisation. """
    ret = Namespace()
    ret.ga_init_pool = get_initial_pool()
    ret.ga_init_vals = [mol_func(mol) for mol in ret.ga_init_pool]
    ret.mol_domain = MolDomain()
    return ret
def prep_optimiser_args(obj_func, optimiser_args):
    """ Returns the options and reporter. """
    reporter = get_reporter('default')
    options = load_options(optimiser_args, reporter=reporter)
    options.pre_eval_points = get_initial_pool()
    options.pre_eval_vals = [obj_func(mol) for mol in options.pre_eval_points]
    options.pre_eval_true_vals = options.pre_eval_vals
    options_clone = deepcopy(options)
    return options, options_clone, reporter
Beispiel #4
0
 def _set_up_acq_opt_ga(self):
     self.ga_init_pool = get_initial_pool()
     self.ga_mutation_op = lambda x: x
     # In future, implement Domains:
     # # The initial pool
     # self.ga_init_pool = get_initial_pool(self.domain.get_type())
     # # The number of evaluations
     if self.get_acq_opt_max_evals is None:
         #lead_const = min(5, self.domain.get_dim())**2
         lead_const = 25
         self.get_acq_opt_max_evals = lambda t: np.clip(
             lead_const * int(np.sqrt(t)), 50, 500)
Beispiel #5
0
    def __init__(self, fitness_func, initial_pool=None, max_pool_size=None):
        """
        Params:
        :fitness_func: function to optimize over evolution
        :initial_pool: just what it says
        :max_pool_size: int or None

        TODO:
        :mutation_op: mutates a given Molecule
        :crossover_op: takes two Molecules
                    and returns one new Molecule
        """
        self.fitness_func = fitness_func
        self.synth = RexgenForwardSynthesizer()
        if initial_pool is None:
            initial_pool = get_initial_pool()
        self.pool = initial_pool
        self.max_pool_size = max_pool_size