oxfordcontrol / COSMO.jl

COSMO: Accelerated ADMM-based solver for convex conic optimisation problems (LP, QP, SOCP, SDP, ExpCP, PowCP). Automatic chordal decomposition of sparse semidefinite programs.
https://oxfordcontrol.github.io/COSMO.jl/stable
Apache License 2.0
284 stars 42 forks source link

Issue with _pass_attributes(::MathOptInterface.ModelLike ... #117

Closed 1oly closed 4 years ago

1oly commented 4 years ago

Hi,

I recently made a post at discourse: https://discourse.julialang.org/t/performance-of-optimization-problem-in-a-loop/46374 with discussion on speeding-up an optimization problem. But now I cannot run the code.

MWE:

using Convex, COSMO
n = 4
x = rand(ComplexF64,n); 
noise = diagm(rand(n))
S = x*x' + noise

d = Convex.Variable(n)
p = minimize(sum(d), S+Diagonal(d) in :SDP)
solve!(p, () -> COSMO.Optimizer())

This worked when I posted but after an update it fails, due to _pass_attributes:

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, ::MathOptInterface.Utilities.IndexMap, ::Any, ::Any, ::Any, ::Any) at /Users/oliver/.julia/packages/MathOptInterface/k7UUH/src/Utilities/copy.jl:175
  _pass_attributes(::MathOptInterface.ModelLike, ::MathOptInterface.ModelLike, ::MathOptInterface.Utilities.IndexMap, ::Any, ::Any, ::Any, ::Any, ::Function) at /Users/oliver/.julia/packages/MathOptInterface/k7UUH/src/Utilities/copy.jl:175
