Skip to content

Commit

Permalink
Fix was_tuned (aimclub#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
YamLyubov authored Feb 21, 2023
1 parent 6b2fa54 commit 1d6be04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions golem/core/tuning/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def tune(self, graph: DomainGraphForTune) -> DomainGraphForTune:
# Validation is the optimization do well
final_graph = self.final_check(graph)

self.was_tuned = True

return self.adapter.restore(final_graph)

def get_nodes_order(self, nodes_number: int) -> range:
Expand Down Expand Up @@ -126,6 +128,7 @@ def tune_node(self, graph: DomainGraphForTune, node_index: int) -> DomainGraphFo
iterations_per_node=self.iterations,
seconds_per_node=self.max_seconds,
)
self.was_tuned = True

# Validation is the optimization do well
final_graph = self.final_check(graph)
Expand Down
2 changes: 2 additions & 0 deletions golem/core/tuning/simultaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def tune(self, graph: DomainGraphForTune, show_progress: bool = True) -> DomainG
# Validation is the optimization do well
graph = self.final_check(tuned_graph)

self.was_tuned = True

except Exception as ex:
self.log.warning(f'Exception {ex} occurred during tuning')

Expand Down
8 changes: 8 additions & 0 deletions test/unit/optimizers/fitness/test_fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from golem.core.optimisers.fitness import null_fitness, SingleObjFitness, MultiObjFitness
from golem.core.optimisers.objective.objective import to_fitness
from golem.serializers import Serializer


Expand Down Expand Up @@ -125,3 +126,10 @@ def test_fitness_serialization(fitness):
assert fitness.valid == reserialized.valid
if fitness.valid:
assert fitness == reserialized

def test_universal_fitness_compare():
assert to_fitness([1., 1., 3.], multi_objective=False).dominates(to_fitness([1., 2., 3.], multi_objective=False))
assert to_fitness([1., 1., 3.], multi_objective=True).dominates(to_fitness([1., 2., 3.], multi_objective=True))

assert to_fitness([1., 1., 3.], multi_objective=False).dominates(to_fitness([1., 2., 1.], multi_objective=False))
assert not to_fitness([1., 1., 3.], multi_objective=True).dominates(to_fitness([1., 2., 1.], multi_objective=True))

0 comments on commit 1d6be04

Please sign in to comment.