Skip to content

Commit 3986cbd

Browse files
committed
simplify num_initial_random check
Signed-off-by: Grossberger Lukas (CR/AIR2.2) <Lukas.Grossberger@de.bosch.com>
1 parent fc391bc commit 3986cbd

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

blackboxopt/optimizers/botorch_base.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,11 @@ def generate_evaluation_specification(self) -> EvaluationSpecification:
278278
):
279279
raise OptimizerNotReady
280280

281+
# Generate random samples until there are enough samples where at least one of
282+
# the objective values is available
281283
if self.num_initial_random > 0 and (
282-
self.X.size(-2) < self.num_initial_random
283-
or (
284-
torch.nonzero(~torch.any(self.losses.isnan(), dim=1)).numel()
285-
< self.num_initial_random
286-
)
284+
sum(~torch.any(self.losses.isnan(), dim=1)) < self.num_initial_random
287285
):
288-
# We keep generating random samples until there are enough samples, and
289-
# at least one of them has a valid objective
290286
eval_spec = EvaluationSpecification(
291287
configuration=self.search_space.sample(),
292288
optimizer_info={"model_based_pick": False},

0 commit comments

Comments
 (0)