Skip to content

Commit f8dcfea

Browse files
FBumannclaude
andauthored
feat: Add fix(), unfix(), and fixed to Variable and Variables (#625)
* feat: Add fix(), unfix(), and fixed to Variable and Variables Add methods to fix variables to values via equality constraints, with: - Automatic rounding (0 decimals for int/binary, configurable for continuous) - Clipping to variable bounds to prevent infeasibility - Optional integrality relaxation (relax=True) for MILP dual extraction - Relaxed state tracked in Model._relaxed_registry and restored by unfix() - Cleanup on variable removal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add example to notebook covering fixing and dual extraction * Add example to notebook covering fixing and dual extraction * fix: Add type annotations to test_fix.py for mypy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: Add release note for fix/unfix/fixed feature Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: Persist _relaxed_registry through netCDF IO Serialize the relaxed registry as a JSON string in netCDF attrs so that unfix() can restore integrality after a save/load roundtrip. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: Address PR review comments for fix/unfix feature - Use as_dataarray() instead of DataArray() for value conversion - Remove explanatory inline comments - Move FIX_CONSTRAINT_PREFIX to constants.py - Raise ValueError for out-of-bounds fix values instead of clipping - Add overwrite parameter to fix() (default True) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: Parametrize fix tests across scalar and array data types Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: Remove clipping from changelog for new feature --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 393da2f commit f8dcfea

File tree

7 files changed

+1285
-57
lines changed

7 files changed

+1285
-57
lines changed

doc/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Upcoming Version
2424
* Improve handling of CPLEX solver quality attributes to ensure metrics such are extracted correctly when available.
2525
* Fix Xpress IIS label mapping for masked constraints and add a regression test for matching infeasible coordinates.
2626
* Enable quadratic problems with SCIP on windows.
27+
* Add ``fix()``, ``unfix()``, and ``fixed`` to ``Variable`` and ``Variables`` for fixing variables to values via equality constraints. Supports automatic rounding and optional integrality relaxation (``relax=True``) for MILP dual extraction.
2728

2829

2930
Version 0.6.5

0 commit comments

Comments
 (0)