Support equality constraints in service layer string parsing (#5174)#5174
Closed
sdaulton wants to merge 2 commits intofacebook:mainfrom
Closed
Support equality constraints in service layer string parsing (#5174)#5174sdaulton wants to merge 2 commits intofacebook:mainfrom
sdaulton wants to merge 2 commits intofacebook:mainfrom
Conversation
|
@sdaulton has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100256487. |
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
d01e1f8 to
c6e6eb9
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Pull Request resolved: facebook#5174 Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
c6e6eb9 to
40ac657
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
40ac657 to
7e1628d
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Pull Request resolved: facebook#5174 Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
7e1628d to
4e8fe60
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5174 +/- ##
========================================
Coverage 96.41% 96.41%
========================================
Files 618 619 +1
Lines 68882 69008 +126
========================================
+ Hits 66410 66532 +122
- Misses 2472 2476 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 17, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
Summary: Add support for linear equality constraints (`w^T x == b`) alongside existing inequality constraints (`w^T x <= b`) in Ax's `ParameterConstraint` class. This is the first diff in a stack that threads equality constraints all the way down to BoTorch's `optimize_acqf`. Changes: - Add `extract_coefficient_dict_from_equality` to `ax/utils/common/sympy.py` for parsing `"expr == bound"` strings (SymPy can't parse `==` directly since Python evaluates it as a boolean). - Extend `ParameterConstraint.__init__` to accept `equality=` kwarg alongside existing `inequality=` kwarg. Exactly one must be provided. - Add `is_equality` property. - Update `check()` to use `|w^T x - b| <= tol` for equality constraints. - Update `__repr__`, `clone()`, `clone_with_transformed_parameters()`. - Add comprehensive tests for equality constraints. Differential Revision: D100256486
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
4e8fe60 to
95f65ba
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
95f65ba to
a934285
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
a934285 to
6e6ff78
Compare
…k#5174) Summary: Pull Request resolved: facebook#5174 Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
6e6ff78 to
e715983
Compare
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
sdaulton
added a commit
to sdaulton/Ax-1
that referenced
this pull request
Apr 20, 2026
…k#5174) Summary: Add support for parsing equality constraint strings (e.g. `"x1 + x2 == 3"`) in `constraint_from_str`. This extends the existing `<=`/`>=` parsing to also accept `==` as a comparison operator. - Add `_process_equality_constraint` function (analogous to `_process_linear_constraint`) that constructs `ParameterConstraint(equality=...)`. - Detect `==` in `constraint_from_str` and route to the new function. - Reject equality order constraints (`"x1 == x2"`) with a clear error message. - Update `INVALID_CONSTRAINT_ERROR_MSG` to document `==` support. Reviewed By: bletham Differential Revision: D100256487
|
This pull request has been merged in 3975e45. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add support for parsing equality constraint strings (e.g.
"x1 + x2 == 3")in
constraint_from_str. This extends the existing<=/>=parsing to alsoaccept
==as a comparison operator._process_equality_constraintfunction (analogous to_process_linear_constraint)that constructs
ParameterConstraint(equality=...).==inconstraint_from_strand route to the new function."x1 == x2") with a clear error message.INVALID_CONSTRAINT_ERROR_MSGto document==support.Reviewed By: bletham
Differential Revision: D100256487