Skip to content

Conversation

dourouc05
Copy link
Contributor

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.

@blegat
Copy link
Member

blegat commented Aug 6, 2020

I would rather do something more general like passing a filter function. This way, it could also be used for instance to relax integrality. Another example: in jump-dev/Pavito.jl#21, I ended up copying the model without integrality to the continuous solver and copying the model without quadratic and nonlinear constraints to the mip solvers.
So copying with a filter seems to be quite useful and I wouldn't specialize the feature for conflicts only.

@dourouc05
Copy link
Contributor Author

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.
@dourouc05
Copy link
Contributor Author

I now use nothing, it feels much faster than before. The performance penalty for people not filtering anything should be very low with respect to pre-PR state (several branches; short unions are supposed to be quite optimised).

For numbers, before this PR (using the benchmark included in the last test):

(9/10) benchmarking "copy_model"...
done (took 2.352988901 seconds)

And after:

(9/10) benchmarking "copy_model"...
done (took 2.270177901 seconds)

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)
Copy link
Member

@blegat blegat Aug 21, 2020

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.

Copy link
Contributor Author

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)
Copy link
Member

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 ?

@blegat blegat added this to the v0.9.15 milestone Aug 28, 2020
@dourouc05
Copy link
Contributor Author

It looks like BoundModel was indeed not so correct… Now, it should be!

Copy link
Member

@blegat blegat left a 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

@dourouc05
Copy link
Contributor Author

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 relax_integrality, but I don't think it would benefit from a rewrite to use this functionality. Do you have any idea where it might be useful in JuMP?

@blegat
Copy link
Member

blegat commented Aug 29, 2020

You can wait for MOI to be tagged, it will be quite soon.
Other places are META solvers where you usuallu communicate only one part of the model to tu e underlying solver

@blegat blegat merged commit fa88b46 into jump-dev:master Aug 29, 2020
dourouc05 added a commit to dourouc05/JuMP.jl that referenced this pull request Nov 5, 2020
dourouc05 added a commit to dourouc05/JuMP.jl that referenced this pull request Nov 9, 2020
dourouc05 added a commit to dourouc05/JuMP.jl that referenced this pull request Feb 21, 2021
dourouc05 added a commit to dourouc05/JuMP.jl that referenced this pull request Feb 21, 2021
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.
dourouc05 added a commit to dourouc05/JuMP.jl that referenced this pull request Feb 21, 2021
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.
dourouc05 added a commit to dourouc05/JuMP.jl that referenced this pull request Feb 21, 2021
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.
odow pushed a commit to dourouc05/JuMP.jl that referenced this pull request Feb 22, 2021
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.
odow pushed a commit to jump-dev/JuMP.jl that referenced this pull request Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants