Created
December 3, 2018 11:46
-
-
Save gyu-don/d63a33e98c4ca30d32302b47bb82f96d to your computer and use it in GitHub Desktop.
Blueqat VQE minimizer using PFN's Optuna library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import optuna | |
def get_optuna_minimizer(n_trials, study=None): | |
if study is None: | |
study = optuna.create_study() | |
def minimizer(objective, n_params): | |
def optuna_objective(trial): | |
params = [trial.suggest_uniform(f'params[{i}]', 0.0, 1.0) for i in range(n_params)] | |
return objective(params) | |
study.optimize(optuna_objective, n_trials=n_trials) | |
return [study.best_params[k] for k in sorted(study.best_params)] | |
return minimizer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment