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
Create a version of method delete that deletes a vector of variables. #2135
Create a version of method delete that deletes a vector of variables. #2135
Conversation
… This calls the version of MOI.delete that also works over a vector of variables, and is specialized by solvers for greater performance than repeteadely calling the single variable version.
Can you add a test to test/variables.jl please? Can just be the same one as the one you added to MOI (but with JuMP syntax). |
Will do it. |
Codecov Report
@@ Coverage Diff @@
## master #2135 +/- ##
==========================================
+ Coverage 91.4% 91.42% +0.01%
==========================================
Files 42 42
Lines 4097 4105 +8
==========================================
+ Hits 3745 3753 +8
Misses 352 352
Continue to review full report at Codecov.
|
…. Implemented the batch deletion in JuMPExtension to pass the test. Increased the coverage of the test to include the cases a Exception is thrown (bad paths).
Added the tests and changed JuMPExtensions to implement the batch delete and pass the tests too. The tests are similar to the ones for a single variable in JuMP and to the ones over multiple variables in MOI. I think it is now ready for review. |
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.
Awesome!
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.
Users will wonder why we have JuMP.delete
for vectors of variables but not vectors of constraints (MOI.delete
supports vectors of constraints). We could add this now or leave a TODO in the appropriate spot in the code.
I will implement the batch constraint deletion in JuMP too. However, I think it would be good to keep in mind that:
|
…ints. JuMPExtension implementation and the tests for both JuMP and JuMPExtensions were also added.
I implemented the items 4.1, 4.2, and 4.3 from my last comment. To make it work, I defined the method signature as: |
…ack as @odow noted. Ran the tests, code is working.
An easier way to reason about this is that So |
Thanks for the explanation, @odow. Taking this into account, then there is no change to be done in the signature of the methods. |
This calls the version of MOI.delete that also works over a vector of variables, and is specialized by solvers for greater performance than repeatedly calling the single variable version.
The code was suggested by @odow in a discussion with him and @mlubin.
This is related to:
jump-dev/MathOptInterface.jl#989
jump-dev/Gurobi.jl#282
jump-dev/CPLEX.jl#273
The CPLEX and Gurobi PR's are already closed, the MathOptInterface is just waiting more reviewers (I think). Anyway, MathOptInterface already has a "delete a vector of variables" fallback method (https://github.com/JuliaOpt/MathOptInterface.jl/blob/c4beceb4e9444c752f7e655f7a50a38a70181b06/src/indextypes.jl#L124-L128). So this addition to JuMP would already be working if it was approved immediately. I suppose tests may be necessary, but it is MOI that does the heavy lifting and this method is basically the same as the single variable version except by the type of the parameters and the version of the MOI method it calls.
I imported the JuMP package changed by my branch in the REPL and called the method to test against typos.