-
Notifications
You must be signed in to change notification settings - Fork 94
When copying a model, propose to only keep conflict constraints. #1135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I would rather do something more general like passing a |
I've just made this modification, so that the code is now much more flexible. However, it feels much slower than previously… |
Add a bit more doc.
I now use For numbers, before this PR (using the benchmark included in the last test):
And after:
I guess we might say there is no significant performance impact on the most common path. |
|
||
# Perform the copy. | ||
dst = OrderConstrainedVariablesModel() | ||
index_map = MOI.copy_to(dst, src, filter_constraints=f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test where the filter filters out all constraints of a given type and the output model does not support the type of constraints that is filtered out ? If they are all filtered out, it shouldn't throw UnsupportedConstraint
but it'd be good to check with a test. This is needed in the use case of MIP relaxation where a MIP is copied to an LP that does not support integer variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like the last commit?
2fa662c
|
||
# Perform the copy. This should not throw an error. | ||
dst = BoundModel() | ||
MOI.copy_to(dst, src, filter_constraints=f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a @test_throws ... MOI.copy_to(dst, src)
to make sure that BoundModel
was setup correctly ?
It looks like BoundModel was indeed not so correct… Now, it should be! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I believe that this has many use cases
Shall I wait until this is merged before starting a PR to expose this functionality in JuMP, but specialised for conflicts? Otherwise, continuous integration can only fail, even though people would still be able to test on their own machines. I had a look at |
You can wait for MOI to be tagged, it will be quite soon. |
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 Don't create a testset for each potential test file. This cleans up the output when running the tests, as there is no output for files that are excluded. Previously, the output was like: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 37.4 seconds. Test Summary: | JuMPExtension.jl | No tests callbacks.jl took 15.9 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 With this patch: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 22.0 seconds. callbacks.jl took 16.8 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 Allow filtering constraints when copying a JuMP model. This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 Add test for copying models with filter. Deal with arrays of constraints. Make tests pass. Typo Add dedicated tests with all container types. Add a convenience function `copy_conflict`. @mlubin feedback. Add a compatibility layer between JuMP.ConstraintRef and MOI.ConstraintIndex. This fixes a pretty serious bug… Doc fixes. More consistency in tests. Add link to `copy_conflict` from `solutions.md` Typo @blegat Test copy_conflict based on MockOptimizer WIP. WIP 2. Move condition in functions. Improve style code, as proposed by @odow. Add to doc. Formatting changes were lost by rebasing. Ditto. Other rebase problem.
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 Don't create a testset for each potential test file. This cleans up the output when running the tests, as there is no output for files that are excluded. Previously, the output was like: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 37.4 seconds. Test Summary: | JuMPExtension.jl | No tests callbacks.jl took 15.9 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 With this patch: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 22.0 seconds. callbacks.jl took 16.8 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 Allow filtering constraints when copying a JuMP model. This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 Add test for copying models with filter. Deal with arrays of constraints. Make tests pass. Typo Add dedicated tests with all container types. Add a convenience function `copy_conflict`. @mlubin feedback. Add a compatibility layer between JuMP.ConstraintRef and MOI.ConstraintIndex. This fixes a pretty serious bug… Doc fixes. More consistency in tests. Add link to `copy_conflict` from `solutions.md` Typo @blegat Test copy_conflict based on MockOptimizer WIP. WIP 2. Move condition in functions. Improve style code, as proposed by @odow. Add to doc. Formatting changes were lost by rebasing. Ditto. Other rebase problem.
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 ---------------------------------------------------------- Don't create a testset for each potential test file. This cleans up the output when running the tests, as there is no output for files that are excluded. Previously, the output was like: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 37.4 seconds. Test Summary: | JuMPExtension.jl | No tests callbacks.jl took 15.9 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 With this patch: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 22.0 seconds. callbacks.jl took 16.8 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 Allow filtering constraints when copying a JuMP model. This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 Add test for copying models with filter. Deal with arrays of constraints. Make tests pass. Typo Add dedicated tests with all container types. Add a convenience function `copy_conflict`. @mlubin feedback. Add a compatibility layer between JuMP.ConstraintRef and MOI.ConstraintIndex. This fixes a pretty serious bug… Doc fixes. More consistency in tests. Add link to `copy_conflict` from `solutions.md` Typo @blegat Test copy_conflict based on MockOptimizer WIP. WIP 2. Move condition in functions. Improve style code, as proposed by @odow. Add to doc. Formatting changes were lost by rebasing. Ditto. Other rebase problem.
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 ---------------------------------------------------------- Don't create a testset for each potential test file. This cleans up the output when running the tests, as there is no output for files that are excluded. Previously, the output was like: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 37.4 seconds. Test Summary: | JuMPExtension.jl | No tests callbacks.jl took 15.9 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 With this patch: Test Summary: | Pass Total Containers | 241 241 Containers.jl took 22.0 seconds. callbacks.jl took 16.8 seconds. Test Summary: | Pass Total callbacks.jl | 22 22 Allow filtering constraints when copying a JuMP model. This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135 Add test for copying models with filter. Deal with arrays of constraints. Make tests pass. Typo Add dedicated tests with all container types. Add a convenience function `copy_conflict`. @mlubin feedback. Add a compatibility layer between JuMP.ConstraintRef and MOI.ConstraintIndex. This fixes a pretty serious bug… Doc fixes. More consistency in tests. Add link to `copy_conflict` from `solutions.md` Typo @blegat Test copy_conflict based on MockOptimizer WIP. WIP 2. Move condition in functions. Improve style code, as proposed by @odow. Add to doc. Formatting changes were lost by rebasing. Ditto. Other rebase problem.
This replicates the functionality of MOI: jump-dev/MathOptInterface.jl#1135
In line with #1035, a first step to allow a common interface for conflicts (exporting just these constraints). Copying the relevant constraints is a more flexible way to get to that point.