Commit f8dcfea
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- doc
- examples
- linopy
- test
7 files changed
+1285
-57
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
0 commit comments