SumOfSquares.jl
SumOfSquares.jl copied to clipboard
Add an example with hypercube constraint
The following is infeasible:
using DynamicPolynomials
using SumOfSquares
using MosekTools
solver = optimizer_with_attributes(Mosek.Optimizer, MOI.Silent() => false)
model = SOSModel(solver);
@polyvar x
V = 1 + x
S = @set x^2 == 1
@variable(model, γ)
@constraint(model, V <= γ, domain = S)
@objective(model, Min, γ)
optimize!(model)
@show termination_status(model)
moment_matrix(c)
It's a bit counter-intuitive and we should mention something in the docs and have an example.
What happens is that the monomials of V - γ are [x, 1] so the newton polytope method find [1] which does not work.
Using maxdegree solves the issue, we should mention the importance of maxdegree when there is equalities in the domain.
using DynamicPolynomials
using SumOfSquares
using MosekTools
solver = optimizer_with_attributes(Mosek.Optimizer, MOI.Silent() => false)
model = SOSModel(solver);
n = 1
@polyvar x[1:n]
V = 1 + sum(x)
S = algebraicset([x[i]^2 - 1 for i in 1:n])
@variable(model, γ)
c = @constraint(model, V <= γ, domain = S, maxdegree = 2)
@objective(model, Min, γ)
optimize!(model)
@show termination_status(model)
gram_matrix(c)
Moreover, it's unclear how to create the hypercube from a vector of x. We should have an example with algebraicset and mention something in the doc