Skip to content

Commit

Permalink
Merge branch 'develop' into release-1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Jun 17, 2022
2 parents ff131c9 + 08f1d9a commit 2b2c14e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion physbo/search/discrete/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, test_X, config=None, initial_data=None, comm=None):
self.mpisize = comm.size
self.mpirank = comm.rank
self.actions = np.array_split(self.actions, self.mpisize)[self.mpirank]
self.config.learning.is_disp = self.mpirank == 0
self.config.learning.is_disp = (self.config.learning.is_disp and self.mpirank == 0)

def set_seed(self, seed):
"""
Expand Down Expand Up @@ -251,6 +251,9 @@ def bayes_search(
if self.mpirank != 0:
is_disp = False

old_disp = self.config.learning.is_disp
self.config.learning.is_disp = is_disp

if max_num_probes is None:
max_num_probes = 1
simulator = None
Expand Down Expand Up @@ -296,6 +299,7 @@ def bayes_search(
break

if simulator is None:
self.config.learning.is_disp = old_disp
return action

time_run_simulator = time.time()
Expand All @@ -315,6 +319,7 @@ def bayes_search(
if is_disp:
utility.show_search_results(self.history, N_indeed)
self._update_predictor()
self.config.learning.is_disp = old_disp
return copy.deepcopy(self.history)

@staticmethod
Expand Down
6 changes: 6 additions & 0 deletions physbo/search/discrete_multi/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def bayes_search(
if self.mpirank != 0:
is_disp = False

old_disp = self.config.learning.is_disp
self.config.learning.is_disp = is_disp

if max_num_probes is None:
max_num_probes = 1
simulator = None
Expand Down Expand Up @@ -230,9 +233,11 @@ def bayes_search(
if N_indeed == 0:
if self.mpirank == 0:
print("WARNING: All actions have already searched.")
self.config.learning.is_disp = old_disp
return copy.deepcopy(self.history)

if simulator is None:
self.config.learning.is_disp = old_disp
return action

time_run_simulator = time.time()
Expand All @@ -254,6 +259,7 @@ def bayes_search(
self.history, N, disp_pareto_set=disp_pareto_set
)
self._update_predictor()
self.config.learning.is_disp = old_disp
return copy.deepcopy(self.history)

def _get_actions(self, mode, N, K, alpha):
Expand Down

0 comments on commit 2b2c14e

Please sign in to comment.