Skip to content

Commit

Permalink
Fix the example
Browse files Browse the repository at this point in the history
  • Loading branch information
nabenabe0928 committed Oct 1, 2024
1 parent baf5ff3 commit fd91c4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package/samplers/user_prior_cmaes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def objective(trial: optuna.Trial) -> float:

if __name__ == "__main__":
module = optunahub.load_module(package="samplers/user_prior_cmaes")
sampler = module.UserPriorCmaEsSampler(param_names=["x", "y"], mu0=np.array([3., -48.]), cov0=np.diag([0.2, 2.0]))
sampler = module.UserPriorCmaEsSampler(param_names=["x", "y"], mu0=np.array([-48., 3.]), cov0=np.diag([2., 0.2]))
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=20)
print(study.best_trial.value, study.best_trial.params)
Expand Down
1 change: 1 addition & 0 deletions package/samplers/user_prior_cmaes/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def sample_relative(
"The most probable reason is duplicated names in param_names."
)
elif len(search_space) != 0:
# Ensure the parameter order is identical to that in param_names.
search_space = {
param_name: search_space[param_name] for param_name in self._param_names
}
Expand Down

0 comments on commit fd91c4c

Please sign in to comment.