Skip to content

Commit

Permalink
Allow custom search spaces in get_experiment_with_observations (#2027)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #2027

Reviewed By: Balandat

Differential Revision: D51682453

fbshipit-source-id: 1b886a50ef7f57875b75acabc4a9b199f0b293f9
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Nov 30, 2023
1 parent d4af0c4 commit e44f621
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ax/utils/testing/core_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def get_experiment_with_observations(
scalarized: bool = False,
constrained: bool = False,
with_tracking_metrics: bool = False,
search_space: Optional[SearchSpace] = None,
) -> Experiment:
multi_objective = (len(observations[0]) - constrained) > 1
if multi_objective:
Expand Down Expand Up @@ -680,8 +681,9 @@ def get_experiment_with_observations(
)
else:
optimization_config = OptimizationConfig(objective=objective)
search_space = search_space or get_search_space_for_range_values(min=0.0, max=1.0)
exp = Experiment(
search_space=get_search_space_for_range_values(min=0.0, max=1.0),
search_space=search_space,
optimization_config=optimization_config,
tracking_metrics=[
Metric(name=f"m{len(observations[0])}", lower_is_better=False)
Expand All @@ -691,10 +693,10 @@ def get_experiment_with_observations(
runner=SyntheticRunner(),
is_test=True,
)
sobol_generator = get_sobol(search_space=search_space)
for i, obs in enumerate(observations):
# Create a dummy trial to add the observation.
trial = exp.new_trial()
trial.add_arm(Arm({"x": i / 100.0, "y": i / 100.0}))
trial = exp.new_trial(generator_run=sobol_generator.gen(n=1))
data = Data(
df=pd.DataFrame.from_records(
[
Expand Down

0 comments on commit e44f621

Please sign in to comment.