Skip to content
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

Adds buffering for variables deleted. #317

Merged
merged 3 commits into from
May 11, 2020

Conversation

henriquebecker91
Copy link
Contributor

Gurobi.Optimizer now have fields next_column and columns_deleted_since_last_update. The behavior now is to not force a update before deleting, but instead: update the list of variables in Julia side but not their column indexes, and save the column indexes of the ones deleted; when updating the model then update the column indexes in Julia side.

The code pass all tests. But maybe we need to devise new ones.

This fix #315 in my code (that unfortunately is not a MWE).

I will be out for about 2 hours now, @odow, after this I will check if you have suggested something to me to improve in this PR.

…s `next_column` and `columns_deleted_since_last_update`. The behavior now is to not force a update before deleting, but instead: update the list of variables in Julia side but not their column indexes, and save the column indexes of the ones deleted; when updating the model then update the column indexes in Julia side.
Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely need some tests for this one.

My example from this issue should be fine.

src/MOI_wrapper.jl Outdated Show resolved Hide resolved
src/MOI_wrapper.jl Outdated Show resolved Hide resolved
@henriquebecker91
Copy link
Contributor Author

henriquebecker91 commented May 4, 2020 via email

@henriquebecker91
Copy link
Contributor Author

@odow The test was a little harder to create than I expected. Many common attributes are cached on the wrapper (name, bounds, type, ...) and other are discarded (Start, VBasis, ...) if any variables are deleted. This explains how this bug did not surface immediately, and how the code seems to work in some situations that it shouldn't work, given the nature of the bug.

The testset has 4 fails in current master branch and none with the changes introduced by this branch. I think it is a solid test.

@odow
Copy link
Member

odow commented May 7, 2020

Which are the tests that fail?

@henriquebecker91
Copy link
Contributor Author

Buffered deletion test: Test Failed at /home/henrique/AreaDeTrabalho/Gurobi.jl/test/MOI/MOI_wrapper.jl:519
  Expression: vars_obj[2] == MOI.get(model, obj_attr, vars[2])
   Evaluated: 42.0 == -77.0
Buffered deletion test: Test Failed at /home/henrique/AreaDeTrabalho/Gurobi.jl/test/MOI/MOI_wrapper.jl:521
  Expression: fourth_var_obj == MOI.get(model, obj_attr, fourth_var)
   Evaluated: -77.0 == 0.0
Buffered deletion test: Test Failed at /home/henrique/AreaDeTrabalho/Gurobi.jl/test/MOI/MOI_wrapper.jl:526
  Expression: vars_obj[2] == MOI.get(model, obj_attr, vars[2])
   Evaluated: 42.0 == -77.0
Buffered deletion test: Test Failed at /home/henrique/AreaDeTrabalho/Gurobi.jl/test/MOI/MOI_wrapper.jl:528
  Expression: fourth_var_obj == MOI.get(model, obj_attr, fourth_var)
   Evaluated: -77.0 == 0.0

Basically the tests that check the value of the property set. The ones before the implicit update_model! caused by MOI.optimize! and the ones after it. In the patched version such errors do not exist (all tests pass). So I am confident the code, while not bug-free, solves the bug it intends to solve and do not break any other test.

@odow
Copy link
Member

odow commented May 7, 2020

Oops. I mis-read your comment. I understood it as 4 different tests were failing, but these ones were passing.

@henriquebecker91
Copy link
Contributor Author

Oh, no. With this PR all older tests pass and the new ones too. In the master branch, the 4 @test I cited of the new @testset I created fail (because the bug the PR solves).

@henriquebecker91
Copy link
Contributor Author

@odow, do you want me to improve this PR in some way? While this is not approved, Gurobi.jl will cause subtle bugs to users when deletion is followed by attribute changes. It is also good for me if I can refer to the Gurobi version I used in my paper, instead of saying I used a patched local copy, XD.

@odow odow merged commit 2cf703a into jump-dev:master May 11, 2020
@odow
Copy link
Member

odow commented May 11, 2020

Sorry, merging since this is a strict improvement in correcting an existing bug. Thanks!

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.

More fun with lazy update semantics
2 participants