plot_optimizer(opt, x, fx) ############################################################################# # Changing kappa and xi on the go # ------------------------------- # If we want to change kappa or ki at any point during our optimization # process we just replace opt.acq_func_kwargs. Remember to call # `opt.update_next()` after the change, in order for next point to be # recalculated. acq_func_kwargs = {"kappa": 0} ############################################################################# opt = Optimizer([(-2.0, 2.0)], "GP", n_initial_points=1, acq_func="LCB", acq_optimizer="sampling", acq_func_kwargs=acq_func_kwargs) ############################################################################# opt.acq_func_kwargs ############################################################################# opt.run(objective, n_iter=20) plot_optimizer(opt, x, fx) ############################################################################# acq_func_kwargs = {"kappa": 100000} ############################################################################# opt.acq_func_kwargs = acq_func_kwargs opt.update_next() ############################################################################# opt.run(objective, n_iter=20) plot_optimizer(opt, x, fx)
if __name__ == '__main__': optimizer = Optimizer(dimensions=dim_vals, n_jobs=12, random_state=1, base_estimator='RF', n_initial_points=n_initial, initial_point_generator='random') with mp.Pool(n_procs) as p: #with DebugPool() as p: jobs = [] try: for i in range(n_eval): args = optimizer.ask() optimizer.update_next() print('#######') print(f'Evaluation #{i}') print(args) print('#######') jobs.append(Job(p.apply_async(objective, args), args)) for job in jobs: if job.result.ready(): optimizer.tell(job.args, job.result.get()) jobs.remove(job) while sum(map(not_ready, jobs)) >= n_procs: time.sleep(0.5) for job in jobs: optimizer.tell(job.args, job.result.get()) except KeyboardInterrupt: pass