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

Change recommend to raise an error in MOO case #1213

Merged
merged 17 commits into from
Aug 23, 2021
Merged
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
6 changes: 5 additions & 1 deletion nevergrad/optimization/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def recommend(self) -> p.Parameter:
The candidate with minimal loss. :code:`p.Parameters` have field :code:`args` and :code:`kwargs` which can be directly used
on the function (:code:`objective_function(*candidate.args, **candidate.kwargs)`).
"""
if self.num_objectives > 1:
raise RuntimeError(
"No best candidate in MOO. Use optimizer.pareto_front() instead to get the set of all non-dominated candidates."
)
recom_data = self._internal_provide_recommendation() # pylint: disable=assignment-from-none
if recom_data is None or any(np.isnan(recom_data)):
name = "minimum" if self.parametrization.function.deterministic else "pessimistic"
Expand Down Expand Up @@ -652,7 +656,7 @@ def minimize(
(tmp_finished if x_job[1].done() else tmp_runnings).append(x_job)
self._running_jobs, self._finished_jobs = tmp_runnings, tmp_finished
first_iteration = False
return self.provide_recommendation()
return self.provide_recommendation() if self.num_objectives == 1 else p.Constant(None)

def _info(self) -> tp.Dict[str, tp.Any]:
"""Easy access to debug/benchmark info"""
Expand Down