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

Ambiguous methods for supports_constraint #854

Closed
matbesancon opened this issue Aug 28, 2019 · 5 comments · Fixed by #891
Closed

Ambiguous methods for supports_constraint #854

matbesancon opened this issue Aug 28, 2019 · 5 comments · Fixed by #891
Assignees
Milestone

Comments

@matbesancon
Copy link
Contributor

The following happened when testing Dualization with MOI v0.9:

structures: Error During Test at /home/mbesancon/.julia/dev/Dualization/test/Tests/test_structures.jl:1
  Got exception outside of a @test
  MethodError: supports_constraint(::TestModel{Float64}, ::Type{MathOptInterface.SingleVariable}, ::Type{MathOptInterface.GreaterThan{Float64}}) is ambiguous. Candidates:
    supports_constraint(model::TestModel{#13#T}, ::Type{#s915} where #s915<:Union{MathOptInterface.SingleVariable, MathOptInterface.ScalarAffineFunction{#13#T}, MathOptInterface.ScalarQuadraticFunction{#13#T}}, ::Type{#s916} where #s916<:Union{MathOptInterface.Integer, MathOptInterface.ZeroOne, MathOptInterface.EqualTo{#13#T}, MathOptInterface.GreaterThan{#13#T}, MathOptInterface.Interval{#13#T}, MathOptInterface.LessThan{#13#T}, MathOptInterface.Semicontinuous{#13#T}, MathOptInterface.Semiinteger{#13#T}}) where #13#T in Main at /home/mbesancon/.julia/packages/MathOptInterface/016Ol/src/Utilities/model.jl:997
    supports_constraint(::MathOptInterface.Utilities.AbstractModel{T}, ::Type{MathOptInterface.SingleVariable}, ::Type{#s109} where #s109<:Union{MathOptInterface.Integer, MathOptInterface.ZeroOne, MathOptInterface.EqualTo{T}, MathOptInterface.GreaterThan{T}, MathOptInterface.Interval{T}, MathOptInterface.LessThan{T}}) where T in MathOptInterface.Utilities at /home/mbesancon/.julia/packages/MathOptInterface/016Ol/src/Utilities/model.jl:469
  Possible fix, define
    supports_constraint(::TestModel{T}, ::Type{MathOptInterface.SingleVariable}, ::Type{#s109} where #s109<:Union{MathOptInterface.Integer, MathOptInterface.ZeroOne, MathOptInterface.EqualTo{T}, MathOptInterface.GreaterThan{T}, MathOptInterface.Interval{T}, MathOptInterface.LessThan{T}})
  Stacktrace:
   [1] add_constraint(::TestModel{Float64}, ::MathOptInterface.SingleVariable, ::MathOptInterface.GreaterThan{Float64}) at /home/mbesancon/.julia/packages/MathOptInterface/016Ol/src/Utilities/model.jl:473
   [2] lp1_test() at /home/mbesancon/.julia/dev/Dualization/test/Problems/Linear/linear_problems.jl:18
   [3] top-level scope at /home/mbesancon/.julia/dev/Dualization/test/Tests/test_structures.jl:8
   [4] top-level scope at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.2/Test/src/Test.jl:1113
   [5] top-level scope at /home/mbesancon/.julia/dev/Dualization/test/Tests/test_structures.jl:2
@matbesancon
Copy link
Contributor Author

Status:

(Dualization) pkg> st
Project Dualization v0.1.0
    Status `~/.julia/dev/Dualization/Project.toml`
  [4076af6c] + JuMP v0.20.0
  [b8f27783] + MathOptInterface v0.9.1
    Status `~/.julia/dev/Dualization/Manifest.toml`
  [4076af6c] + JuMP v0.20.0
  [b8f27783] + MathOptInterface v0.9.1

@ericphanson
Copy link
Contributor

I am no MOI expert, but I had a similar ambiguity error, and @blegat directed me to #736, saying to remove MOI.SingleVariable from the @model macro, or just use MOI.Utilities.Model instead of the @model macro. I ended up going for MOI.Utilities.Model, seems to work well.

@matbesancon
Copy link
Contributor Author

Thanks I'll try this

@KristofferC
Copy link
Contributor

This came up when testing this package for 1.3:

Unslack: Error During Test at /root/.julia/packages/MathOptInterface/WXD0G/test/Bridges/lazy_bridge_optimizer.jl:472
  Test threw exception
  Expression: MOI.supports_constraint(full_bridged_no_variable, MOI.SingleVariable, S)
  MethodError: supports_constraint(::NoVariableModel{Float64}, ::Type{MathOptInterface.SingleVariable}, ::Type{MathOptInterface.LessThan{Float64}}) is ambiguous. Candidates:
    supports_constraint(::MathOptInterface.Utilities.AbstractModel{T}, ::Type{MathOptInterface.SingleVariable}, ::Type{#s110} where #s110<:Union{MathOptInterface.Integer, MathOptInterface.ZeroOne, MathOptInterface.EqualTo{T}, MathOptInterface.GreaterThan{T}, MathOptInterface.Interval{T}, MathOptInterface.LessThan{T}, MathOptInterface.Semicontinuous{T}, MathOptInterface.Semiinteger{T}}) where T in MathOptInterface.Utilities at /root/.julia/packages/MathOptInterface/WXD0G/src/Utilities/model.jl:482
    supports_constraint(::NoVariableModel, ::Type{MathOptInterface.SingleVariable}, ::Type{#s958} where #s958<:MathOptInterface.AbstractScalarSet) in Main at /root/.julia/packages/MathOptInterface/WXD0G/test/Bridges/lazy_bridge_optimizer.jl:256
  Possible fix, define
    supports_constraint(::NoVariableModel{T}, ::Type{MathOptInterface.SingleVariable}, ::Type{#s958} where #s958<:MathOptInterface.AbstractScalarSet)

@blegat blegat added this to the v0.9.3 milestone Sep 20, 2019
@blegat
Copy link
Member

blegat commented Sep 20, 2019

@matbesancon I believe this is indeed because you included MOI.SingleVariable in MOIU.Model.
@KristofferC Indeed, that's an ambiguity, good to see improvements in the Julia type system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants