Skip to content

Commit

Permalink
Fix VecGymNE so that it can work with adaptive popsize (#106)
Browse files Browse the repository at this point in the history
This commit makes `VecGymNE` return number of interactions and number of episodes in its status dictionary, which is required for adaptive popsize to work in non-distributed mode
  • Loading branch information
engintoklu committed Jun 9, 2024
1 parent 8e91b99 commit 496e6e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/evotorch/neuroevolution/vecgymne.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ def __init__(
subbatch_size=subbatch_size,
)

self.after_eval_hook.append(self._extra_status)

def _parallelize(self):
super()._parallelize()
if self.is_main:
Expand All @@ -452,6 +454,9 @@ def _set_actor_max_num_envs(self, n: int):
self._actor_max_num_envs = n
self._actor_max_num_envs_ready = True

def _extra_status(self, batch: SolutionBatch):
return dict(total_interaction_count=self.interaction_count, total_episode_count=self.episode_count)

@property
def observation_normalization(self) -> bool:
return self._observation_normalization
Expand Down

0 comments on commit 496e6e2

Please sign in to comment.