-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sparse -> Sparse * Sparse module * Sparse -> Sparsity * Renamings * Sparse -> Sparsity * Renamings * Update tests * Add deprecation * Fixes * Fix for MOI v0.10.6 * Doc fixes * Doc fixes * Fix examples
- Loading branch information
Showing
32 changed files
with
273 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Sparsity | ||
|
||
import MultivariatePolynomials | ||
const MP = MultivariatePolynomials | ||
import MultivariateBases | ||
const MB = MultivariateBases | ||
using SemialgebraicSets | ||
|
||
include("ChordalExtensionGraph.jl") | ||
using .ChordalExtensionGraph: ChordalCompletion, ClusterCompletion | ||
export ChordalCompletion, ClusterCompletion | ||
|
||
import SumOfSquares | ||
|
||
export SignSymmetry | ||
abstract type Pattern end | ||
struct NoPattern <: Pattern end | ||
|
||
include("xor_space.jl") | ||
include("sign.jl") | ||
include("variable.jl") | ||
include("monomial.jl") | ||
|
||
include("preorder.jl") | ||
include("ideal.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
struct Sparsity.Ideal{S <: Sparsity.Pattern, C <: AbstractIdealCertificate} <: SumOfSquares.Certificate.AbstractIdealCertificate | ||
sparsity::S | ||
certificate::C | ||
end | ||
Same certificate as `certificate` except that the Sum-of-Squares polynomial `σ` | ||
is modelled as a sum of Sum-of-Squares polynomials with smaller bases | ||
using the sparsity reduction `sparsity`. | ||
""" | ||
struct Ideal{S <: Pattern, C <: SumOfSquares.Certificate.AbstractIdealCertificate} <: SumOfSquares.Certificate.AbstractIdealCertificate | ||
sparsity::S | ||
certificate::C | ||
end | ||
|
||
function Ideal(sp::Variable, basis, cone, maxdegree::Nothing, newton_polytope) | ||
error("`maxdegree` cannot be `nothing` when `sparsity` is `Sparsity.Variable`.") | ||
end | ||
function Ideal(sp::Variable, basis, cone, maxdegree::Integer, newton_polytope) | ||
return Ideal(sp, SumOfSquares.Certificate.MaxDegree(cone, basis, maxdegree)) | ||
end | ||
function Ideal(sp::Union{Monomial, SignSymmetry}, basis, cone, maxdegree, newton_polytope) | ||
return Ideal(sp, SumOfSquares.Certificate.Newton(cone, basis, newton_polytope)) | ||
end | ||
|
||
function sparsity(poly::MP.AbstractPolynomial, ::Variable, certificate::SumOfSquares.Certificate.MaxDegree) | ||
H, cliques = chordal_csp_graph(poly, SemialgebraicSets.FullSpace()) | ||
return map(cliques) do clique | ||
return SumOfSquares.Certificate.maxdegree_gram_basis(certificate.basis, clique, certificate.maxdegree) | ||
end | ||
end | ||
function sparsity(monos, sp::Union{SignSymmetry, Monomial}, gram_basis::MB.MonomialBasis) | ||
return MB.MonomialBasis.(sparsity(monos, sp, gram_basis.monomials)) | ||
end | ||
function sparsity(poly::MP.AbstractPolynomial, sp::Union{SignSymmetry, Monomial}, certificate::SumOfSquares.Certificate.AbstractIdealCertificate) | ||
return sparsity(MP.monomials(poly), sp, SumOfSquares.Certificate.get(certificate, SumOfSquares.Certificate.GramBasis(), poly)) | ||
end | ||
function SumOfSquares.Certificate.get(certificate::Ideal, ::SumOfSquares.Certificate.GramBasis, poly) | ||
return sparsity(poly, certificate.sparsity, certificate.certificate) | ||
end | ||
function SumOfSquares.Certificate.get(::Type{Ideal{S, C}}, attr::SumOfSquares.Certificate.GramBasisType) where {S, C} | ||
return Vector{<:SumOfSquares.Certificate.get(C, attr)} | ||
end | ||
function SumOfSquares.Certificate.get(certificate::Ideal, attr::SumOfSquares.Certificate.ReducedPolynomial, poly, domain) | ||
return SumOfSquares.Certificate.get(certificate.certificate, attr, poly, domain) | ||
end | ||
function SumOfSquares.Certificate.get(certificate::Ideal, attr::SumOfSquares.Certificate.Cone) | ||
return SumOfSquares.Certificate.get(certificate.certificate, attr) | ||
end | ||
SumOfSquares.matrix_cone_type(::Type{Ideal{S, C}}) where {S, C} = SumOfSquares.matrix_cone_type(C) | ||
|
||
SumOfSquares.Certificate.zero_basis(certificate::Ideal) = SumOfSquares.Certificate.zero_basis(certificate.certificate) | ||
SumOfSquares.Certificate.zero_basis_type(::Type{Ideal{S, C}}) where {S, C} = SumOfSquares.Certificate.zero_basis_type(C) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
struct Sparsity.Preorder{S <: Sparsity.Pattern, C <: SumOfSquares.Certificate.AbstractPreorderCertificate} <: SumOfSquares.Certificate.AbstractPreorderCertificate | ||
sparsity::S | ||
certificate::C | ||
end | ||
Same certificate as `C` except that the Sum-of-Squares polynomials `σ_i` | ||
are modelled as a sum of Sum-of-Squares polynomials with smaller basis | ||
using the sparsity reduction `sparsity`. | ||
""" | ||
struct Preorder{S <: Pattern, C <: SumOfSquares.Certificate.AbstractPreorderCertificate} <: SumOfSquares.Certificate.AbstractPreorderCertificate | ||
sparsity::S | ||
certificate::C | ||
end | ||
|
||
SumOfSquares.Certificate.get(certificate::Preorder, attr::SumOfSquares.Certificate.Cone) = SumOfSquares.Certificate.get(certificate.certificate, attr) | ||
|
||
struct Domain{S, P, B} | ||
domain::S | ||
processed::P | ||
bases::Vector{Vector{B}} | ||
end | ||
|
||
function SumOfSquares.Certificate.get(certificate::Preorder, attr::SumOfSquares.Certificate.PreprocessedDomain, domain::SemialgebraicSets.BasicSemialgebraicSet, p) | ||
basis, Preorder_bases = sparsity(p, domain, certificate.sparsity, certificate.certificate) | ||
return Domain(domain, SumOfSquares.Certificate.get(certificate.certificate, attr, domain, p), Preorder_bases) | ||
end | ||
|
||
function SumOfSquares.Certificate.get(certificate::Preorder, attr::SumOfSquares.Certificate.PreorderIndices, domain::Domain) | ||
return SumOfSquares.Certificate.get(certificate.certificate, attr, domain.processed) | ||
end | ||
|
||
function SumOfSquares.Certificate.get(::Preorder, ::SumOfSquares.Certificate.MultiplierBasis, index::SumOfSquares.Certificate.PreorderIndex, domain::Domain) | ||
return domain.bases[index.value] | ||
end | ||
function SumOfSquares.Certificate.get(::Type{Preorder{S, C}}, attr::SumOfSquares.Certificate.MultiplierBasisType) where {S, C} | ||
return Vector{SumOfSquares.Certificate.get(C, attr)} | ||
end | ||
|
||
function SumOfSquares.Certificate.get(certificate::Preorder, attr::SumOfSquares.Certificate.Generator, index::SumOfSquares.Certificate.PreorderIndex, domain::Domain) | ||
return SumOfSquares.Certificate.get(certificate.certificate, attr, index, domain.processed) | ||
end | ||
|
||
SumOfSquares.Certificate.get(certificate::Preorder, attr::SumOfSquares.Certificate.IdealCertificate) = Ideal(certificate.sparsity, SumOfSquares.Certificate.get(certificate.certificate, attr)) | ||
SumOfSquares.Certificate.get(::Type{<:Preorder{S, C}}, attr::SumOfSquares.Certificate.IdealCertificate) where {S, C} = Ideal{S, SumOfSquares.Certificate.get(C, attr)} | ||
|
||
SumOfSquares.matrix_cone_type(::Type{Preorder{S, C}}) where {S, C} = SumOfSquares.matrix_cone_type(C) |
4 changes: 2 additions & 2 deletions
4
src/Certificate/sparse/sign.jl → src/Certificate/Sparsity/sign.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.