Skip to content

Commit

Permalink
Merge branch 'multi_dimensional_action' into boptest-gym-service
Browse files Browse the repository at this point in the history
  • Loading branch information
javiarrobas committed Oct 3, 2024
2 parents 52e489e + 078c634 commit 910f7e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions boptestGymEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,14 +1065,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]

Expand Down
2 changes: 1 addition & 1 deletion testing/references/vectorized_training.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
keys,value
0,7
0,0

0 comments on commit 910f7e1

Please sign in to comment.