Even reduction

using DynamicPolynomials
@polyvar x
(x,)

We would like to find the minimum value of the following polynomial:

poly = x^4 - 2x^2

using SumOfSquares

We define the custom action as follows:

struct OnSign <: Symmetry.OnMonomials end
using PermutationGroups
import SymbolicWedderburn
SymbolicWedderburn.coeff_type(::OnSign) = Float64
function SymbolicWedderburn.action(::OnSign, p::Permutation, mono::AbstractMonomial)
    if isone(p) || iseven(DynamicPolynomials.degree(mono))
        return 1 * mono
    else
        @assert p.perm == perm"(1,2)"
        return -1 * mono
    end
end
G = PermGroup([perm"(1,2)"])
Permutation group on 1 generator generated by
 (1,2)

We can exploit the symmetry as follows:

import CSDP
solver = CSDP.Optimizer
model = Model(solver)
@variable(model, t)
@objective(model, Max, t)
pattern = Symmetry.Pattern(G, OnSign())
con_ref = @constraint(model, poly - t in SOSCone(), symmetry = pattern)
optimize!(model)
value(t)
-1.000000007084374

We indeed find -1, let's verify that symmetry was exploited:

gram_matrix(con_ref)
BlockDiagonalGramMatrix with 2 blocks:
[1] Block with row/column basis:
     FixedPolynomialBasis([1.0, x^2])
    And entries in a 2×2 SymMatrix{Float64}:
      1.0000000070844732  -1.0000000020056958
     -1.0000000020056958   1.0000000000000828
[2] Block with row/column basis:
     FixedPolynomialBasis([x])
    And entries in a 1×1 SymMatrix{Float64}:
     4.011410529947057e-9

This page was generated using Literate.jl.