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

ERROR: MethodError: no method matching setindex!(::Set{Int64}, ::Vector{Int64}, ::Colon) #149

Closed
thinh-le opened this issue Feb 18, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@thinh-le
Copy link

Hi COSMO devs, I am running a large scale SDP with

COSMO v0.8.3
JuMP v0.22.2
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i9-10900X CPU @ 3.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cascadelake)

and got the following

ERROR: MethodError: no method matching setindex!(::Set{Int64}, ::Vector{Int64}, ::Colon)
Stacktrace:
  [1] reorder_snd_consecutively!(t::COSMO.SuperNodeTree, ordering::Vector{Int64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\trees.jl:557
  [2] COSMO.SparsityPattern(L::SparseArrays.SparseMatrixCSC{Float64, Int64}, N::Int64, ordering::Vector{Int64}, merge_strategy::COSMO.OptionsFactory{COSMO.CliqueGraphMerge}, row_range::UnitRange{Int64}, cone_ind::Int64, nz_ind_map::SparseArrays.SparseVector{Int64, Int64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\types.jl:202
  [3] _analyse_sparsity_pattern(ci::COSMO.ChordalInfo{Float64}, csp::Vector{Int64}, sets::Vector{COSMO.AbstractConvexSet}, C::COSMO.PsdConeTriangle{Float64}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::COSMO.OptionsFactory{COSMO.CliqueGraphMerge})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\chordal_decomposition.jl:64
  [4] analyse_sparsity_pattern!(ci::COSMO.ChordalInfo{Float64}, csp::Vector{Int64}, sets::Vector{COSMO.AbstractConvexSet}, C::COSMO.PsdConeTriangle{Float64}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::COSMO.OptionsFactory{COSMO.CliqueGraphMerge})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\chordal_decomposition.jl:55
  [5] find_sparsity_patterns!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\chordal_decomposition.jl:47
  [6] chordal_decomposition!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\chordal_decomposition.jl:18
  [7] macro expansion
    @ .\timing.jl:299 [inlined]
  [8] optimize!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\solver.jl:90
  [9] optimize!
    @ C:\Users\Miguel\.julia\packages\COSMO\y3Zqn\src\MOI_wrapper.jl:152 [inlined]
 [10] optimize!
    @ C:\Users\Miguel\.julia\packages\MathOptInterface\QxT5e\src\MathOptInterface.jl:81 [inlined]
 [11] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{COSMO.Optimizer{Float64}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
    @ MathOptInterface.Utilities C:\Users\Miguel\.julia\packages\MathOptInterface\QxT5e\src\Utilities\cachingoptimizer.jl:285

The SDP was a large sparse problem, (re)formulated using group theoretic methods (SymbolicWedderburn.jl, StarAlgebras.jl, JuMP.jl and so on). Its hard for me to give a minimal working example, so if it is really needed to fix this bug, I can contact via email and send the details to you.

A smaller instance of my SDP was solved successfully with COSMO without such error, and with the same settings. In fact, I first solve the smaller instance to force compilation and check that everything works, then in the same Julia session I proceed to solve the above instance.

Could it be that L557 should be

s[:] = Set(k:1:k+l-1)

for setindex! to work? I am guessing purely based on syntax and so cannot make sure that the semantics of the program is respected if I fix it like this.

@thinh-le thinh-le added the bug Something isn't working label Feb 18, 2022
@migarstka
Copy link
Member

Thanks for opening an issue. I'll have a look.

migarstka added a commit that referenced this issue Feb 20, 2022
- If a graphbased merging strategy is applied to a pattern
with just one clique, no merging will happen. Convert snd, sep
which are Array{Set{Int}, 1} back to Array{Array{Int}, 1}.
@migarstka
Copy link
Member

migarstka commented Feb 20, 2022

I hope this fixes it 623a704 I will tag v0.8.5 shortly. Let me know if the issue persists.

@thinh-le
Copy link
Author

Many thanks, this works but another error pops up:

ERROR: TypeError: in <:, expected Type, got a value of type COSMO.CliqueGraphMerge
Stacktrace:
  [1] COSMO.SparsityPattern(L::SparseArrays.SparseMatrixCSC{Float64, Int64}, N::Int64, ordering::Vector{Int64}, merge_strategy::COSMO.OptionsFactory{COSMO.CliqueGraphMerge}, row_range::UnitRange{Int64}, cone_ind::Int64, nz_ind_map::SparseArrays.SparseVector{Int64, Int64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\types.jl:200
  [2] _analyse_sparsity_pattern(ci::COSMO.ChordalInfo{Float64}, csp::Vector{Int64}, sets::Vector{COSMO.AbstractConvexSet}, C::COSMO.PsdConeTriangle{Float64}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::COSMO.OptionsFactory{COSMO.CliqueGraphMerge})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:64
  [3] analyse_sparsity_pattern!(ci::COSMO.ChordalInfo{Float64}, csp::Vector{Int64}, sets::Vector{COSMO.AbstractConvexSet}, C::COSMO.PsdConeTriangle{Float64}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::COSMO.OptionsFactory{COSMO.CliqueGraphMerge})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:55
  [4] find_sparsity_patterns!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:47
  [5] chordal_decomposition!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:18
  [6] macro expansion
    @ .\timing.jl:299 [inlined]
  [7] optimize!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\solver.jl:90
  [8] optimize!
    @ C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\MOI_wrapper.jl:151 [inlined]
  [9] optimize!
    @ C:\Users\Miguel\.julia\packages\MathOptInterface\QxT5e\src\MathOptInterface.jl:81 [inlined]
 [10] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{COSMO.Optimizer{Float64}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
    @ MathOptInterface.Utilities C:\Users\Miguel\.julia\packages\MathOptInterface\QxT5e\src\Utilities\cachingoptimizer.jl:285

PS: I am trying to debug this myself by overriding COSMO fundtions. Let me know if you need any variables in my session.

@migarstka
Copy link
Member

You can also try using a different merge strategy, e.g. pass in the setting merge_strategy = COSMO.ParentChildMerge or merge_strategy = COSMO.NoMerge. see: https://oxfordcontrol.github.io/COSMO.jl/dev/decomposition/

@thinh-le
Copy link
Author

Thanks @migarstka. Btw, I can confirm that in the OP, my instance indeed has only one clique. Also your fix 623a704 still returns the correct result for a smaller instance. However, on the larger instance, using

COSMOOPTIMIZER = optimizer_with_attributes(
           COSMO.Optimizer,
           "max_iter" => 100_000,
           "verbose" => true,
           "verbose_timing" => true,
           "eps_abs" => 1e-8,
           "merge_strategy" => COSMO.NoMerge,
)

still returns error

ERROR: TypeError: in <:, expected Type, got a value of type COSMO.NoMerge
Stacktrace:
  [1] COSMO.SparsityPattern(L::SparseArrays.SparseMatrixCSC{Float64, Int64}, N::Int64, ordering::Vector{Int64}, merge_strategy::Type{COSMO.NoMerge}, row_range::UnitRange{Int64}, cone_ind::Int64, nz_ind_map::SparseArrays.SparseVector{Int64, Int64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\types.jl:200
  [2] _analyse_sparsity_pattern(ci::COSMO.ChordalInfo{Float64}, csp::Vector{Int64}, sets::Vector{COSMO.AbstractConvexSet}, C::COSMO.PsdConeTriangle{Float64}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::Type{COSMO.NoMerge})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:64
  [3] analyse_sparsity_pattern!(ci::COSMO.ChordalInfo{Float64}, csp::Vector{Int64}, sets::Vector{COSMO.AbstractConvexSet}, C::COSMO.PsdConeTriangle{Float64}, k::Int64, psd_row_range::UnitRange{Int64}, sp_ind::Int64, merge_strategy::Type{COSMO.NoMerge})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:55
  [4] find_sparsity_patterns!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:47
  [5] chordal_decomposition!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\chordal_decomposition.jl:18
  [6] macro expansion
    @ .\timing.jl:299 [inlined]
  [7] optimize!(ws::COSMO.Workspace{Float64})
    @ COSMO C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\solver.jl:90
  [8] optimize!
    @ C:\Users\Miguel\.julia\packages\COSMO\6NlGI\src\MOI_wrapper.jl:151 [inlined]
  [9] optimize!
    @ C:\Users\Miguel\.julia\packages\MathOptInterface\QxT5e\src\MathOptInterface.jl:81 [inlined]
 [10] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{COSMO.Optimizer{Float64}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
    @ MathOptInterface.Utilities C:\Users\Miguel\.julia\packages\MathOptInterface\QxT5e\src\Utilities\cachingoptimizer.jl:285

I'll try switching off the chordal decomposition completely and see what happens. Two questions:

  • should I open a separate issue for the type error?
  • the branch with_multi_threading is also up to date with v0.8.5 right?

@migarstka
Copy link
Member

should I open a separate issue for the type error?

It would be great if you could provide me with some code that I can use to reproduce the error.

the branch with_multi_threading is also up to date with v0.8.5 right?

I try to keep it in sync with the latest version

@thinh-le
Copy link
Author

Fixed by @kalmarek in #164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants