From 8b12370b05d158ef4b51de7cf5c8a62737d4e1ae Mon Sep 17 00:00:00 2001 From: Lyubov Yamshchikova Date: Mon, 27 Nov 2023 15:01:10 +0300 Subject: [PATCH] Rebase --- docs/source/api/tuning.rst | 5 ----- golem/core/tuning/iopt_tuner.py | 11 ++++++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/source/api/tuning.rst b/docs/source/api/tuning.rst index 9858dd8e9..97d6e8a79 100644 --- a/docs/source/api/tuning.rst +++ b/docs/source/api/tuning.rst @@ -52,11 +52,6 @@ You can tune all parameters of graph nodes simultaneously using ``SimultaneousTu .. note:: ``IOptTuner`` implements deterministic algorithm. - For now ``IOptTuner`` can not be constrained by time, so constrain execution by number of iterations. - - Also ``IOptTuner`` can optimise only `continuous` and `discrete` parameters but not `categorical` ones. - `Categorical` parameters will be ignored while tuning. - ``IOptTuner`` is implemented using `IOpt library`_. See the `documentation`_ (in Russian) to learn more about the optimisation algorithm. diff --git a/golem/core/tuning/iopt_tuner.py b/golem/core/tuning/iopt_tuner.py index 0dbe70ef6..fccf778db 100644 --- a/golem/core/tuning/iopt_tuner.py +++ b/golem/core/tuning/iopt_tuner.py @@ -1,7 +1,6 @@ from copy import deepcopy from dataclasses import dataclass, field from datetime import timedelta -from random import choice from typing import List, Dict, Generic, Tuple, Any, Optional import numpy as np @@ -147,14 +146,15 @@ def _tune(self, graph: DomainGraphForTune, show_progress: bool = True) -> Domain has_parameters_to_optimize = (len(problem_parameters.discrete_parameters_names) > 0 or len(problem_parameters.float_parameters_names) > 0) - objectives_number = len(ensure_wrapped_in_sequence(self.init_metric)) - is_multi_objective = objectives_number > 1 - if self._check_if_tuning_possible(graph, has_parameters_to_optimize): + self.objectives_number = len(ensure_wrapped_in_sequence(self.init_metric)) + is_multi_objective = self.objectives_number > 1 + + if self._check_if_tuning_possible(graph, has_parameters_to_optimize, supports_multi_objective=True): if initial_parameters: initial_point = Point(**initial_parameters) self.solver_parameters.start_point = initial_point - problem = GolemProblem(graph, self.objective_evaluate, problem_parameters, objectives_number) + problem = GolemProblem(graph, self.objective_evaluate, problem_parameters, self.objectives_number) solver = Solver(problem, parameters=self.solver_parameters) if show_progress: @@ -177,6 +177,7 @@ def _tune(self, graph: DomainGraphForTune, show_progress: bool = True) -> Domain self.was_tuned = True else: tuned_graphs = graph + return tuned_graphs def _get_parameters_for_tune(self, graph: OptGraph) -> Tuple[IOptProblemParameters, dict]: