From f3ca2f10cfe7b1c5b476b2a045c6fdce7a4f22d1 Mon Sep 17 00:00:00 2001 From: Javier Arroyo Date: Thu, 3 Oct 2024 16:42:23 +0200 Subject: [PATCH 1/2] Fix _get_indices. --- boptestGymEnv.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/boptestGymEnv.py b/boptestGymEnv.py index b272a21..6e1f8b6 100644 --- a/boptestGymEnv.py +++ b/boptestGymEnv.py @@ -1037,14 +1037,20 @@ def _get_indices(self, action_wrapper): Then, `_get_indices` example, for action_wrapper = 37: indices = [] Loop 3 times: - Iteration 1: indices.append(37 % 4) -> indices = [1], action_wrapper //= 4 -> action_wrapper = 9 - Iteration 2: indices.append(9 % 4) -> indices = [1, 1], action_wrapper //= 4 -> action_wrapper = 2 - Iteration 3: indices.append(2 % 4) -> indices = [1, 1, 2], action_wrapper //= 4 -> action_wrapper = 0 - Reverse indices: [2, 1, 1] + Iteration 1: indices.append((37+1) % 4) -> indices = [2], action_wrapper //= 4 -> action_wrapper = 9 + Iteration 2: indices.append((9+1) % 4) -> indices = [2, 2], action_wrapper //= 4 -> action_wrapper = 2 + Iteration 3: indices.append((2+1) % 4) -> indices = [2, 2, 3], action_wrapper //= 4 -> action_wrapper = 0 + Reverse indices: [3, 2, 2] + + Note + ---- + To understand why we need to add 1 in `action_wrapper+1)%self.n_bins_act` think of the corner case + where we only have one bin. If the action_wrapper is 1, then the index should be 1, but if we do not + add 1, the index would be 0 (because 1%1=0). """ indices=[] for _ in range(self.n_act): - indices.append(action_wrapper%self.n_bins_act) + indices.append((action_wrapper+1)%self.n_bins_act) action_wrapper //= self.n_bins_act return indices[::-1] From 078c634bef1f0fd7a9c055656ad03fc9aee29bcc Mon Sep 17 00:00:00 2001 From: Javier Arroyo Date: Thu, 3 Oct 2024 16:43:20 +0200 Subject: [PATCH 2/2] Back to previous reference with vectorized_training. --- testing/references/vectorized_training.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/references/vectorized_training.csv b/testing/references/vectorized_training.csv index 878d3e0..2d768af 100644 --- a/testing/references/vectorized_training.csv +++ b/testing/references/vectorized_training.csv @@ -1,2 +1,2 @@ keys,value -0,7 \ No newline at end of file +0,0 \ No newline at end of file