Extend projection to nonlinear inequality constraints#3316
Conversation
|
Hi @MrzvskK! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Motivation
Related to #3280.
gen_candidates_scipyalready supportsnonlinear_inequality_constraintsviamake_scipy_nonlinear_inequality_constraints, butproject_to_feasible_space_via_slsqponly handled linear constraints. After optimization,_optimize_acqf_batchchecks feasibility (including nonlinear inequalities) but previously skipped projection whenever nonlinear constraints were present, so slightly infeasible candidates could remain infeasible or trigger errors.This PR extends projection to nonlinear inequality constraints using the same SciPy path as
gen_candidates_scipy, as suggested in the #3280 discussion.Changes:
botorch/optim/parameter_constraints.pynonlinear_inequality_constraintsargument toproject_to_feasible_space_via_slsqp.make_scipy_nonlinear_inequality_constraints(same helper asgen_candidates_scipy)._get_f_np_wrapper_for_projectionso projection can evaluate constraint values/Jacobians without importinggen.py(avoids circular imports).validate_feasibility: bool = Truetomake_scipy_nonlinear_inequality_constraints(default unchanged). Projection passesvalidate_feasibility=Falsebecause repair starts from infeasible points; IC validation behavior is unchanged.shapeXwith_validate_linear_constraints_shape_inputfor consistent(b, q, d)handling.botorch/optim/optimize.pynonlinear_inequality_constraints is not None.nonlinear_inequality_constraintsintoproject_to_feasible_space_via_slsqpfor infeasible batches.Tests
test_project_to_feasible_space_via_slsqp_nonlinear: unit disk + half-plane; slightly infeasible point projected to feasibility; linear + nonlinear combo.test_optimize_acqf_projection_applied_with_nonlinear_constraintsto expect projection is applied and linear constraints are repaired.Have you read the Contributing Guidelines on pull requests?
Yes. First BoTorch contribution — happy to adjust based on review.
Test Plan
pytest test/optim/test_parameter_constraints.py::TestProjectToFeasibleSpace::test_project_to_feasible_space_via_slsqp_nonlinear -vUnit disk + half-plane; slightly infeasible point projected to feasibility; linear + nonlinear combo.
pytest test/optim/test_parameter_constraints.py test/optim/test_optimize.py -vBroader regression (75 passed locally).
test_optimize_acqf_projection_applied_with_nonlinear_constraints: projection runs when nonlinear constraints are present; linear inequalities repaired.Compared pytest warnings with/without this diff on the above test files: 117 warnings, unchanged (no new warnings from these changes; existing RuntimeWarnings from retry/IC mocks, etc.).
Notes for reviewers
callable(x) >= 0, with the same(callable, is_intrapoint)tuple format asoptimize_acqf.½‖x - x₀‖²) with SLSQP, consistent with existing linear repair.Related PRs
N/A
/cc @esantorella @jduerholt FYI for the discussion in #3280