mirror of
https://github.com/microsoft/autogen.git
synced 2025-09-24 07:34:02 +00:00
26 lines
701 B
Python
26 lines
701 B
Python
![]() |
def test_config_constraint():
|
||
|
from flaml import tune
|
||
|
|
||
|
# Test dict return value
|
||
|
def evaluate_config_dict(config):
|
||
|
metric = (round(config["x"]) - 85000) ** 2 - config["x"] / config["y"]
|
||
|
return {"metric": metric}
|
||
|
|
||
|
def config_constraint(config):
|
||
|
if config["y"] >= config["x"]:
|
||
|
return 1
|
||
|
else:
|
||
|
return 0
|
||
|
|
||
|
tune.run(
|
||
|
evaluate_config_dict,
|
||
|
config={
|
||
|
"x": tune.qloguniform(lower=1, upper=100000, q=1),
|
||
|
"y": tune.qrandint(lower=2, upper=100000, q=2),
|
||
|
},
|
||
|
config_constraints=[(config_constraint, ">", 0.5)],
|
||
|
metric="metric",
|
||
|
mode="max",
|
||
|
num_samples=100,
|
||
|
)
|