Skip to content

[Bug]: get_next_trials violates parameter constraint #3862

@kurt-essential

Description

@kurt-essential

What happened?

I set a constraint that four parameters must sum to <= 1 and the first trial generated sets all parameters to 0.5, violating this constraint. (on ax-platform v1.0.0)

Please provide a minimal, reproducible example of the unexpected behavior.

Code:

from ax.api.client import Client
from ax.api.configs import RangeParameterConfig

parameter_names = [f'x_{i}' for i in range(4)]
parameters = [
    RangeParameterConfig(
            name=x,  
            bounds=(0.0, 1.0),
            parameter_type="float",
        ) for x in parameter_names]

sum_constraint = " + ".join(parameter_names) + " <= 1.0"
client = Client()
client.configure_experiment(
    parameters=parameters,
    parameter_constraints=[sum_constraint],
    )
client.configure_optimization(objective="objective")
print(sum_constraint)
print(client._experiment.search_space.parameter_constraints)
trials = client.get_next_trials(max_trials=3)
for trial_index, trial_parameters in trials.items():
    print(trial_index, trial_parameters)
    print(client._experiment.search_space.parameter_constraints[0].check(trial_parameters))

Output:

x_0 + x_1 + x_2 + x_3 <= 1.0
[ParameterConstraint(1.0*x_0 + 1.0*x_1 + 1.0*x_2 + 1.0*x_3 <= 1.0)]
0 {'x_0': 0.5, 'x_1': 0.5, 'x_2': 0.5, 'x_3': 0.5}
False
1 {'x_0': 0.07523129135370255, 'x_1': 0.07053725980222225, 'x_2': 0.32778964564204216, 'x_3': 0.3629995724186301}
True
2 {'x_0': 0.12477120012044907, 'x_1': 0.13883846905082464, 'x_2': 0.11183641757816076, 'x_3': 0.012117702513933182}
True

Please paste any relevant traceback/logs produced by the example provided.

Ax Version

1.0.0

Python Version

3.10.12

Operating System

NAME="Ubuntu" VERSION="22.04.2 LTS (Jammy Jellyfish)"

(Optional) Describe any potential fixes you've considered to the issue outlined above.

No response

Pull Request

Yes

Code of Conduct

  • I agree to follow Ax's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions