Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Map Constraint.Feasible/Infeasible to concrete constraints #3546

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

jsiirola
Copy link
Member

Fixes #2918 .

Summary/Motivation:

We have historically mapped Constraint.Feasible to Constraint.Skip and had Constraint.Infeasible immediately raise a ValueError. This causes some undesirable behavior:

  • You cannot "evaluate" a Constraint that was set by Constraint.Feasible because the ConstraintData was not created (see this question on SO)
  • You cannot (easily) have a trivially infeasible constraint anywhere in the model, even if the infeasible constraint would not cause the model to be infeasible (because it was on a disjunct; see Allow Constraint.Infeasible to be used to disable a Disjunct #2918)

This updates Constraint and LogicalConstraint to map Constraint.Feasible to a trivial inequality, and Constraint.Infeasible to a trivial infeasible Inequality.

Changes proposed in this PR:

  • Map Constraint.Feasible and Constraint.Infeasible to actual trivial constraints
  • Rework part of Constraint to remove a repeated exception
  • Port LogicalConstraint to the new structure (initillizers, disable_method, Abstract classes, simplified method overrides) from Constraint
  • Update logical_to_linear and logical_to_disjunctive to support constant expressions
  • Update tests

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 the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@jsiirola jsiirola requested a review from emma58 March 28, 2025 06:39
@jsiirola jsiirola changed the title May Constraint.Feasible/Infeasible to concrete constraints Map Constraint.Feasible/Infeasible to concrete constraints Mar 28, 2025
@mrmundt
Copy link
Contributor

mrmundt commented Apr 8, 2025

A note from the dev call on 4/8 - we don't think we need to especially rush to get this in by the patch release next week, but it would be nice if we could.

@mrmundt mrmundt requested a review from michaelbynum April 8, 2025 18:42
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Constraint.Infeasible to be used to disable a Disjunct
2 participants