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

Use WeightedSOSCone by default #355

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
f848081
Use Variable.KernelBridge by default
blegat May 14, 2024
26f5702
Fixes
blegat May 14, 2024
6c96f5d
Fixes
blegat May 14, 2024
8b1a17f
Update to StarAlgebras
blegat May 22, 2024
88a340a
Fixes
blegat May 23, 2024
f0e56be
Use basis, not monomials in SOSPolynomialSet
blegat May 23, 2024
2d94025
Fixes
blegat May 23, 2024
666ba8e
Fix format
blegat May 23, 2024
ef2fb1c
Fixes
blegat May 23, 2024
72126ed
Fix format
blegat May 23, 2024
364f00b
Fixes
blegat May 24, 2024
d6f93e9
Fix format
blegat May 25, 2024
623e0e2
up
blegat May 27, 2024
2b6e4ea
up
blegat May 27, 2024
5934578
Fixes
blegat May 27, 2024
faecf67
Fixes
blegat May 27, 2024
4c77875
Fix
blegat May 28, 2024
e00c503
GLPK tests working
blegat May 28, 2024
df45196
Fix format
blegat May 28, 2024
6cf200b
Fixes
blegat May 28, 2024
f80ae73
Fix format
blegat May 28, 2024
fac8136
Fixes
blegat May 28, 2024
623e3e8
Fixes
blegat May 28, 2024
76f634d
Fixes
blegat May 28, 2024
1a69467
Fix format
blegat May 28, 2024
fe9dd32
Fix
blegat May 28, 2024
ebc8868
Fixes
blegat May 29, 2024
a614315
WIP
blegat May 29, 2024
5aa328e
WIP
blegat May 30, 2024
edd442a
WIP
blegat May 30, 2024
2212929
up
blegat May 30, 2024
bdde3a2
Fixes
blegat May 30, 2024
3fe5bcf
Missing canonical
blegat May 31, 2024
70b7f54
Fixes
blegat Jun 3, 2024
3173afc
up
blegat Jun 3, 2024
ff616d9
up
blegat Jun 3, 2024
d283ba2
Fixes
blegat Jun 4, 2024
b2e1653
Fixes
blegat Jun 4, 2024
5e69887
up
blegat Jun 4, 2024
02bfd28
Fixes
blegat Jun 4, 2024
65999b4
Fixes
blegat Jun 5, 2024
30d7fb9
Fixes
blegat Jun 5, 2024
13bddca
Fixes
blegat Jun 5, 2024
ba0907d
Remove debug
blegat Jun 6, 2024
57a10a4
Remove debug
blegat Jun 6, 2024
15fcd66
Fixes
blegat Jun 6, 2024
f67d91a
up
blegat Jun 8, 2024
850e32c
Fxies
blegat Jun 8, 2024
d48a255
Fixes
blegat Jun 8, 2024
f0c9306
Fixes
blegat Jun 10, 2024
f6e30ae
SCS tests passing
blegat Jun 10, 2024
72a2798
Simplifty
blegat Jun 10, 2024
eafd066
Fixes
blegat Jun 10, 2024
f297da6
Fix format
blegat Jun 11, 2024
3fa06d5
Fixes
blegat Jun 12, 2024
4c425cb
up ci
blegat Jun 12, 2024
e328886
Fix format
blegat Jun 12, 2024
716d880
Fixes
blegat Jun 14, 2024
11e8ed4
Fix
blegat Jun 14, 2024
7bc5516
Fixes
blegat Jun 14, 2024
c3d7627
Update .github/workflows/ci.yml
blegat Jun 14, 2024
563f5d3
Fix @kwdef for Julia v1.6
blegat Jun 17, 2024
7d4635b
fix format
blegat Jun 17, 2024
fd2ed1f
Fixes
blegat Jun 17, 2024
3182ba6
Fixes
blegat Jun 18, 2024
cc172b4
Update ci
blegat Jun 18, 2024
5a587fb
Fix format
blegat Jun 18, 2024
7763055
Fixes
blegat Jun 18, 2024
f13c16e
Fix format
blegat Jun 18, 2024
71d672a
Fix
blegat Jun 18, 2024
5563cd0
Disable symmetry
blegat Jun 19, 2024
f9c16aa
Update script of examples
blegat Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ jobs:
run: |
using Pkg
Pkg.add([
PackageSpec(name="MultivariateBases", rev="master"),
PackageSpec(name="MathOptInterface", rev="master"),
PackageSpec(name="MathOptInterface", rev="bl/set_map_type"),
PackageSpec(name="StarAlgebras", rev="bl/sos"),
blegat marked this conversation as resolved.
Show resolved Hide resolved
PackageSpec(name="SymbolicWedderburn", rev="mk/StarAlgebras_0_3"),
PackageSpec(name="MultivariateBases", rev="bl/sos"),
PackageSpec(name="SemialgebraicSets", rev="master"),
PackageSpec(name="MultivariateMoments", rev="bl/exp"),
PackageSpec(name="PolyJuMP", rev="bl/sos"),
])
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
run: |
using Pkg
Pkg.add([
PackageSpec(name="MathOptInterface", rev="bl/set_map_type"),
PackageSpec(name="StarAlgebras", rev="bl/sos"),
PackageSpec(name="SymbolicWedderburn", rev="mk/StarAlgebras_0_3"),
PackageSpec(name="MultivariateBases", rev="bl/sos"),
PackageSpec(name="SemialgebraicSets", rev="master"),
PackageSpec(name="MultivariateMoments", rev="master"),
PackageSpec(name="PolyJuMP", rev="master"),
PackageSpec(path=pwd()),
])
Pkg.instantiate()
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ jobs:
run: |
using Pkg
Pkg.add([
PackageSpec(name="MathOptInterface", rev="bl/set_map_type"),
PackageSpec(name="StarAlgebras", rev="bl/sos"),
PackageSpec(name="SymbolicWedderburn", rev="mk/StarAlgebras_0_3"),
PackageSpec(name="MultivariateBases", rev="bl/sos"),
PackageSpec(name="SemialgebraicSets", rev="master"),
PackageSpec(name="MultivariateMoments", rev="master"),
PackageSpec(name="PolyJuMP", rev="master"),
PackageSpec(path=pwd()),
])
Pkg.instantiate()
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PolyJuMP = "ddf597a6-d67e-5340-b84c-e37d84115374"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SemialgebraicSets = "8e049039-38e8-557d-ae3a-bc521ccf6204"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StarAlgebras = "0c0c59c1-dc5f-42e9-9a8b-b5dc384a6cd1"
SymbolicWedderburn = "858aa9a9-4c7c-4c62-b466-2421203962a2"

