Skip to content

Handle empty constraints safely - #432

Open
h-g-s wants to merge 1 commit into
masterfrom
fix-issue-364-empty-constraints
Open

h-g-s wants to merge 1 commit into
masterfrom
fix-issue-364-empty-constraints

Conversation

@h-g-s

@h-g-s h-g-s commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Addresses #364. Reject expressions with no comparison and empty constraints when the model has no variables with a clear InvalidLinExpr error, rather than passing invalid input or returning a broken CBC constraint. Existing empty constraints remain supported when the model has variables. Avoid querying invalid CBC row-matrix data if the last variable is subsequently removed.

Regression tests cover the original reproduction, zero-variable empty constraints, and inspection and removal of an empty constraint after removing the last variable.

Local validation: 596 passed, 34 skipped (full suite with doctests and warnings as errors). Black and Flake8 passed on the changed package files. In paired local benchmarks, ordinary row insertion showed no clear slowdown; inserting 50,000 empty rows took about 7 ms longer in the median.

Reject constraint expressions without a comparison and empty constraints on models without variables. Avoid querying invalid CBC row matrix data after the last variable is removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant