Skip to content

COSMO.jl does not work with JuMP #123

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

Closed
Shuvomoy opened this issue Jan 15, 2021 · 3 comments
Closed

COSMO.jl does not work with JuMP #123

Shuvomoy opened this issue Jan 15, 2021 · 3 comments

Comments

@Shuvomoy
Copy link

Dear All,

I am trying to run the following code verbatim from the documentation:


using COSMO, JuMP, LinearAlgebra

C =  [1 2; 0 2]
A = [1 0; 5 2]
b = 4;

m = Model(COSMO.Optimizer);
# replacing the previous line with 
# m = JuMP.Model(SCS.Optimizer);
# works just fine
@variable(m, X[1:2, 1:2], PSD)
@objective(m, Min, tr(C * X));
@constraint(m, tr(A * X) == b);
JuMP.optimize!(m);

status = JuMP.termination_status(m)
X_sol = JuMP.value.(X)
obj_value = JuMP.objective_value(m)

And I am getting the error:

MethodError: no method matching _pass_attributes(::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.AbstractModelAttribute,1}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::typeof(MathOptInterface.Utilities.load))
Closest candidates are:
  _pass_attributes(::MathOptInterface.ModelLike, ::MathOptInterface.ModelLike, !Matched::MathOptInterface.Utilities.IndexMap, ::Any, ::Any, ::Any, ::Any) at C:\Users\shuvo\.julia\packages\MathOptInterface\ZJFKw\src\Utilities\copy.jl:175
  _pass_attributes(::MathOptInterface.ModelLike, ::MathOptInterface.ModelLike, !Matched::MathOptInterface.Utilities.IndexMap, ::Any, ::Any, ::Any, ::Any, !Matched::Function) at C:\Users\shuvo\.julia\packages\MathOptInterface\ZJFKw\src\Utilities\copy.jl:175
pass_attributes!(::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::MathOptInterface.Utilities.IndexMap, ::Function) at MOIWrapper.jl:615
pass_attributes!(::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::MathOptInterface.Utilities.IndexMap) at MOIWrapper.jl:611
copy_to(::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}; copy_names::Bool) at MOIWrapper.jl:148
(::MathOptInterface.var"#copy_to##kw")(::NamedTuple{(:copy_names,),Tuple{Bool}}, ::typeof(MathOptInterface.copy_to), ::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}) at MOIWrapper.jl:137
attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{Optimizer{Float64},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at cachingoptimizer.jl:150
optimize!(::MathOptInterface.Utilities.CachingOptimizer{Optimizer{Float64},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at cachingoptimizer.jl:211
optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{Optimizer{Float64},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}}) at bridge_optimizer.jl:264
optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at cachingoptimizer.jl:215
optimize!(::Model, ::Nothing; bridge_constraints::Bool, ignore_optimize_hook::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at optimizer_interface.jl:131
optimize! at optimizer_interface.jl:107 [inlined]
optimize!(::Model) at optimizer_interface.jl:107
top-level scope at all_files_test.jl:556
include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088

I have tried the same problem with SCS and it works just fine. Any help on how to fix this will be appreciated.

@blegat
Copy link
Contributor

blegat commented Jan 15, 2021

See #117

@migarstka
Copy link
Member

migarstka commented Jan 15, 2021

@Shuvomoy What MathOptInterface version are you using? You should use a version higher than v.0.19.14 (and the latest COSMO v0.7.8).

Looks similar to #117.

@Shuvomoy
Copy link
Author

Thanks, my MathOptInterface was not updated as you pointed out. Updating it fixed the issue.

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

No branches or pull requests

3 participants