Skip to content

[Question] BO's result with constraints of parameter's range and outcome #273

@rinc5

Description

@rinc5

Hello.
I've been trying out Ax for my task and I really like this great library.

I have three questions about my multi-objective optimization task.

Use case:
There are two metrics (Y1: maximize, Y2: outcome constraint). The metrics and parameters (X1- X5, X3+X4+X5==100) are loaded from CSV file (experimental data). This experiment takes a long time, so I want to know what value should I set to parameters for next experiment. In addition, I want to know the prediction value of Y1 and Y2 at these parameters.

My questions:

  1. "range" of X1 and X2 at ax.modelbridge.transforms.int_to_float warning message is incorrect.

The WARNING is occured at get_next_trial and the warning message is like this:

[WARNING 03-10 17:14:43] ax.modelbridge.transforms.int_to_float: Unable to round {...}to meet constraints of SearchSpace(parameters=[RangeParameter(name='X1', parameter_type=FLOAT, range=[0.0, 1.0]), RangeParameter(name='X2', parameter_type=FLOAT, range=[0.0, 1.0]), ..., parameter_constraints=[ParameterConstraint(1.0*X3 + 1.0*X4 + 1.0*X5 <= 100), ParameterConstraint(-1.0*X3 + -1.0*X4 + -1.0*X5 <= -100.0)])

I set 'bound': [-50.0, 10.0] for X1 and 'bound': [-0.5, 50.0] for X2, but different ranges are printed at the warning message.
Why is this difference occured? (I confirmed ax_client.experiment.parameters and they were correct ranges.) What should I do to avoid this?

  1. Should I remove data which violate the outcome constraint?

When I use data which violate the outcome constraint, the prediction value of Y2 at get_next_trial is out of range (Y2 > 10.0).
On the other hand, when I don't use these data, the prediction value of Y2 at the parameters is within range (0.0 <= Y2 <= 10.0).

  1. Is it correct with my code for predicting metric values at get_next_trial?

My code is like this:

df = pd.read_csv('data.csv')

parameters = [
    {
        'name': 'X1',
        'value_type': 'float',
        'type': 'range',
        'bounds': [-50.0, 10.0],
    },
    {
        'name': 'X2',
        'value_type': 'float',
        'type': 'range',
        'bounds': [-0.5, 50.0],
    },
    {
        'name': 'X3',
        'value_type': 'int',
        'type': 'range',
        'bounds': [0, 100],
    },
    {
        'name': 'X4',
        'value_type': 'int',
        'type': 'range',
        'bounds': [0, 100],
    },
    {
        'name': 'X5',
        'value_type': 'int',
        'type': 'range',
        'bounds': [0, 100],
    },
]

# initialize AxClient
ax_client = AxClient(...)

# set up experiment
ax_client.create_experiment(
    name='my_BO_task',
    parameters=parameters,
    objective_name='Y1',
    minimize=False,
    parameter_constraints=['X3 +X4 + X5 <= 100', 'X3 + X4 + X5 >= 100'],
    outcome_constraints=['Y2 >= 0.0', 'Y2 <= 10.0'],
)

# optimize
for _, row in df.iterrows():
    # convert row to dict (parameter_data, metric_data)

    _, trial_index = ax_client.attach_trial(parameter_data)
    ax_client.complete_trial(trial_index, metric_data)

next_candidates, _ = ax_client.get_next_trial() # WARNING is occured here

# predict metric values at next_candidates
m = get_GPEI(ax_client.experiment, ax_client.experiment.fetch_data())
f, cov = m.predict([ObservationFeatures(parameters=parameters)])

Any help is appreciated. And if you would like to know more information, please ask me.
Thank you so much for your help.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions