-
Notifications
You must be signed in to change notification settings - Fork 94
Remove SingleVariable #1474
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
Remove SingleVariable #1474
Conversation
1ae5dd9
to
306f11b
Compare
What do we think of this? I took a look, and migrating all of the calls is a lot of work |
A lot of work in MOI or in the whole ecosystem or both ? |
In MOI and the ecosystem. There's thousands of changes. I tried scripting the changes create_regex(regex) = regex => s -> match(regex, s)[1]
regexes = [
create_regex(r"MOI\.SingleVariable\(([a-zA-Z\.\[\]0-9]+?)\)"),
create_regex(r"MOI\.SingleVariable\.\(([a-zA-Z\.\[\]0-9]+?)\)"),
create_regex(r"SingleVariable\(([a-zA-Z\.\[\]0-9]+?)\)"),
create_regex(r"SingleVariable\.\(([a-zA-Z\.\[\]0-9]+?)\)"),
"::NOI.SingleVariable" => "::MOI.VariableIndex",
"::SingleVariable" => "::VariableIndex",
"{MOI.SingleVariable" => "{MOI.VariableIndex",
"{SingleVariable" => "{VariableIndex",
"MOI.SingleVariable," => "MOI.VariableIndex,",
]
for (root, dirs, files) in walkdir(".")
for file in files
if !(endswith(file, ".jl") || endswith(file, ".md"))
continue
end
filename = joinpath(root, file)
file = read(filename, String)
if !occursin("SingleVariable", file)
continue
end
for (regex, f) in regexes
file = replace(file, regex => f)
end
write(filename, file)
end
end which takes the number of changes required from thousands to hundreds... |
Yes, I agree it's a huge fixed cost of time to pay now. But it will only get worse with time and I think it might be saving time over time that will overweight this cost. |
I'm still not convinced that this is necessary. Can you point to code that would be significantly simplified if we removed SingleVariable? And why the benefits of this change out-weights the cost? |
I would not say that one code will be significantly simplified but rather than many codes will be simplified. Here are example where many small complications are due to SingleVariable is: Here is an example where I tried to have a code working both for JuMP and MOI model: |
Okay. It's reasonable to be annoyed at returning both
Are you worried about the extra allocation of the
This is a pretty extreme edge-case (making it work for JuMP and MOI). And you seem to have sorted it out by a couple of helper functions.
I'm not saying that removing Rewriting thousands of lines of code to save a few helper functions in a couple of packages doesn't seem like it's worth the effort. We also have to go through all of the documentation, the paper would be out-dated, all talks we gave would be out-dated. It's not the same as changing the order of some fields (or renaming them). Can we leave as-is for MOI 1.0 and think about it for MOI 2.0? |
For the record, here is what I wrote on Gitter:
Would there be any performance benefits of getting rid of SingleVariable? It would account for one fewer layer of abstraction, so it shouldn't hurt, but I guess Julia is already optimising the code quite a lot. |
In general, there are no performance benefits to removing it. In some cases you might need to allocate a new array if you need to pass an array of SingleVariable instead of VariableIndex, but that will never be more than a tiny part of the total cost so isn't really a consideration. The trade-off here is: is it worth changing thousands of lines of code across every package in the ecosystem for the small benefit? |
I am for this change as it seems to make things conceptually simpler and makes future efforts in the ecosystem less technical. Edit: I have one barely half working NLP solver where the MOI interface is still private. So weigh my opinions with respect to my contributions |
I agree it's a lot. But the usability change is quite substantial.
I'd say it's now or never. Doing it in MOI 2.0 is even worse.
I don't think it is noticeable, you can also write your code in a way such that it does not affect you. But you might need to complicate things a bit. |
I agree but I suspect that people don't do it algebraically because if the usability issue. Some may even try, get errors and don't realize that they could just use I can take care of updating packages in the jump-dev Github org.
For the record, @joehuchette was also in favor of this during the JuMP-dev call of July. |
I've found this a relatively minor, but persistent, annoyance when trying to build constraints algebraically. |
After following the discussion for a while, I'm also in favour of this, it's worth delaying 0.10 and have things a bit simpler |
We can discuss during this week's call. But this is the remaining blocker for MOI 0.10. |
should we close this now that it's overtaken by #1559 ? |
Just a proof of concept at the moment
Closes #1472