Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ax/adapter/tests/test_torch_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ def test_pairwise_preference_generator(self) -> None:
surrogate=surrogate,
),
optimization_config=OptimizationConfig(
Objective(
objective=Objective(
metric=Metric(Keys.PAIRWISE_PREFERENCE_QUERY.value),
minimize=False,
)
Expand Down
13 changes: 9 additions & 4 deletions ax/adapter/tests/test_torch_moo_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ def test_hypervolume(self, _, cuda: bool = False) -> None:
)
for trial in exp.trials.values():
trial.mark_running(no_runner_required=True).mark_completed()
# pyre-fixme[16]: Optional type has no attribute `metrics`.
metrics_dict = exp.metrics
# Objective thresholds and synthetic observations chosen to have closed-form
# hypervolumes to test.
Expand Down Expand Up @@ -464,9 +463,15 @@ def test_infer_objective_thresholds(self, _, cuda: bool = False) -> None:
first = sub_exprs[0]
if not first.startswith("-"):
sub_exprs[0] = f"-{first}"
oc.objective = Objective(
expression=", ".join(sub_exprs),
metric_name_to_signature={s.lstrip("-"): s.lstrip("-") for s in sub_exprs},
oc = oc.clone_with_args(
objectives=[
Objective(
expression=", ".join(sub_exprs),
metric_name_to_signature={
s.lstrip("-"): s.lstrip("-") for s in sub_exprs
},
)
]
)

for use_partial_thresholds in (False, True):
Expand Down
7 changes: 4 additions & 3 deletions ax/adapter/transforms/relativize.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def transform_optimization_config(
"Expected multi-objective, got single-objective"
)
new_optimization_config = optimization_config.clone_with_args(
objective=objective,
objectives=[objective],
outcome_constraints=constraints,
)
elif isinstance(optimization_config, MultiObjectiveOptimizationConfig):
Expand All @@ -174,13 +174,14 @@ def transform_optimization_config(
)

new_optimization_config = optimization_config.clone_with_args(
objective=optimization_config.objective,
objectives=[optimization_config.objective],
outcome_constraints=constraints,
objective_thresholds=obj_thresholds,
)
else:
new_optimization_config = optimization_config.clone_with_args(
objective=optimization_config.objective, outcome_constraints=constraints
objectives=[optimization_config.objective],
outcome_constraints=constraints,
)

return new_optimization_config
Expand Down
10 changes: 6 additions & 4 deletions ax/adapter/transforms/standardize_y.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ def transform_optimization_config(
(name, new_w)
for (name, _), new_w in zip(objective.metric_weights, new_weights)
]
optimization_config.objective = _build_objective_from_metric_weights(
new_metric_weights,
metric_name_to_signature=objective.metric_name_to_signature,
)
optimization_config._objectives = [
_build_objective_from_metric_weights(
new_metric_weights,
metric_name_to_signature=objective.metric_name_to_signature,
)
]

new_constraints = self._transform_constraints(
optimization_config.outcome_constraints, adapter
Expand Down
10 changes: 6 additions & 4 deletions ax/adapter/transforms/stratified_standardize_y.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ def transform_optimization_config(
(name, new_w)
for (name, _), new_w in zip(objective.metric_weights, new_weights)
]
optimization_config.objective = _build_objective_from_metric_weights(
new_metric_weights,
metric_name_to_signature=objective.metric_name_to_signature,
)
optimization_config._objectives = [
_build_objective_from_metric_weights(
new_metric_weights,
metric_name_to_signature=objective.metric_name_to_signature,
)
]

optimization_config.outcome_constraints = self._transform_constraints(
optimization_config.outcome_constraints, strata, adapter
Expand Down
2 changes: 1 addition & 1 deletion ax/api/utils/instantiation/from_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ def optimization_config_from_string(
)

return OptimizationConfig(
objective=objective,
objectives=[objective],
outcome_constraints=outcome_constraints,
)
2 changes: 1 addition & 1 deletion ax/benchmark/benchmark_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def get_soo_opt_config(
)

config = OptimizationConfig(
objective=objective, outcome_constraints=outcome_constraints
objectives=[objective], outcome_constraints=outcome_constraints
)
return config, [obj_metric] + constraint_metrics

Expand Down
18 changes: 10 additions & 8 deletions ax/benchmark/problems/surrogate/hss/cifar10_surrogate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,16 @@ def get_cifar10_surrogate_benchmark(
)

optimization_config = OptimizationConfig(
objective=Objective(
metric=BenchmarkMetric(
name="CIFAR10 Test Accuracy",
lower_is_better=False,
observe_noise_sd=False,
),
minimize=False,
)
objectives=[
Objective(
metric=BenchmarkMetric(
name="CIFAR10 Test Accuracy",
lower_is_better=False,
observe_noise_sd=False,
),
minimize=False,
)
],
)

return BenchmarkProblem(
Expand Down
18 changes: 10 additions & 8 deletions ax/benchmark/problems/surrogate/hss/fashion_mnist_surrogate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,16 @@ def get_fashion_mnist_surrogate_benchmark(
)

optimization_config = OptimizationConfig(
objective=Objective(
metric=BenchmarkMetric(
name="FashionMNIST Test Accuracy",
lower_is_better=False,
observe_noise_sd=False,
),
minimize=False,
)
objectives=[
Objective(
metric=BenchmarkMetric(
name="FashionMNIST Test Accuracy",
lower_is_better=False,
observe_noise_sd=False,
),
minimize=False,
)
],
)

return BenchmarkProblem(
Expand Down
18 changes: 10 additions & 8 deletions ax/benchmark/problems/surrogate/hss/mnist_surrogate.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,16 @@ def get_mnist_surrogate_benchmark(
)

optimization_config = OptimizationConfig(
objective=Objective(
metric=BenchmarkMetric(
name="MNIST Test Accuracy",
lower_is_better=False,
observe_noise_sd=False,
),
minimize=False,
)
objectives=[
Objective(
metric=BenchmarkMetric(
name="MNIST Test Accuracy",
lower_is_better=False,
observe_noise_sd=False,
),
minimize=False,
)
],
)

return BenchmarkProblem(
Expand Down
Loading
Loading