Skip to content

Commit 02bfd28

Browse files
committed
Fixes
1 parent 5e69887 commit 02bfd28

File tree

7 files changed

+27
-46
lines changed

7 files changed

+27
-46
lines changed

src/Bridges/Constraint/sos_polynomial.jl

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ struct SOSPolynomialBridge{
33
F<:MOI.AbstractVectorFunction,
44
DT<:SemialgebraicSets.AbstractSemialgebraicSet,
55
M, # matrix cone type
6+
BT,
67
B,
78
G<:SA.ExplicitBasis,
89
CT<:SOS.Certificate.AbstractIdealCertificate,
9-
MT<:MP.AbstractMonomial,
10-
MVT<:AbstractVector{MT},
1110
W<:SA.AlgebraElement,
1211
} <: MOI.Bridges.Constraint.SetMapBridge{
1312
T,
1413
SOS.WeightedSOSCone{M,B,G,W},
15-
SOS.SOSPolynomialSet{DT,MB.SubBasis{MB.Monomial,MT,MVT},CT},
14+
SOS.SOSPolynomialSet{DT,BT,CT},
1615
F,
1716
F,
1817
}
1918
constraint::MOI.ConstraintIndex{F,SOS.WeightedSOSCone{M,B,G,W}}
20-
set::SOS.SOSPolynomialSet{DT,MB.SubBasis{MB.Monomial,MT,MVT},CT}
19+
set::SOS.SOSPolynomialSet{DT,BT,CT}
2120
new_basis::B
2221
flat_indices::Union{Int,Base.UnitRange{Int}}
2322
end
@@ -42,11 +41,11 @@ function _flatten(
4241
end
4342

4443
function MOI.Bridges.Constraint.bridge_constraint(
45-
::Type{SOSPolynomialBridge{T,F,DT,M,B,G,CT,MT,MVT,W}},
44+
::Type{SOSPolynomialBridge{T,F,DT,M,BT,B,G,CT,W}},
4645
model::MOI.ModelLike,
4746
func::MOI.AbstractVectorFunction,
4847
set::SOS.SOSPolynomialSet{<:SemialgebraicSets.AbstractAlgebraicSet},
49-
) where {T,F,DT,M,B,G,CT,MT,MVT,W}
48+
) where {T,F,DT,M,BT,B,G,CT,W}
5049
@assert MOI.output_dimension(func) == length(set.basis)
5150
# As `*(::MOI.ScalarAffineFunction{T}, ::S)` is only defined if `S == T`, we
5251
# need to call `similar`. This is critical since `T` is
@@ -82,7 +81,7 @@ function MOI.Bridges.Constraint.bridge_constraint(
8281
MOI.Utilities.vectorize(new_coeffs),
8382
SOS.WeightedSOSCone{M}(new_basis, flat_gram_bases, flat_weights),
8483
)
85-
return SOSPolynomialBridge{T,F,DT,M,B,G,CT,MT,MVT,W}(
84+
return SOSPolynomialBridge{T,F,DT,M,BT,B,G,CT,W}(
8685
constraint,
8786
set,
8887
new_basis,
@@ -104,23 +103,22 @@ _eltype(::Type{T}) where T = T
104103
function MOI.Bridges.Constraint.concrete_bridge_type(
105104
::Type{<:SOSPolynomialBridge{T}},
106105
F::Type{<:MOI.AbstractVectorFunction},
107-
::Type{SOS.SOSPolynomialSet{DT,MB.SubBasis{MB.Monomial,MT,MVT},CT}},
108-
) where {T,DT<:SemialgebraicSets.AbstractAlgebraicSet,MT,MVT,CT}
106+
::Type{SOS.SOSPolynomialSet{DT,BT,CT}},
107+
) where {T,DT<:SemialgebraicSets.AbstractAlgebraicSet,BT,CT}
109108
# promotes VectorOfVariables into VectorAffineFunction, it should be enough
110109
# for most use cases
111110
M = SOS.matrix_cone_type(CT)
112-
B = MB.SubBasis{MB.Monomial,MT,MVT}
113-
W = SA.AlgebraElement{MB.algebra_type(B),T,Vector{T}}
114-
R = MA.promote_operation(
111+
W = SA.AlgebraElement{MB.algebra_type(BT),T,Vector{T}}
112+
B = MA.promote_operation(
115113
SOS.Certificate.reduced_basis,
116114
CT,
117-
B,
115+
BT,
118116
SemialgebraicSets.similar_type(DT, T),
119-
Vector{MB.SubBasis{MB.Monomial,MT,MVT}},
117+
Vector{BT},
120118
Vector{W},
121119
)
122-
G = SOS.Certificate.gram_basis_type(CT, MT)
123-
return SOSPolynomialBridge{T,F,DT,M,R,_eltype(G),CT,MT,MVT,W}
120+
G = SOS.Certificate.gram_basis_type(CT)
121+
return SOSPolynomialBridge{T,F,DT,M,BT,B,_eltype(G),CT,W}
124122
end
125123

126124
function MOI.Bridges.inverse_map_function(::SOSPolynomialBridge, f)

src/Certificate/Sparsity/ideal.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ function SumOfSquares.Certificate.gram_basis(certificate::Ideal, poly)
8585
end
8686
function SumOfSquares.Certificate.gram_basis_type(
8787
::Type{Ideal{S,C}},
88-
::Type{M},
89-
) where {S,C,M}
90-
return Vector{SumOfSquares.Certificate.gram_basis_type(C, M)}
88+
) where {S,C}
89+
return Vector{SumOfSquares.Certificate.gram_basis_type(C)}
9190
end
9291
function SumOfSquares.Certificate.reduced_polynomial(
9392
certificate::Ideal,

src/Certificate/Symmetry/wedderburn.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ function SumOfSquares.matrix_cone_type(::Type{<:Ideal{C}}) where {C}
7777
end
7878
function SumOfSquares.Certificate.gram_basis_type(
7979
::Type{<:Ideal},
80-
::Type{M},
81-
) where {M}
80+
)
8281
return Vector{Vector{MB.FixedPolynomialBasis}}
8382
end
8483
SumOfSquares.Certificate.zero_basis_type(::Type{<:Ideal}) = MB.Monomial

src/Certificate/ideal.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function gram_basis(certificate::MaxDegree, poly)
117117
certificate.maxdegree,
118118
)
119119
end
120-
function gram_basis_type(::Type{MaxDegree{C,B}}, ::Type{M}) where {C,B,M} # TODO remove `M` it's not needed anymore
120+
function gram_basis_type(::Type{MaxDegree{C,B}}) where {C,B}
121121
return MB.explicit_basis_type(B)
122122
end
123123

