From a70b5b8b2938892b59e525db4225314565688b8c Mon Sep 17 00:00:00 2001 From: Adamantios Date: Tue, 16 Jul 2024 15:28:12 +0300 Subject: [PATCH] fix: set randomness only the first time when benchmarking --- .../skills/decision_maker_abci/behaviours/tool_selection.py | 2 +- packages/valory/skills/decision_maker_abci/policy.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index ac4de0b90..17816bec8 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -43,7 +43,7 @@ def _select_tool(self) -> Generator[None, None, Optional[str]]: return None randomness = ( - self.benchmarking_mode.randomness + (self.benchmarking_mode.randomness if self.is_first_period else None) if self.benchmarking_mode.enabled else self.synchronized_data.most_voted_randomness ) diff --git a/packages/valory/skills/decision_maker_abci/policy.py b/packages/valory/skills/decision_maker_abci/policy.py index eaece391a..b85e71ac3 100644 --- a/packages/valory/skills/decision_maker_abci/policy.py +++ b/packages/valory/skills/decision_maker_abci/policy.py @@ -137,12 +137,14 @@ def update_weighted_accuracy(self) -> None: for tool, acc_info in self.accuracy_store.items() } - def select_tool(self, randomness: RandomnessType) -> Optional[str]: + def select_tool(self, randomness: RandomnessType = None) -> Optional[str]: """Select a Mech tool and return its index.""" if self.n_tools == 0: return None - random.seed(randomness) + if randomness is not None: + random.seed(randomness) + if not self.has_updated or random.random() < self.eps: # nosec return self.random_tool