def test_random_config_synthetic(self):
path = os.path.dirname(hpolib.benchmarks.synthetic_functions.__file__)
for _, pkg, _ in pkgutil.iter_modules([path, ]):
pkg_name = "hpolib.benchmarks.synthetic_functions.{:s}".format(pkg)
importlib.import_module(pkg_name)
mod_name = sys.modules[pkg_name]
for name, obj in inspect.getmembers(mod_name, inspect.isclass):
if issubclass(obj, AbstractBenchmark) and "Abstract" not in name:
b = getattr(mod_name, name)()
cfg = b.get_configuration_space()
for i in range(100):
c = cfg.sample_configuration()
res = b.objective_function(c)
self.assertTrue(np.isfinite(res['function_value']))
评论列表
文章目录