From bf2b0e84aa055ee42a02a7d0bd5830be3dd1837c Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Fri, 2 Aug 2024 11:59:10 +0900 Subject: [PATCH 1/3] Use optuna.search_space.IntersectionSearchSpace --- package/samplers/implicit_natural_gradient/sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/samplers/implicit_natural_gradient/sampler.py b/package/samplers/implicit_natural_gradient/sampler.py index fd880fc5..24a6c1b2 100644 --- a/package/samplers/implicit_natural_gradient/sampler.py +++ b/package/samplers/implicit_natural_gradient/sampler.py @@ -125,7 +125,7 @@ def __init__( self._independent_sampler = independent_sampler or optuna.samplers.RandomSampler(seed=seed) self._n_startup_trials = n_startup_trials self._warn_independent_sampling = warn_independent_sampling - self._search_space = optuna.samplers.IntersectionSearchSpace() + self._search_space = optuna.search_space.IntersectionSearchSpace() self._optimizer: Optional[FastINGO] = None self._seed = seed self._population_size = population_size From b360e86168c3fbc0ae9b95223f66f97ea81c6439 Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Fri, 2 Aug 2024 12:01:11 +0900 Subject: [PATCH 2/3] Remove deepcopy --- package/samplers/implicit_natural_gradient/sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/samplers/implicit_natural_gradient/sampler.py b/package/samplers/implicit_natural_gradient/sampler.py index 24a6c1b2..3eb12fa9 100644 --- a/package/samplers/implicit_natural_gradient/sampler.py +++ b/package/samplers/implicit_natural_gradient/sampler.py @@ -192,7 +192,7 @@ def sample_relative( if len(search_space) == 0: return {} - completed_trials = study.get_trials(deepcopy=True, states=[TrialState.COMPLETE]) + completed_trials = study.get_trials(deepcopy=False, states=[TrialState.COMPLETE]) if len(completed_trials) < self._n_startup_trials: return {} From a724de805f7e36cc366ea16c22b682154b48fc0c Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Fri, 2 Aug 2024 12:54:21 +0900 Subject: [PATCH 3/3] Fix INGO implementation --- package/samplers/implicit_natural_gradient/sampler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package/samplers/implicit_natural_gradient/sampler.py b/package/samplers/implicit_natural_gradient/sampler.py index 3eb12fa9..db1a9752 100644 --- a/package/samplers/implicit_natural_gradient/sampler.py +++ b/package/samplers/implicit_natural_gradient/sampler.py @@ -174,7 +174,7 @@ def _pop_from_param_queue( study._storage.set_trial_system_attr( trial_id, _GENERATION_ATTR_KEY, self._get_optimizer().generation ) - return self._param_queue.pop() + return self._param_queue.pop(0) def _check_trial_is_generation(self, trial: FrozenTrial) -> bool: current_gen = self._get_optimizer().generation @@ -233,9 +233,8 @@ def sample_relative( for i, t in enumerate(solution_trials[: self._optimizer.population_size]): assert t.value is not None, "completed trials must have a value" solutions_x[i, :] = trans.transform(t.params) - # TODO(c-bata): Check whether FastINGO assumes maximize or minimize problem solutions_y[i] = ( - -t.value if study.direction == StudyDirection.MINIMIZE else t.value + -t.value if study.direction == StudyDirection.MAXIMIZE else t.value ) self._optimizer.tell(solutions_x, solutions_y)