[compat]
Expand All @@ -29,5 +30,5 @@ MutableArithmetics = "1"
PolyJuMP = "0.7"
Reexport = "0.2, 1.0"
SemialgebraicSets = "0.3"
SymbolicWedderburn = "0.3"
SymbolicWedderburn = "0.4"
julia = "1.6"
2 changes: 1 addition & 1 deletion bench/sos_polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function sos_polynomial(n)
@polyvar x
monos = monomials(x, 0:2n)
set = SumOfSquares.SOSPolynomialSet(
SumOfSquares.FullSpace(), monos,
SumOfSquares.FullSpace(), MB.SubBasis{MB.Monomial}(monos),
SumOfSquares.Certificate.Remainder(
SumOfSquares.SOSCone(),
SumOfSquares.MonomialBasis,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ where `α` and `β` are JuMP decision variables and `x` and `y` are polynomial
variables. Since the polynomial is a quadratic form, the sum-of-squares
certificate is also a quadratic form (see [Blekherman2012; Section~3.3.4](@cite)). Hence the
default polynomial basis used for the [Nonnegative polynomial variables]
certificate is `MonomialBasis([x, y])`, that is, we search for a positive
certificate is `MultivariateBases.SubBasis{MultivariateBases.Monomial}([x, y])`, that is, we search for a positive
semidefinite matrix `Q` such that
```math
\alpha x^2 + \beta y^2 - (\alpha - \beta) x y = X^\top Q X
Expand All @@ -164,7 +164,7 @@ As the polynomial space is determined by the polynomial being constrained,
only the basis *type* needs to be given. For instance, to use the scaled monomial
basis in the example above, use
```jldoctest constraint-xy
julia> @constraint(model, α * x^2 + β * y^2 ≥ (α - β) * x * y, basis = ScaledMonomialBasis)
julia> @constraint(model, α * x^2 + β * y^2 ≥ (α - β) * x * y, basis = ScaledMonomial)
(β)y² + (-α + β)xy + (α)x² is SOS
```

Expand Down
8 changes: 4 additions & 4 deletions docs/src/tutorials/Extension/certificate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ solution_summary(model)
import MultivariateBases as MB
const SOS = SumOfSquares
const SOSC = SOS.Certificate
struct Schmüdgen{IC <: SOSC.AbstractIdealCertificate, CT <: SOS.SOSLikeCone, BT <: SOS.AbstractPolynomialBasis} <: SOSC.AbstractPreorderCertificate
struct Schmüdgen{IC<:SOSC.AbstractIdealCertificate,CT<:SOS.SOSLikeCone,B<:SA.AbstractBasis} <: SOSC.AbstractPreorderCertificate
ideal_certificate::IC
cone::CT
basis::Type{BT}
basis::B
maxdegree::Int
end

Expand All @@ -78,8 +78,8 @@ function SOSC.multiplier_basis(certificate::Schmüdgen, index::SOSC.PreorderInde
q = SOSC.generator(certificate, index, domain)
return SOSC.maxdegree_gram_basis(certificate.basis, variables(domain), SOSC.multiplier_maxdegree(certificate.maxdegree, q))
end
function SOSC.multiplier_basis_type(::Type{Schmüdgen{IC, CT, BT}}) where {IC, CT, BT}
return BT
function SOSC.multiplier_basis_type(::Type{Schmüdgen{IC, CT, BT}}, ::Type{M}) where {IC,CT,BT,M}
return MB.similar_type(BT, M)
end

function SOSC.generator(::Schmüdgen, index::SOSC.PreorderIndex, domain::SOSC.WithVariables)
Expand Down
30 changes: 30 additions & 0 deletions src/Bridges/Bridges.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
module Bridges

import MathOptInterface as MOI
import SumOfSquares as SOS

include("Variable/Variable.jl")
include("Constraint/Constraint.jl")

function MOI.get(
model::MOI.ModelLike,
attr::Union{
SOS.GramMatrixAttribute,
SOS.MomentMatrixAttribute,
SOS.SOSDecompositionAttribute,
},
bridge::MOI.Bridges.Constraint.VectorSlackBridge,
)
return MOI.get(model, attr, bridge.slack_in_set)
end

# TODO bridges should redirect to `MOI.get_fallback` as well so that
# we can just use `Union{MOI.ConstraintIndex,MOI.Bridges.AbstractBridge}` in the `get_fallback` in `attributes.jl`
function MOI.get(
model::MOI.ModelLike,
attr::SOS.SOSDecompositionAttribute,
bridge::Union{
Variable.KernelBridge,
Constraint.ImageBridge,
Constraint.SOSPolynomialInSemialgebraicSetBridge,
},
)
gram = MOI.get(model, SOS.GramMatrixAttribute(attr.result_index), bridge)
return SOS.SOSDecomposition(gram, attr.ranktol, attr.dec)
end

end
16 changes: 1 addition & 15 deletions src/Bridges/Constraint/Constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Constraint
using LinearAlgebra

import MutableArithmetics as MA
import StarAlgebras as SA

import MathOptInterface as MOI

Expand All @@ -26,19 +27,4 @@ include("image.jl")
include("sos_polynomial.jl")
include("sos_polynomial_in_semialgebraic_set.jl")

# TODO bridges should redirect to `MOI.get_fallback` as well so that
# we can just use `Union{MOI.ConstraintIndex,MOI.Bridges.AbstractBridge}` in the `get_fallback` in `attributes.jl`
function MOI.get(
model::MOI.ModelLike,
attr::SOS.SOSDecompositionAttribute,
bridge::Union{
ImageBridge,
SOSPolynomialBridge,
SOSPolynomialInSemialgebraicSetBridge,
},
)
gram = MOI.get(model, SOS.GramMatrixAttribute(attr.result_index), bridge)
return SOS.SOSDecomposition(gram, attr.ranktol, attr.dec)
end

end
13 changes: 9 additions & 4 deletions src/Bridges/Constraint/image.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ function MOI.Bridges.Constraint.bridge_constraint(
MOI.Utilities.operate_output_index!(-, T, k, f, var)
else
found[mono] = k
t = MP.searchsortedfirst(set.basis.monomials, mono)
if t in eachindex(set.basis.monomials) &&
set.basis.monomials[t] == mono
t = MB.monomial_index(set.basis, mono)
if !isnothing(t)
first[t] = k
if is_diag
MOI.Utilities.operate_output_index!(
Expand Down Expand Up @@ -168,7 +167,13 @@ end
function MOI.supports_constraint(
::Type{ImageBridge{T}},
::Type{<:MOI.AbstractVectorFunction},
::Type{<:SOS.WeightedSOSCone{M,<:MB.MonomialBasis,<:MB.MonomialBasis}},
::Type{
<:SOS.WeightedSOSCone{
M,
<:MB.SubBasis{MB.Monomial},
<:MB.SubBasis{MB.Monomial},
},
},
) where {T,M}
return true
end
Expand Down
Loading
Loading