def test_num_trials(self): ss = get_discrete_search_space() # Check that with budget that is lower than exhaustive, BayesOpt is used. sobol_gpei = choose_generation_strategy(search_space=ss, num_trials=11) self.assertEqual(sobol_gpei._steps[0].model.value, "Sobol") self.assertEqual(sobol_gpei._steps[1].model.value, "BO_MIXED") # Check that with budget that is exhaustive, Sobol is used. sobol = choose_generation_strategy(search_space=ss, num_trials=12) self.assertEqual(sobol._steps[0].model.value, "Sobol") self.assertEqual(len(sobol._steps), 1)
def test_deduplicate(self): sobol = RandomModelBridge( search_space=get_discrete_search_space(), model=SobolGenerator(deduplicate=True), transforms=Cont_X_trans, ) for _ in range( 24): # Search space is {[0, 3], [5, 7], {"red", "panda"}} self.assertEqual(len(sobol.gen(1).arms), 1) with self.assertRaises(SearchSpaceExhausted): sobol.gen(1)