Skip to content

Conversation

@AngelFP
Copy link
Member

@AngelFP AngelFP commented Nov 30, 2023

This PR adds support for interactive explorations where the range of varying parameters can be updated, or their values fixed. For example:

var1 = VaryingParameter("x0", -50.0, 5.0)
var2 = VaryingParameter("x1", -5.0, 15.0)
obj = Objective("f", minimize=False)

generator = AxSingleFidelityGenerator(
    varying_parameters=[var1, var2],
    objectives=[obj],
    fit_out_of_design=True,
)
evaluator = FunctionEvaluator(function=eval_func_sf)
exploration = Exploration(
    generator=generator,
    evaluator=evaluator,
    sim_workers=2,
)

# Run 5 evals with default parameters
exploration.run(n_evals=5)

# Change range of x0 and run 10 evals
var1.update_range(-20., 0.)
generator.update_parameter(var1)
exploration.run(n_evals=10)

# Fix value of x0 and run 5 evals
var1.fix_value(-9)
generator.update_parameter(var1)
exploration.run(n_evals=5)

# Free value of x0 and run 5 evals
var1.free_value()
generator.update_parameter(var1)
exploration.run(n_evals=5)

Currently, only the generators based on the Ax service API support updating the parameters. Support for other generators will be added in future PRs.

In order to support VaryingParameters with a fixed value, a set of fixed_features needs to be passed to Ax. This, however, is not currently possible with the Service API (unless facebook/Ax#2015 or something similar is merged). Therefore, this PR defines a CustomAxClient derived class that modifies get_next_trial to support fixed_features.

Other changes

  • The CustomAxClient requires Ax>=0.3.4 (and therefore python>=3.9), which means that this PR also drops support for older Ax versions and Python 3.8.
  • The logic of how we create the AxClients has been simplified. Now the subclasses of the AxServiceGenerator only need to define the list of GenerationSteps, instead of creating an AxClient. This avoids code duplication.

@AngelFP AngelFP changed the title [WIP] Support changing the range and fixing the value of VaryingParameters Support changing the range and fixing the value of VaryingParameters Nov 30, 2023
Copy link
Collaborator

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@MaxThevenet MaxThevenet merged commit 914139c into main Dec 1, 2023
@MaxThevenet MaxThevenet deleted the feature/fixed_parameters branch December 1, 2023 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants