Skip to content

Commit

Permalink
fixed policy.load for MPI mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Aug 30, 2024
1 parent e5a4e17 commit 2a03337
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion physbo/search/discrete/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,13 @@ def load(self, file_history, file_training=None, file_predictor=None):
self.predictor = pickle.load(f)

N = self.history.total_num_search
self.actions = self._delete_actions(self.history.chosen_actions[:N])

visited = self.history.chosen_actions[:N]
local_index = np.searchsorted(self.actions, visited)
local_index = local_index[
np.take(self.actions, local_index, mode="clip") == visited
]
self.actions = self._delete_actions(local_index)

def export_predictor(self):
"""
Expand Down
8 changes: 7 additions & 1 deletion physbo/search/discrete_multi/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,13 @@ def load(self, file_history, file_training_list=None, file_predictor_list=None):
self.load_predictor_list(file_predictor_list)

N = self.history.total_num_search
self.actions = self._delete_actions(self.history.chosen_actions[:N])

visited = self.history.chosen_actions[:N]
local_index = np.searchsorted(self.actions, visited)
local_index = local_index[
np.take(self.actions, local_index, mode="clip") == visited
]
self.actions = self._delete_actions(local_index)

def save_predictor_list(self, file_name):
with open(file_name, "wb") as f:
Expand Down

0 comments on commit 2a03337

Please sign in to comment.