@@ -32,8 +32,13 @@ solution_summary(model)
3232# We can look at the certificate that `σ = -6` is a lower bound:
3333
3434sos_dec = sos_decomposition (cref, 1e-4 )
35+ expected = x^ 2 - 2 x - 3 # src
36+ @test isapprox (sos_dec. ps, [expected], rtol= 1e-4 ) || isapprox (sos_dec. ps, [- expected], rtol= 1e-4 ) # src
3537
3638# Indeed, `p + 6 = (x^2 - 2x - 3)^2` so `p ≥ -6`.
39+ #
40+ # ## Extraction of minimizers
41+ #
3742# We can now find the minimizers from the moment matrix:
3843
3944ν = moment_matrix (cref)
@@ -63,3 +68,34 @@ Q12 = η1.Q * η.atoms[1].weight + η2.Q * η.atoms[2].weight
6368
6469# Another way to see this (by linearity of the expectation) is that `ν` is the moment matrix
6570# of the convex combination of the two atomic measures.
71+
72+ # ## Changing the polynomial basis
73+ #
74+ # The monomial basis used by default can leave a problem quite ill-conditioned for the solver.
75+ # Let's try to use another basis instead:
76+
77+ model = SOSModel (CSDP. Optimizer)
78+ @variable (model, σ)
79+ @constraint (model, cheby_cref, p >= σ, basis = ChebyshevBasisFirstKind)
80+ @objective (model, Max, σ)
81+ optimize! (model)
82+ solution_summary (model)
83+
84+ # Although the gram matrix in the monomial basis:
85+
86+ g = gram_matrix (cref)
87+ @show g. basis
88+ g. Q
89+
90+ # looks different from the gram matrix in the Chebyshev basis:
91+
92+ cheby_g = gram_matrix (cheby_cref)
93+ @show cheby_g. basis
94+ cheby_g. Q
95+
96+ @test polynomial (g) ≈ polynomial (cheby_g) rtol= 1e-4 # src
97+
98+ # they both yields the same Sum-of-Squares decomposition:
99+
100+ cheby_sos_dec = sos_decomposition (cheby_cref, 1e-4 )
101+ @test isapprox (cheby_sos_dec. ps, [expected], rtol= 1e-4 ) || isapprox (cheby_sos_dec. ps, [- expected], rtol= 1e-4 ) # src
0 commit comments