Skip to content

Fix constraint mutations after insertion into a problem - #948

Closed
pol3et wants to merge 1 commit into
coin-or:masterfrom
pol3et:fix/fix-933-bound-constraints
Closed

pol3et wants to merge 1 commit into
coin-or:masterfrom
pol3et:fix/fix-933-bound-constraints

Conversation

@pol3et

@pol3et pol3et commented Sep 29, 2026 •

Copy link
Copy Markdown

Fixes #933.

After a constraint is inserted, editing its original expression currently leaves the stored Rust row unchanged. For example, changing the coefficient in x >= 2 to 2 still exports x >= 2 and solves to x=2. With this change, it exports 2 x >= 2 and solves to x=1.

Keep inserted row handles on the expression and read/write through the model-owned rows. Coefficient, RHS, sense and in-place edits propagate across repeated insertions; insertion names stay row-local. Copies and ordinary arithmetic remain independent. Replacement validates the expression before writing and clears stale dual/slack values after success.

Three regression tests cover binding, repeated insertion, copies, serialization, side-effect-free formatting/arithmetic and rejected replacement preserving the complete previous row.

Validation against current master 1e6e325c164bc722a55c58ee9b665fccc5698a95 (Python 3.12, Rust 1.98.1):

  • Independently built clean master and patched extensions: the same exported-LP/CBC regression fails on master (x=2 after mutation) and passes with the patch (x=1).
  • Model tests: 91 passed.
  • Before cleanup, full discovery with all extras: patched 1,033 tests, 456 passed, 549 skipped, 28 errors; clean master 1,031 tests, 454 passed, 549 skipped, the exact same 28 MOSEK test errors. MOSEK has no license in this environment; full discovery is not green.
  • After cleanup, full discovery using the CI extras (--all-extras --no-extra mosek): 1,034 tests, 456 passed, 578 skipped, no failures or errors. The original clean-master failure / patched success was rerun.
  • uv run ty check pulp, uv run ruff check pulp, uv run ruff format pulp --check, and uv run cargo check --manifest-path pulp/rust/Cargo.toml pass. Extension rebuilt with maturin; focused mutation checks pass.

This contribution was developed with AI assistance and checked with the regression and baseline comparisons above.

Replaces #947 after renaming the source branch. The patch commit is unchanged.

@pol3et
pol3et force-pushed the fix/fix-933-bound-constraints branch from bc3485e to 80bec49 Compare September 29, 2026 21:22
@pchtsp

pchtsp commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

this seems to be overly complicated. It's better if we just raise an error when someone is trying to edit a constraint. It should not be supported I think

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.

Cannot modify constraints after adding to problem

2 participants