Skip to content

Support trivial constraints in SCIP interfaces - #4001

Open
william-xue wants to merge 1 commit into
Pyomo:mainfrom
william-xue:fix/scip-trivial-constraints
Open

Support trivial constraints in SCIP interfaces#4001
william-xue wants to merge 1 commit into
Pyomo:mainfrom
william-xue:fix/scip-trivial-constraints

Conversation

@william-xue

Copy link
Copy Markdown

Fixes #3976.

Summary/Motivation:

Constraint.Feasible and Constraint.Infeasible are represented by TrivialRelationalExpression. The SCIP expression visitor dispatches on exact types, so both the direct and persistent interfaces currently raise NotImplementedError while compiling these constraints.

Changes proposed in this PR:

  • Translate a trivial relation into a symbolic zero-degree PySCIPOpt expression, rather than letting Python reduce the constant inequality to a bool. This preserves Feasible as 0 <= 0 and Infeasible as 1 <= 0.
  • Add direct and persistent interface regressions using min x, 0 <= x <= 1: the feasible case has known optimum x = 0, while adding Constraint.Infeasible must produce provenInfeasible with no solution.

Validation:

  • .venv/bin/pytest -q --solver=scip_direct pyomo/contrib/solver/tests/solvers/test_scip_direct.py — 22 passed
  • .venv/bin/pytest -q --solver=scip_persistent pyomo/contrib/solver/tests/solvers/test_scip_persistent.py — 18 passed
  • .venv/bin/black --check pyomo/contrib/solver/solvers/scip/base.py pyomo/contrib/solver/tests/solvers/test_scip_direct.py pyomo/contrib/solver/tests/solvers/test_scip_persistent.py — unchanged

AI-Use Disclosure

  • AI tools were NOT used during the preparation of this PR

or

  • AI tools contributed to the development of this PR

    • AI tools generated documentation (including the PR description/comments, code comments, and/or Sphinx documentation)
    • AI tools generated tests (baselines, examples, and/or code)
    • AI tools generated code (apart from tests)

    Review process (select ONE):

    • Rewritten: All AI-generated content was rewritten by me before being committed.
    • Reviewed/verified: I retained AI-generated content and verified it before committing. Verification included (as applicable):
      • Ran the code and fixed issues
      • Added and ran tests
      • Checked correctness/logic of code and tests
      • Checked for alignment with the contribution guide
      • Considered security implications
    • As-is: AI-generated content was commited directly to the repository

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make contributions and grant the license. If my employer has rights to intellectual property that includes my contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

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.

SCIP direct / persistent not compatible with Constraint.Feasible

1 participant