mirror of
https://github.com/microsoft/autogen.git
synced 2025-09-25 16:16:37 +00:00

* notebook test * add ipykernel, remove except * only create dir if not empty * Stop sequential tuning when result is None * fix reproducibility of global search * save gs seed * use get to avoid KeyError * test
26 lines
559 B
Python
26 lines
559 B
Python
from flaml import tune
|
|
|
|
n_trials = 0
|
|
|
|
|
|
def evaluate_config(config):
|
|
global n_trials
|
|
n_trials += 1
|
|
if n_trials >= 10:
|
|
return None
|
|
metric = (round(config["x"]) - 85000) ** 2 - config["x"] / config["y"]
|
|
return metric
|
|
|
|
|
|
def test_eval_stop():
|
|
analysis = tune.run(
|
|
evaluate_config,
|
|
config={
|
|
"x": tune.qloguniform(lower=1, upper=100000, q=1),
|
|
"y": tune.qlograndint(lower=2, upper=100000, q=2),
|
|
},
|
|
num_samples=100,
|
|
mode="max",
|
|
)
|
|
assert len(analysis.trials) == 10
|