Skip to content

Commit

Permalink
Add an option for parameter constraints to get_branin_experiment (#2933)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2933

Adds an option to add parameter constraints in `get_branin_experiment`, which will be used in a follow up diff for testing.

Reviewed By: sdaulton

Differential Revision: D64697748

fbshipit-source-id: cf0f04d18d04e3f9366ad9a8bf88f7ed2b4908dc
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Oct 22, 2024
1 parent eed02a7 commit 29226d8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ax/utils/testing/core_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def get_branin_experiment(
with_fidelity_parameter: bool = False,
with_choice_parameter: bool = False,
with_str_choice_param: bool = False,
with_parameter_constraint: bool = False,
search_space: SearchSpace | None = None,
minimize: bool = False,
named: bool = True,
Expand All @@ -257,6 +258,7 @@ def get_branin_experiment(
with_fidelity_parameter=with_fidelity_parameter,
with_choice_parameter=with_choice_parameter,
with_str_choice_param=with_str_choice_param,
with_parameter_constraint=with_parameter_constraint,
)
exp = Experiment(
name="branin_test_experiment" if named else None,
Expand Down Expand Up @@ -919,6 +921,7 @@ def get_branin_search_space(
with_fidelity_parameter: bool = False,
with_choice_parameter: bool = False,
with_str_choice_param: bool = False,
with_parameter_constraint: bool = False,
) -> SearchSpace:
parameters = [
RangeParameter(
Expand Down Expand Up @@ -955,8 +958,16 @@ def get_branin_search_space(
target_value=1.0,
)
)
if with_parameter_constraint:
constraints = [
ParameterConstraint(constraint_dict={"x1": 1, "x2": 1}, bound=15.0)
]
else:
constraints = None

return SearchSpace(parameters=cast(list[Parameter], parameters))
return SearchSpace(
parameters=cast(list[Parameter], parameters), parameter_constraints=constraints
)


def get_factorial_search_space() -> SearchSpace:
Expand Down

0 comments on commit 29226d8

Please sign in to comment.