-
Notifications
You must be signed in to change notification settings - Fork 80
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
Conversation
…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.
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.
We definitely need some tests for this one.
My example from this issue should be fine.
`deepcopy` is not needed per se, is just an habit of mine to not assume
fields will not be changed to mutable types after. It should be compiled to
a no-operation, but I can remove it if you think it is better.
I will make your example a test then. Just not now.
Em seg., 4 de mai. de 2020 às 16:13, Oscar Dowson <notifications@github.com>
escreveu:
… ***@***.**** commented on this pull request.
We definitely need some tests for this one.
My example from this issue should be fine.
------------------------------
In src/MOI_wrapper.jl
<#317 (comment)>:
> @@ -419,6 +453,12 @@ function _info(model::Optimizer, key::MOI.VariableIndex)
throw(MOI.InvalidIndex(key))
end
+function _get_next_column(model::Optimizer)
+ old_value = deepcopy(model.next_column)
Why is deepcopy needed?
------------------------------
In src/MOI_wrapper.jl
<#317 (comment)>:
> @@ -419,6 +453,12 @@ function _info(model::Optimizer, key::MOI.VariableIndex)
throw(MOI.InvalidIndex(key))
end
+function _get_next_column(model::Optimizer)
+ old_value = deepcopy(model.next_column)
+ model.next_column += 1
+ return old_value
function _get_next_column(model::Optimizer)
model.next_column += 1
return model.next_column - 1end
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#317 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADLVVGYZSGBHF2DOCCNAVD3RP4HWRANCNFSM4MZAGVKA>
.
|
@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. |
Which are the tests that fail? |
Basically the tests that check the value of the property set. The ones before the implicit |
Oops. I mis-read your comment. I understood it as 4 different tests were failing, but these ones were passing. |
Oh, no. With this PR all older tests pass and the new ones too. In the master branch, the 4 |
@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. |
Sorry, merging since this is a strict improvement in correcting an existing bug. Thanks! |
Gurobi.Optimizer now have fields
next_column
andcolumns_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.