Stacktrace:
 [1] pass_attributes!(::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::MathOptInterface.Utilities.IndexMap, ::Function) at /Users/oliver/.julia/packages/COSMO/k4vsi/src/MOIWrapper.jl:615
 [2] pass_attributes!(::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::MathOptInterface.Utilities.IndexMap) at /Users/oliver/.julia/packages/COSMO/k4vsi/src/MOIWrapper.jl:611
 [3] copy_to(::Optimizer{Float64}, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}; copy_names::Bool) at /Users/oliver/.julia/packages/COSMO/k4vsi/src/MOIWrapper.jl:148
 [4] attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{Optimizer{Float64},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /Users/oliver/.julia/packages/MathOptInterface/k7UUH/src/Utilities/cachingoptimizer.jl:150
 [5] optimize!(::MathOptInterface.Utilities.CachingOptimizer{Optimizer{Float64},MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /Users/oliver/.julia/packages/MathOptInterface/k7UUH/src/Utilities/cachingoptimizer.jl:211
 [6] optimize! at /Users/oliver/.julia/packages/MathOptInterface/k7UUH/src/Bridges/bridge_optimizer.jl:264 [inlined]
 [7] solve!(::Problem{Float64}, ::Optimizer{Float64}; check_vexity::Bool, verbose::Bool, warmstart::Bool, silent_solver::Bool) at /Users/oliver/.julia/packages/Convex/aYxJA/src/solution.jl:245
 [8] solve! at /Users/oliver/.julia/packages/Convex/aYxJA/src/solution.jl:223 [inlined]
 [9] solve!(::Problem{Float64}, ::var"#3#4"; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/oliver/.julia/packages/Convex/aYxJA/src/solution.jl:192
 [10] solve!(::Problem{Float64}, ::Function) at /Users/oliver/.julia/packages/Convex/aYxJA/src/solution.jl:191
 [11] top-level scope at REPL[21]:1

Unfortunately, I do not recall my package versions per the working code. Now my status is:

(@v1.5) pkg> st
Status `~/.julia/environments/v1.5/Project.toml`
  [d9c5613a] AbstractOperators v0.2.2
  [537997a7] AbstractPlotting v0.12.10
  [03ede2b8] AeroAcoustics v0.1.2 `../../dev/AeroAcoustics`
  [28312eec] Alert v0.2.0
  [c7e460c6] ArgParse v1.1.0
  [c52e3926] Atom v0.12.23
  [6e4b80f9] BenchmarkTools v0.5.0
  [b99e7846] BinaryProvider v0.5.10
  [1e616198] COSMO v0.7.5
  [336ed68f] CSV v0.7.7
  [5d742f6a] CSVFiles v1.0.0
  [35d6a980] ColorSchemes v3.10.0
  [5ae59095] Colors v0.12.4
  [aa819f21] CompatHelper v1.16.2
  [f65535da] Convex v0.13.7
  [150eb455] CoordinateTransformations v0.6.0
  [a2441757] Coverage v1.1.1
  [717857b8] DSP v0.6.8
  [a93c6f00] DataFrames v0.21.7
  [864edb3b] DataStructures v0.17.20
  [b4f34e82] Distances v0.8.2
  [31c24e10] Distributions v0.23.8
  [e30172f5] Documenter v0.25.2
  [8f5d6c58] EzXML v1.1.0
  [7a1cc6ca] FFTW v1.2.4
  [5789e2e9] FileIO v1.4.3
  [f6369f11] ForwardDiff v0.10.12
  [e9467ef8] GLMakie v0.1.11
  [28b8d3ca] GR v0.52.0
  [aa1b3936] GraphIO v0.5.0
  [f67ccb44] HDF5 v0.13.6
  [7073ff75] IJulia v1.21.3
  [6218d12a] ImageMagick v1.1.6
  [c601a237] Interact v0.10.3
  [4076af6c] JuMP v0.21.4
  [e5e0dc1b] Juno v0.8.4
  [b964fa9f] LaTeXStrings v1.2.0
  [266f59ce] LaTeXTabulars v0.1.1
  [5078a376] LazyArrays v0.16.16
  [093fc24a] LightGraphs v1.3.3
  [9c8b4983] LightXML v0.9.0
  [79261aaa] LocalCoverage v0.1.0 `https://github.com/tpapp/LocalCoverage.jl.git#master`
  [2fda8390] LsqFit v0.11.0
  [23992714] MAT v0.8.1
  [c7f686f2] MCMCChains v4.2.1
  [6e857e4b] MCMCDiagnostics v0.3.0
  [ee78f7c6] Makie v0.11.1
  [eff96d63] Measurements v2.3.0
  [7269a6da] MeshIO v0.4.1
  [0987c9cc] MonteCarloMeasurements v0.9.7
  [80a8ab25] MultipleScattering v0.1.4
  [2774e3e8] NLsolve v4.4.1
  [3b7a836e] PGFPlots v3.3.2
  [8314cec4] PGFPlotsX v1.2.10
  [bef90210] PLCT v0.1.0 `../../dev/PLCT#master`
  [9b87118b] PackageCompiler v1.2.1
  [d96e819e] Parameters v0.12.1
  [91a5bcdd] Plots v1.6.6
  [85a6dd25] PositiveFactorizations v0.2.3
  [92933f4c] ProgressMeter v1.4.0
  [65e78d25] ProxSDP v1.3.0
  [140ffc9f] ProximalAlgorithms v0.4.0
  [a725b495] ProximalOperators v0.11.0
  [438e738f] PyCall v1.91.4
  [d330b81b] PyPlot v2.9.0
  [dca85d43] QuartzImageIO v0.7.3
  [37e2e3b7] ReverseDiff v1.4.3
  [295af30f] Revise v3.1.2
  [f2b01f46] Roots v1.0.5
  [6038ab10] Rotations v1.0.1
  [c946c3f1] SCS v0.7.0
  [276daf66] SpecialFunctions v0.10.3
  [2913bbd2] StatsBase v0.33.1
  [65254759] StatsMakie v0.2.3
  [f3b207a7] StatsPlots v0.14.13
  [5e0ebb24] Strided v1.0.1
  [46cd3e9d] StructuredOptimization v0.2.3
  [30cdaa97] SystemBenchmark v0.3.4
  [bd369af6] Tables v1.0.5
  [5e47fb64] TestImages v1.2.2
  [c751599d] ToeplitzMatrices v0.6.2
  [592b5752] Trapz v2.0.2
  [fce5fe82] Turing v0.14.3
  [b8865327] UnicodePlots v1.3.0
  [8149f6b0] WAV v1.0.3
  [fdbf4ff8] XLSX v0.7.3
  [e88e6eb3] Zygote v0.5.7

I can see a discussion in https://github.com/oxfordcontrol/COSMO.jl/issues/116 that looks related to changes in MathOptInterface

Thanks for an otherwise great piece of software!

blegat commented 4 years ago

See https://github.com/oxfordcontrol/COSMO.jl/issues/116 Make sure you use the latest version of COSMO and MathOptInterface

migarstka commented 4 years ago

Apologies for that. We changed the code to support the latest version of MOI v0.9.16.
Otherwise, you can check out the previous version of COSMO: pkg> add COSMO#v0.7.4

migarstka commented 4 years ago

I am slightly surprised that MOI wasn't updated when you installed the latest COSMO v0.7.5 as I put it as a dependency here: https://github.com/oxfordcontrol/COSMO.jl/blob/9467d619ad8a71a668c10cf865f9273586dbc8e4/Project.toml#L25

1oly commented 4 years ago

It was my mistake, sorry. I hadn't restarted julia after adding v0.7.5 (didn't know that was required). It's working fine now. Thanks for the quick response!