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

MOI.Utilities violates the MethodError principle #1277

Closed
odow opened this issue Mar 9, 2021 · 0 comments · Fixed by #1284
Closed

MOI.Utilities violates the MethodError principle #1277

odow opened this issue Mar 9, 2021 · 0 comments · Fixed by #1284
Assignees
Labels
Submodule: Utilities About the Utilities submodule Type: Bug

Comments

@odow
Copy link
Member

odow commented Mar 9, 2021

function MOI.set(
model::AbstractModel,
::MOI.ConstraintFunction,
ci::CI,
change::MOI.AbstractFunction,
)
return _modify(model, ci, getconstrloc(model, ci), change)
end
function MOI.set(
model::AbstractModel,
::MOI.ConstraintSet,
ci::CI{MOI.SingleVariable},
change::MOI.AbstractSet,
)
MOI.throw_if_not_valid(model, ci)
flag = single_variable_flag(typeof(change))
if !iszero(flag & LOWER_BOUND_MASK)
model.lower_bound[ci.value] = extract_lower_bound(change)
end
if !iszero(flag & UPPER_BOUND_MASK)
model.upper_bound[ci.value] = extract_upper_bound(change)
end
end
function MOI.set(
model::AbstractModel,
::MOI.ConstraintSet,
ci::CI,
change::MOI.AbstractSet,
)
return _modify(model, ci, getconstrloc(model, ci), change)
end

julia> c
MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}(5)

julia> MOI.set(model, MOI.ConstraintFunction(), c, MOI.SingleVariable(x))
ERROR: MethodError: no method matching _modifyconstr(::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}, ::MathOptInterface.ScalarAffineFunction{Float64}, ::MathOptInterface.EqualTo{Float64}, ::MathOptInterface.SingleVariable)
Closest candidates are:
  _modifyconstr(::MathOptInterface.ConstraintIndex{F,S}, ::F, ::S, ::MathOptInterface.AbstractFunctionModification) where {F, S} at /Users/oscar/.julia/dev/MathOptInterface/src/Utilities/model.jl:68
  _modifyconstr(::MathOptInterface.ConstraintIndex{F,S}, ::F, ::S, ::F) where {F, S} at /Users/oscar/.julia/dev/MathOptInterface/src/Utilities/model.jl:60
  _modifyconstr(::MathOptInterface.ConstraintIndex{F,S}, ::F, ::S, ::S) where {F, S} at /Users/oscar/.julia/dev/MathOptInterface/src/Utilities/model.jl:61
Stacktrace:
 [1] _modify(::Array{Tuple{MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}},MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}},1}, ::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}, ::Int64, ::MathOptInterface.SingleVariable) at /Users/oscar/.julia/dev/MathOptInterface/src/Utilities/model.jl:76
 [2] _modify(::MathOptInterface.Utilities.ModelScalarConstraints{Float64,MathOptInterface.ScalarAffineFunction{Float64}}, ::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}, ::Int64, ::MathOptInterface.SingleVariable) at /Users/oscar/.julia/dev/MathOptInterface/src/Utilities/model.jl:1292
 [3] _modify(::MathOptInterface.Utilities.Model{Float64}, ::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}, ::Int64, ::MathOptInterface.SingleVariable) at /Users/oscar/.julia/dev/MathOptInterface/src/Utilities/model.jl:1308
 [4] set(::MathOptInterface.Utilities.Model{Float64}, ::MathOptInterface.ConstraintFunction, ::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64},MathOptInterface.EqualTo{Float64}}, ::MathOptInterface.SingleVariable) at /Users/oscar/.julia/dev/MathOptInterface/src/Utilities/model.jl:749
 [5] top-level scope at none:0
@odow odow added Type: Bug Submodule: Utilities About the Utilities submodule labels Mar 9, 2021
@odow odow self-assigned this Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Submodule: Utilities About the Utilities submodule Type: Bug
1 participant