def test_random_parzen_estimators(): minimize( function_to_optimize, optimization_problem, optimizer_type="parzen_estimator", number_of_evaluation=35, )
def test_passing_optimizer_directly(): minimize( function_to_optimize, optimization_problem, optimizer_type=RandomOptimizer, number_of_evaluation=5, )
def test_suggestions_with_global_seed_reset(): suggestions = [] def eval_(x: float) -> float: suggestions.append(x) np.random.seed(0) return 1.0 params = [{ "name": "x", "category": "uniform", "search_space": { "low": 0, "high": 1 } }] minimize(eval_, params, optimizer_type="parzen_estimator", number_of_evaluation=5) assert len(suggestions) == len(set(suggestions))
def test_random_uniform(): optimization_problem = [{ "name": "x", "category": "uniform", "search_space": { "low": 0, "high": np.pi } }] best_sample = minimize(f, optimization_problem, optimizer_type="random", number_of_evaluation=100) assert np.abs(best_sample["x"] - (np.pi / 2)) < 0.1
def test_random_uniform(): np.random.seed(0) minimize(function_to_optimize, optimization_problem, optimizer_type="random", number_of_evaluation=5)