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 no method matching _allocate_constraint #112

Closed
ccoffrin opened this issue Sep 29, 2018 · 3 comments
Closed

MOI no method matching _allocate_constraint #112

ccoffrin opened this issue Sep 29, 2018 · 3 comments

Comments

@ccoffrin
Copy link

ccoffrin commented Sep 29, 2018

With Julia v0.6.4, JuMP master, SCS master, and MOI v0.6.1.

With the following JuMP model,

using JuMP; using SCS

using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities

m = Model()

X = @variable(m, [1:3, 1:3])

@constraint(m, X in PSDCone())

MOIU.resetoptimizer!(m, SCS.Optimizer())
JuMP.optimize!(m)

I am getting the following error message,

ERROR: MethodError: no method matching _allocate_constraint(::SCS.ConeData, ::MathOptInterface.VectorOfVariables, ::MathOptInterface.PositiveSemidefiniteConeSquare)
Closest candidates are:
  _allocate_constraint(::SCS.ConeData, ::Any, ::Union{MathOptInterface.EqualTo, MathOptInterface.Zeros}) at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:99
  _allocate_constraint(::SCS.ConeData, ::Any, ::Union{MathOptInterface.GreaterThan, MathOptInterface.LessThan, MathOptInterface.Nonnegatives, MathOptInterface.Nonpositives}) at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:105
  _allocate_constraint(::SCS.ConeData, ::Any, ::MathOptInterface.SecondOrderCone) at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:111
  ...
Stacktrace:
 [1] allocate_constraint at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:131 [inlined]
 [2] allocate_constraints(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Type{MathOptInterface.VectorOfVariables}, ::Type{MathOptInterface.PositiveSemidefiniteConeSquare}) at /home/.julia/v0.6/MathOptInterface/src/Utilities/copy.jl:205
 [3] allocate_load(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool) at /home/.julia/v0.6/MathOptInterface/src/Utilities/copy.jl:253
 [4] (::MathOptInterface.#kw##copy_to)(::Array{Any,1}, ::MathOptInterface.#copy_to, ::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}) at ./<missing>:0
 [5] attachoptimizer!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}}) at /home/.julia/v0.6/MathOptInterface/src/Utilities/cachingoptimizer.jl:125
 [6] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}}) at /home/.julia/v0.6/MathOptInterface/src/Utilities/cachingoptimizer.jl:158
 [7] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}},MathOptInterface.Bridges.AllBridgedConstraints{Float64}}) at /home/.julia/v0.6/MathOptInterface/src/Bridges/bridgeoptimizer.jl:73
 [8] #optimize!#92(::Bool, ::Function, ::JuMP.Model, ::Void) at /home/.julia/v0.6/JuMP/src/optimizer_interface.jl:65
 [9] optimize!(::JuMP.Model) at /home/.julia/v0.6/JuMP/src/optimizer_interface.jl:42
@blegat
Copy link
Member

blegat commented Sep 29, 2018

Bridges currently don't work if you do not provide the optimizer from the start.
Try

using JuMP; using SCS

using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities

m = Model(with_optimizer(SCS.Optimizer))

X = @variable(m, [1:3, 1:3])

@constraint(m, X in PSDCone())

JuMP.optimize!(m)

Note that the new syntax is JuMP.optimize!(m, with_optimizer(SCS.Optimizer)) instead of calling resetoptimizer!. We should have a better error.

@ccoffrin
Copy link
Author

ccoffrin commented Sep 29, 2018

Thanks for the clarification on the new syntax. I can confirm the example you provide works like a charm.

However, if I try to set the optimizer at the time of optimize! then I still have an issue,

using JuMP; using SCS

m = Model()

X = @variable(m, [1:3, 1:3])

@constraint(m, X in PSDCone())

JuMP.optimize!(m, with_optimizer(SCS.Optimizer))

results in,

ERROR: MethodError: no method matching _allocate_constraint(::SCS.ConeData, ::MathOptInterface.VectorOfVariables, ::MathOptInterface.PositiveSemidefiniteConeSquare)
Closest candidates are:
  _allocate_constraint(::SCS.ConeData, ::Any, ::Union{MathOptInterface.EqualTo, MathOptInterface.Zeros}) at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:100
  _allocate_constraint(::SCS.ConeData, ::Any, ::Union{MathOptInterface.GreaterThan, MathOptInterface.LessThan, MathOptInterface.Nonnegatives, MathOptInterface.Nonpositives}) at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:106
  _allocate_constraint(::SCS.ConeData, ::Any, ::MathOptInterface.SecondOrderCone) at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:112
  ...
Stacktrace:
 [1] allocate_constraint at /home/.julia/v0.6/SCS/src/MOIWrapper.jl:132 [inlined]
 [2] allocate_constraints(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Type{MathOptInterface.VectorOfVariables}, ::Type{MathOptInterface.PositiveSemidefiniteConeSquare}) at /home/.julia/v0.6/MathOptInterface/src/Utilities/copy.jl:205
 [3] allocate_load(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}, ::Bool) at /home/.julia/v0.6/MathOptInterface/src/Utilities/copy.jl:253
 [4] (::MathOptInterface.#kw##copy_to)(::Array{Any,1}, ::MathOptInterface.#copy_to, ::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}) at ./<missing>:0
 [5] attachoptimizer!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP.JuMPMOIModel{Float64}}}) at /home/.julia/v0.6/MathOptInterface/src/Utilities/cachingoptimizer.jl:125
 [6] attachoptimizer!(::JuMP.Model) at /home/.julia/v0.6/JuMP/src/optimizer_interface.jl:25
 [7] #optimize!#92(::Bool, ::Function, ::JuMP.Model, ::JuMP.OptimizerFactory) at /home/.julia/v0.6/JuMP/src/optimizer_interface.jl:56
 [8] optimize!(::JuMP.Model, ::JuMP.OptimizerFactory) at /home/.julia/v0.6/JuMP/src/optimizer_interface.jl:42

@blegat
Copy link
Member

blegat commented Sep 30, 2018

However, if I try to set the optimizer at the time of optimize! then I still have an issue,

Thanks for checking that. This is problematic but should be resolved by jump-dev/JuMP.jl#1504 and jump-dev/MathOptInterface.jl#530. There is nothing wrong in SCS.jl so I am closing this issue.

@blegat blegat closed this as completed Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants