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

sparse decomposition results in MethodError: no method matching BlockDiagonalGramMatrix(::Vector{GramMatrix{ #344

Open
ArnaudKul opened this issue Apr 18, 2024 · 1 comment · May be fixed by #346
Labels

Comments

@ArnaudKul
Copy link

Hello, I am executing this file :

using JuMP
using SumOfSquares
using DynamicPolynomials
import CSDP
Solver = optimizer_with_attributes(CSDP.Optimizer, MOI.Silent() => true)
function sos_min(sparsity, d, obj, dom; solver=Solver)
    model = Model(solver)
    @variable(model, t)
    @objective(model, Min, t)
    con_ref = @constraint(model, obj - t in SOSCone(), sparsity = sparsity, maxdegree = d, domain = dom)
    optimize!(model)
    return moment_matrix(con_ref)
end
@polyvar x[1:3] l[1:3]
my_game_obj = x[1]^2+x[2]^2+x[3]^2
my_eq_list = [-1+l[3]-3l[2]-3x[2]^2-x[1]*x[2],3x[2]*l[2]-x[2]^2*l[2]-x[1]^2*l[2],l[3]-x[3]*l[3],-2+x[3]+2x[1]+2x[1]*l[1],-2-x[3]+2x[2]+2x[2]*l[1],2l[1]-x[3]*l[1]-x[2]^2*l[1]-x[1]^2*l[1]]
my_ineq_list = [3x[3]-x[2]^2-x[1]^2,1-x[3],l[2],l[3],2-x[3]-x[2]^2-x[1]^2,l[1]]
my_Dom = basicsemialgebraicset(algebraicset(my_eq_list), my_ineq_list)
ν = sos_min(Sparsity.Monomial(ChordalCompletion()),4,my_game_obj,my_Dom)

gives the following error

ERROR: MethodError: no method matching BlockDiagonalGramMatrix(::Vector{GramMatrix{_A, MonomialBasis{Monomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}}, MonomialVector{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}}}, _B, _C} 
where {_A, _B, _C<:AbstractMatrix{_A}}})
Closest candidates are:
  BlockDiagonalGramMatrix(::Array{GramMatrix{T, B, U, MT}, 1}) where {T, B, U, MT} at C:\Users\arobert\.julia\packages\SumOfSquares\xNLIR\src\gram_matrix.jl:221
Stacktrace:

versions

julia v.1.6.1



(Stakelberg.jl) pkg> st
      Status `C:\Users\usename\Documents\GitHub\Stakelberg.jl\Project.toml`
  [0a46da34] CSDP v1.1.1
  [7c1d4256] DynamicPolynomials v0.5.5
  [b99e6be6] Hypatia v0.8.0
  [4076af6c] JuMP v1.20.0
  [5036cc39] MomentOpt v0.3.0
  [6405355b] Mosek v10.1.4
  [1ec41992] MosekTools v0.15.1
  [8e049039] SemialgebraicSets v0.3.2
  [4b9e565b] SumOfSquares v0.7.3
@blegat blegat added the bug label Apr 18, 2024
@blegat
Copy link
Member

blegat commented Apr 25, 2024

The issue seems that the resulting gram matrix is a block diagonal gram matrix with no block hence inference fails to infer the element type.

@blegat blegat linked a pull request May 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants