You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MOI.VariableIndex is not an MOI.AbstractScalarFunction so it does not implement any arithmetic operation. If you use MOI.SingleVariable instead then it should work.
My goal when opening this issue was really to have an excellent solution easily available at MOI level for new users, so that they have a nice API available (and with good performance, but that can always be improved on later on). Also, it lowers the probability of misuse of MOI (like a competing modelling system that compares to JuMP/MOI and uses a poor implementation).
Activity
odow commentedon Jun 1, 2021
Is there any reason not to write out the new function explicitly? You could always define a
dotlocally.I'm hesitant about exposing more of MOI because it's too easy to accidentally introduce slow routes to code. For example, implementing what you suggest would be very slow because of the
dotfallback: https://github.com/JuliaLang/julia/blob/f9720dc2ebd6cd9e3086365f281e62506444ef37/stdlib/LinearAlgebra/src/generic.jl#L896blegat commentedon Jun 2, 2021
MOI.VariableIndexis not anMOI.AbstractScalarFunctionso it does not implement any arithmetic operation. If you useMOI.SingleVariableinstead then it should work.odow commentedon Jun 2, 2021
@dourouc05 there are a few different options:
I would go with implementing the
barmethod locally in your package for now.blegat commentedon Jun 2, 2021
Yes,
dotuses the defaultLinearAlgebraimplementation which does not exploit mutability, if you want it to be fast, useMA.operate(dot, x, y)dourouc05 commentedon Jun 3, 2021
My goal when opening this issue was really to have an excellent solution easily available at MOI level for new users, so that they have a nice API available (and with good performance, but that can always be improved on later on). Also, it lowers the probability of misuse of MOI (like a competing modelling system that compares to JuMP/MOI and uses a poor implementation).
Regarding the fact that
VariableIndexis not a function, there are already two functions that allow the user to build affine expressions directly off indices: https://github.com/jump-dev/MathOptInterface.jl/blob/master/src/Utilities/functions.jl#L2496-L2502, https://github.com/jump-dev/MathOptInterface.jl/blob/master/src/Utilities/functions.jl#L2597-L2606 (throughfill_variable). I thought it could be useful to build upon them, to have a more pleasant (aka shorter) syntax on the user side.For now, I'll go with @odow's
barsuggestion and keep it internal to my package.Replace dot implementations to improve performance.
odow commentedon Jun 16, 2021
Closing because we won't be adding this for now.
blegat commentedon Jun 16, 2021
@dourouc05 I wasn't aware of https://github.com/jump-dev/MathOptInterface.jl/blob/master/src/Utilities/functions.jl#L2496-L2502,
MOI.VariableIndexshould be replaced byMOI.SingleVariablethere. I opened an issue #1388You have a convenient syntax, the same one than with JuMP, but you need to use
MOI.SingleVariable, notMOI.VariableIndex