@@ -170,6 +170,56 @@ def test_find_optimum_in_1d_discrete_space(seed):
170
170
assert opt .objective .name in best .objectives
171
171
172
172
173
+ def test_propose_random_until_enough_evaluations_without_missing_objective_values (seed ):
174
+ space = ps .ParameterSpace ()
175
+ space .add (ps .IntegerParameter ("integ" , (0 , 2 )))
176
+ batch_shape = torch .Size ()
177
+
178
+ opt = SingleObjectiveBOTorchOptimizer (
179
+ search_space = space ,
180
+ objective = Objective ("loss" , greater_is_better = False ),
181
+ model = SingleTaskGP (
182
+ torch .empty ((* batch_shape , 0 , len (space )), dtype = torch .float64 ),
183
+ torch .empty ((* batch_shape , 0 , 1 ), dtype = torch .float64 ),
184
+ ),
185
+ acquisition_function_factory = partial (
186
+ UpperConfidenceBound , beta = 1.0 , maximize = False
187
+ ),
188
+ num_initial_random_samples = 2 ,
189
+ max_pending_evaluations = 1 ,
190
+ seed = seed ,
191
+ )
192
+
193
+ es = opt .generate_evaluation_specification ()
194
+ assert not es .optimizer_info [
195
+ "model_based_pick"
196
+ ], "No evaluation reported, 0 < 2 initial random samples"
197
+ opt .report (
198
+ es .create_evaluation (objectives = {"loss" : es .configuration ["integ" ] ** 2 }),
199
+ )
200
+
201
+ es = opt .generate_evaluation_specification ()
202
+ assert not es .optimizer_info [
203
+ "model_based_pick"
204
+ ], "One evaluation reported, 1 < 2 initial random samples"
205
+ opt .report (
206
+ es .create_evaluation (objectives = {"loss" : None }),
207
+ )
208
+
209
+ es = opt .generate_evaluation_specification ()
210
+ assert not es .optimizer_info [
211
+ "model_based_pick"
212
+ ], "One valid evaluation reported, 1 < 2 initial random samples"
213
+ opt .report (
214
+ es .create_evaluation (objectives = {"loss" : es .configuration ["integ" ] ** 2 }),
215
+ )
216
+
217
+ es = opt .generate_evaluation_specification ()
218
+ assert es .optimizer_info [
219
+ "model_based_pick"
220
+ ], "Two valid evaluations reported, 2 >= 2 initial random samples"
221
+
222
+
173
223
def test_get_numerical_points_from_discrete_space ():
174
224
p0l , p0h = - 5 , 10
175
225
p1 = ("small" , "medium" , "large" )
0 commit comments