feat: Add relax() and unrelax() to Variable and Variables#634
Open
feat: Add relax() and unrelax() to Variable and Variables#634
Conversation
Add methods to relax integrality of binary/integer variables to continuous, enabling LP relaxation of MILP models. Supports partial relaxation of individual variables or filtered views (e.g. m.variables.integers.relax()). Semi-continuous variables raise NotImplementedError since their relaxation requires bound changes. Refactors fix(relax=True) to delegate to relax(), removing the relax parameter from fix() to avoid redundancy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
@FabianHofmann sorry for the noisy notebook! The rest should be easy to review. |
Collaborator
Author
|
I'll need to adjust this before merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up on #625
Summary
relax()/unrelax()/relaxedtoVariableandVariables, enabling LP relaxation of MILP modelsm.variables.integers.relax(),m.variables.binaries.relax(), or individualm.variables["x"].relax()NotImplementedError(their LP relaxation requires bound changes, not just a flag flip)relaxparameter fromfix()— the canonical workflow is nowfix()thenrelax()as separate, composable operationsunfix()delegates tounrelax()so the full fix+relax workflow is undone in one callUsage
This is sort of a refactor of #625 which works fine as not released yet!
Test plan
Variable.relax()/unrelax()on binary, integer, continuous, and semi-continuousVariables.relax()/unrelax()on full and filtered containersm.type)test_fix_relax.pypass🤖 Generated with Claude Code