@@ -31,23 +31,19 @@ const Index = Union{PreorderIndex, IdealIndex}
31
31
abstract type Attribute end
32
32
33
33
# For get
34
- struct Cone <: Attribute end
35
- struct GramBasis <: Attribute end
34
+ function cone end
35
+ function gram_basis end
36
36
# FIXME currently, this returns `MB.MonomialBasis` instead of `MB.MonomialBasis{MT, MVT}`
37
- struct GramBasisType <: Attribute end
38
- struct ReducedPolynomial <: Attribute end
39
- struct IdealCertificate <: Attribute end
40
- struct PreprocessedDomain <: Attribute end
37
+ function gram_basis_type end
38
+ function reduced_polynomial end
39
+ function ideal_certificate end
40
+ function preprocessed_domain end
41
41
42
42
# Only for PreorderIndex
43
- struct PreorderIndices <: Attribute end
44
- struct Generator <: Attribute end
45
- struct MultiplierBasis <: Attribute end
46
- struct MultiplierBasisType <: Attribute end
47
-
48
- # For set
49
- # struct Monomials <: Attribute end
50
-
43
+ function preorder_indices end
44
+ function generator end
45
+ function multiplier_basis end
46
+ function multiplier_basis_type end
51
47
52
48
# PreorderCertificate
53
49
# IdealCertificate
@@ -80,40 +76,40 @@ struct Putinar{IC <: AbstractIdealCertificate, CT <: SumOfSquares.SOSLikeCone, B
80
76
maxdegree:: Int
81
77
end
82
78
83
- get (certificate:: Putinar , :: Cone ) = certificate. cone
79
+ cone (certificate:: Putinar ) = certificate. cone
84
80
85
81
struct DomainWithVariables{S, V}
86
82
domain:: S
87
83
variables:: V
88
84
end
89
- function get (:: Putinar , :: PreprocessedDomain , domain:: BasicSemialgebraicSet , p)
85
+ function preprocessed_domain (:: Putinar , domain:: BasicSemialgebraicSet , p)
90
86
return DomainWithVariables (domain, MP. variables (p))
91
87
end
92
88
93
- function get (:: Putinar , :: PreorderIndices , domain:: DomainWithVariables )
89
+ function preorder_indices (:: Putinar , domain:: DomainWithVariables )
94
90
return map (PreorderIndex, eachindex (domain. domain. p))
95
91
end
96
92
97
93
function maxdegree_gram_basis (B:: Type , variables, maxdegree:: Int )
98
94
return MB. maxdegree_basis (B, variables, div (maxdegree, 2 ))
99
95
end
100
96
multiplier_maxdegree (maxdegree, q) = maxdegree - MP. maxdegree (q)
101
- function get (certificate:: Putinar , :: MultiplierBasis , index:: PreorderIndex , domain:: DomainWithVariables )
97
+ function multiplier_basis (certificate:: Putinar , index:: PreorderIndex , domain:: DomainWithVariables )
102
98
q = domain. domain. p[index. value]
103
99
vars = sort! ([domain. variables... , MP. variables (q)... ], rev = true )
104
100
unique! (vars)
105
101
return maxdegree_gram_basis (certificate. basis, vars, multiplier_maxdegree (certificate. maxdegree, q))
106
102
end
107
- function get (:: Type{Putinar{IC, CT, BT}} , :: MultiplierBasisType ) where {IC, CT, BT}
103
+ function multiplier_basis_type (:: Type{Putinar{IC, CT, BT}} ) where {IC, CT, BT}
108
104
return BT
109
105
end
110
106
111
- function get (:: Putinar , :: Generator , index:: PreorderIndex , domain:: DomainWithVariables )
107
+ function generator (:: Putinar , index:: PreorderIndex , domain:: DomainWithVariables )
112
108
return domain. domain. p[index. value]
113
109
end
114
110
115
- get (certificate:: Putinar , :: IdealCertificate ) = certificate. ideal_certificate
116
- get (:: Type{<:Putinar{IC}} , :: IdealCertificate ) where {IC} = IC
111
+ ideal_certificate (certificate:: Putinar ) = certificate. ideal_certificate
112
+ ideal_certificate (:: Type{<:Putinar{IC}} ) where {IC} = IC
117
113
118
114
SumOfSquares. matrix_cone_type (:: Type{<:Putinar{IC, CT}} ) where {IC, CT} = SumOfSquares. matrix_cone_type (CT)
119
115
@@ -122,9 +118,9 @@ SumOfSquares.matrix_cone_type(::Type{<:Putinar{IC, CT}}) where {IC, CT} = SumOfS
122
118
# #####################
123
119
124
120
abstract type SimpleIdealCertificate{CT, BT} <: AbstractIdealCertificate end
125
- get (:: SimpleIdealCertificate , :: ReducedPolynomial , poly, domain) = poly
121
+ reduced_polynomial (:: SimpleIdealCertificate , poly, domain) = poly
126
122
127
- get (certificate:: SimpleIdealCertificate , :: Cone ) = certificate. cone
123
+ cone (certificate:: SimpleIdealCertificate ) = certificate. cone
128
124
SumOfSquares. matrix_cone_type (:: Type{<:SimpleIdealCertificate{CT}} ) where {CT} = SumOfSquares. matrix_cone_type (CT)
129
125
130
126
# TODO return something else when `PolyJuMP` support other bases.
@@ -150,10 +146,10 @@ struct MaxDegree{CT <: SumOfSquares.SOSLikeCone, BT <: MB.AbstractPolynomialBasi
150
146
basis:: Type{BT}
151
147
maxdegree:: Int
152
148
end
153
- function get (certificate:: MaxDegree , :: GramBasis , poly) where CT
149
+ function gram_basis (certificate:: MaxDegree , poly) where CT
154
150
return maxdegree_gram_basis (certificate. basis, MP. variables (poly), certificate. maxdegree)
155
151
end
156
- function get (:: Type{MaxDegree{CT, BT}} , :: GramBasisType ) where {CT, BT}
152
+ function gram_basis_type (:: Type{MaxDegree{CT, BT}} ) where {CT, BT}
157
153
return BT
158
154
end
159
155
@@ -173,10 +169,10 @@ struct FixedBasis{CT <: SumOfSquares.SOSLikeCone, BT <: MB.AbstractPolynomialBas
173
169
cone:: CT
174
170
basis:: BT
175
171
end
176
- function get (certificate:: FixedBasis , :: GramBasis , poly) where CT
172
+ function gram_basis (certificate:: FixedBasis , poly) where CT
177
173
return certificate. basis
178
174
end
179
- function get (:: Type{FixedBasis{CT, BT}} , :: GramBasisType ) where {CT, BT}
175
+ function gram_basis_type (:: Type{FixedBasis{CT, BT}} ) where {CT, BT}
180
176
return BT
181
177
end
182
178
@@ -201,10 +197,10 @@ struct Newton{CT <: SumOfSquares.SOSLikeCone, BT <: MB.AbstractPolynomialBasis,
201
197
basis:: Type{BT}
202
198
variable_groups:: NPT
203
199
end
204
- function get (certificate:: Newton{CT, B} , :: GramBasis , poly) where {CT, B}
200
+ function gram_basis (certificate:: Newton{CT, B} , poly) where {CT, B}
205
201
return MB. basis_covering_monomials (B, monomials_half_newton_polytope (MP. monomials (poly), certificate. variable_groups))
206
202
end
207
- function get (:: Type{<:Newton{CT, BT}} , :: GramBasisType ) where {CT, BT}
203
+ function gram_basis_type (:: Type{<:Newton{CT, BT}} ) where {CT, BT}
208
204
return BT
209
205
end
210
206
@@ -228,18 +224,18 @@ struct Remainder{GCT<:AbstractIdealCertificate} <: AbstractIdealCertificate
228
224
gram_certificate:: GCT
229
225
end
230
226
231
- function get (:: Remainder , :: ReducedPolynomial , poly, domain)
227
+ function reduced_polynomial (:: Remainder , poly, domain)
232
228
return convert (typeof (poly), rem (poly, ideal (domain)))
233
229
end
234
230
235
- function get (certificate:: Remainder , attr :: GramBasis , poly)
236
- return get (certificate. gram_certificate, attr , poly)
231
+ function gram_basis (certificate:: Remainder , poly)
232
+ return gram_basis (certificate. gram_certificate, poly)
237
233
end
238
- function get (:: Type{Remainder{GCT}} , attr :: GramBasisType ) where GCT
239
- return get (GCT, attr )
234
+ function gram_basis_type (:: Type{Remainder{GCT}} ) where GCT
235
+ return gram_basis_type (GCT)
240
236
end
241
237
242
- get (certificate:: Remainder , attr :: Cone ) = get (certificate. gram_certificate, attr )
238
+ cone (certificate:: Remainder ) = cone (certificate. gram_certificate)
243
239
SumOfSquares. matrix_cone_type (:: Type{Remainder{GCT}} ) where {GCT} = SumOfSquares. matrix_cone_type (GCT)
244
240
zero_basis (certificate:: Remainder ) = zero_basis (certificate. gram_certificate)
245
241
zero_basis_type (:: Type{Remainder{GCT}} ) where {GCT} = zero_basis_type (GCT)
0 commit comments