@@ -141,7 +141,7 @@ end
141141
function gram_basis(certificate::FixedBasis, _)
142142
return certificate.basis
143143
end
144-
gram_basis_type(::Type{FixedBasis{C,B}}, ::Type) where {C,B} = B
144+
gram_basis_type(::Type{FixedBasis{C,B}}) where {C,B} = B
145145

146146
"""
147147
struct Newton{
@@ -184,11 +184,11 @@ end
184184
function gram_basis(certificate::Newton, basis)
185185
return MB.basis_covering_monomials(
186186
certificate.basis,
187-
monomials_half_newton_polytope(SA.basis(basis), certificate.newton),
187+
half_newton_polytope(SA.basis(basis), certificate.newton),
188188
)
189189
end
190190

191-
function gram_basis_type(::Type{<:Newton{C,B}}, ::Type{M}) where {C,B,M}
191+
function gram_basis_type(::Type{<:Newton{C,B}}) where {C,B}
192192
return MB.explicit_basis_type(B)
193193
end
194194

@@ -233,8 +233,8 @@ function gram_basis(certificate::Remainder, poly)
233233
return gram_basis(certificate.gram_certificate, poly)
234234
end
235235

236-
function gram_basis_type(::Type{Remainder{GCT}}, ::Type{M}) where {GCT,M}
237-
return gram_basis_type(GCT, M)
236+
function gram_basis_type(::Type{Remainder{GCT}}) where {GCT}
237+
return gram_basis_type(GCT)
238238
end
239239

240240
cone(certificate::Remainder) = cone(certificate.gram_certificate)

src/Certificate/newton_polytope.jl

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function half_newton_polytope(X::AbstractVector, ::NewtonDegreeBounds{Tuple{}})
204204
end
205205
end
206206

207-
function half_newton_polytope(monos::AbstractVector, newton::NewtonFilter)
207+
function half_newton_polytope(basis::SA.ExplicitBasis, newton::NewtonFilter)
208208
gram_monos = half_newton_polytope(monos, newton.outer_approximation)
209209
return post_filter(gram_monos, monos)
210210
end
@@ -273,21 +273,6 @@ function post_filter(monos, X)
273273
return monos[findall(keep)]
274274
end
275275

276-
# FIXME update API with basis, this is a hack
277-
function monomials_half_newton_polytope(
278-
basis::MB.SubBasis{MB.Monomial},
279-
newton::AbstractNewtonPolytopeApproximation,
280-
)
281-
return half_newton_polytope(basis.monomials, newton)
282-
end
283-
284-
function monomials_half_newton_polytope(
285-
monos::AbstractVector,
286-
newton::AbstractNewtonPolytopeApproximation,
287-
)
288-
return half_newton_polytope(MP.monomial_vector(monos), newton)
289-
end
290-
291276
struct DegreeBounds{M}
292277
mindegree::Int
293278
maxdegree::Int

src/Certificate/preorder.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ function multiplier_basis(
144144
)
145145
return domain.bases[index.value]
146146
end
147-
function multiplier_basis_type(::Type{<:Putinar{MC}}, ::Type{M}) where {MC,M}
148-
return gram_basis_type(MC, M)
147+
function multiplier_basis_type(::Type{<:Putinar{MC}}) where {MC}
148+
return gram_basis_type(MC)
149149
end
150150

151151
function generator(

test/certificate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function certificate_api(certificate::Certificate.AbstractIdealCertificate)
204204
) isa Tuple
205205
_basis_check(
206206
Certificate.gram_basis(certificate, basis),
207-
Certificate.gram_basis_type(typeof(certificate), MP.monomial_type(x)),
207+
Certificate.gram_basis_type(typeof(certificate)),
208208
)
209209
zbasis = Certificate.zero_basis(certificate)
210210
@test zbasis isa SA.AbstractBasis

0 commit comments

Comments
 (0)