Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ngopt faster #1329

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nevergrad/optimization/oneshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _internal_ask(self) -> tp.ArrayLike:
point = self.parametrization.sample().get_standardized_data(reference=self.parametrization)
else:
raise ValueError("Unkwnown sampler {self.sampler}")
self._opposable_data = scale * point
self._opposable_data = scale * point # type: ignore
return self._opposable_data # type: ignore

def _internal_provide_recommendation(self) -> tp.Optional[tp.ArrayLike]:
Expand Down
22 changes: 13 additions & 9 deletions nevergrad/optimization/optimizerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,9 +2779,9 @@ def _select_optimizer_cls(self) -> base.OptCls:
if (
self.budget > 5000 * self.dimension
): # Asymptotically let us trust NGOpt36 and its subtle restart.
return NGOpt36
return NGOpt36._select_optimizer_cls(self) # type: ignore
if self.dimension < 5: # Low dimension: let us hit the bounds.
return NGOpt21
return NGOpt21._select_optimizer_cls(self) # type: ignore
if self.dimension < 10: # Moderate dimension: reasonable restart + bet and run.
num = 1 + int(np.sqrt(8.0 * (8 * self.budget) // (self.dimension * 1000)))
return ConfPortfolio(optimizers=[NGOpt14] * num, warmup_ratio=0.7)
Expand All @@ -2793,7 +2793,7 @@ def _select_optimizer_cls(self) -> base.OptCls:
)
# We need a special case for dim < 30 ---> let's see later.
# Otherwise, let us go back to normal life: NGOpt16 which rocks in many cases, possibly Cobyla.
return NGOpt16
return NGOpt16._select_optimizer_cls(self) # type: ignore
elif ( # This might be specific of high-precision cases.
self.budget is not None
and self.fully_continuous
Expand All @@ -2803,7 +2803,11 @@ def _select_optimizer_cls(self) -> base.OptCls:
and self.budget > 50 * self.dimension
and p.helpers.Normalizer(self.parametrization).fully_bounded
):
return NGOpt8 if self.dimension < 3 else NGOpt15
return (
NGOpt8._select_optimizer_cls(self) # type: ignore
if self.dimension < 3
else NGOpt15._select_optimizer_cls(self) # type: ignore
)
else:
return super()._select_optimizer_cls()

Expand Down Expand Up @@ -2851,9 +2855,9 @@ def _select_optimizer_cls(self) -> base.OptCls:
if (
self.budget > 5000 * self.dimension
): # Asymptotically let us trust NGOpt36 and its subtle restart.
return NGOpt36
return NGOpt36._select_optimizer_cls(self) # type: ignore
if self.dimension < 5: # Low dimension: let us hit the bounds.
return NGOpt21
return NGOpt21._select_optimizer_cls(self) # type: ignore
if self.dimension < 10: # Moderate dimension: reasonable restart + bet and run.
num = 1 + int(np.sqrt(8.0 * (8 * self.budget) // (self.dimension * 1000)))
return ConfPortfolio(optimizers=[NGOpt14] * num, warmup_ratio=0.7)
Expand All @@ -2867,7 +2871,7 @@ def _select_optimizer_cls(self) -> base.OptCls:
return CmaFmin2
# We need a special case for dim < 30 ---> let's see later.
# Otherwise, let us go back to normal life: NGOpt16 which rocks in many cases, possibly Cobyla.
return NGOpt16
return NGOpt16._select_optimizer_cls(self) # type: ignore
elif ( # This might be specific of high-precision cases.
self.budget is not None
and self.fully_continuous
Expand All @@ -2878,12 +2882,12 @@ def _select_optimizer_cls(self) -> base.OptCls:
and p.helpers.Normalizer(self.parametrization).fully_bounded
):
if self.dimension < 3:
return NGOpt8
return NGOpt8._select_optimizer_cls(self) # type: ignore
if self.dimension <= 20 and self.num_workers == 1:
MetaModelFmin2 = ParametrizedMetaModel(multivariate_optimizer=CmaFmin2)
MetaModelFmin2.no_parallelization = True
return MetaModelFmin2
return NGOpt15
return NGOpt15._select_optimizer_cls(self) # type: ignore
else:
return super()._select_optimizer_cls()

Expand Down