def fmin_smac_nopynisher()

in benchmarks/run_smac_benchmarks.py [0:0]


def fmin_smac_nopynisher(func, x0, bounds, maxfun, rng):
    """
    Minimize a function using SMAC, but without pynisher, which doesn't work
    well with benchmark_minimize_callable.
    
    This function is based on SMAC's fmin_smac.
    """
    cs = ConfigurationSpace()
    tmplt = 'x{0:0' + str(len(str(len(bounds)))) + 'd}'
    for idx, (lower_bound, upper_bound) in enumerate(bounds):
        parameter = UniformFloatHyperparameter(
            name=tmplt.format(idx + 1),
            lower=lower_bound,
            upper=upper_bound,
            default_value=x0[idx],
        )
        cs.add_hyperparameter(parameter)

    scenario_dict = {
        "run_obj": "quality",
        "cs": cs,
        "deterministic": "true",
        "initial_incumbent": "DEFAULT",
        "runcount_limit": maxfun,
    }
    scenario = Scenario(scenario_dict)

    def call_ta(config):
        x = np.array([val for _, val in sorted(config.get_dictionary().items())],
                     dtype=np.float)
        return func(x)

    smac = SMAC4HPO(
        scenario=scenario,
        tae_runner=ExecuteTAFuncArray,
        tae_runner_kwargs={'ta': call_ta, 'use_pynisher': False},
        rng=rng,
        initial_design=RandomConfigurations,
    )

    smac.optimize()
    return