PolyJuMP.jl is a JuMP extension for formulating and solving polynomial optimization problems. This extension includes the following:
- Polynomial functions on JuMP decisions variables. These can be solved with the
PolyJuMP.QCQP.OptimizerorPolyJuMP.KKT.Optimizer. - Constraints that a polynomial is nonnegative where the coefficients of the polynomials depend on JuMP decision variables.
These nonnegativity constraints can be reformulated using sufficient conditions using
PolyJuMP.RelativeEntropysubmodule or SumOfSquares.jl.
PolyJuMP.jl is licensed under the MIT license.
Install PolyJuMP using Pkg.add:
import Pkg
Pkg.add("PolyJuMP")PolyJuMP allows encoding a constraint that a polynomial should be zero for all values of some
symbolic variables defined with DynamicPolynomials.@polyvar or TypedPolynomials.@polyvar.
For instance, the following constrains the JuMP decision variable a to be such that
a * x - y is zero for all real values of x and y, i.e., all its coefficients are zero,
which is infeasible:
using DynamicPolynomials
@polyvar x y
using JuMP
import PolyJuMP
model = Model()
@variable(model, a)
@constraint(model, a * x == y)The polynomial can instead be constrained to be zero only on an algebraic set,
given with the domain keyword:
using SemialgebraicSets
V = @set x * y == 1 && y^2 == 1
@constraint(model, a * x == y, domain = V)This is encoded by constraining a * x - y to be in the ideal generated by the equalities h_1, ..., h_m of V,
i.e., to be a combination λ_1 * h_1 + ... + λ_m * h_m where the λ_i are polynomials.
Deciding this requires computing a Gröbner basis of the ideal, which can be very expensive.
So, unless the equalities are already known to be a Gröbner basis (e.g., for @set x == 1 && y == 2),
the degree of each λ_i * h_i is limited to the maximum of the degree of the polynomial and of the equalities, i.e., 2 here,
and the constraint is encoded with the null space of the Macaulay matrix of the equalities of that degree.
This default is given by PolyJuMP.default_maxdegree and the truncation by PolyJuMP.truncated_domain.
This is consistent with the default maxdegree of the nonnegativity constraints of SumOfSquares.jl.
This may be too restrictive.
In the example above, x - y = y * (x * y - 1) - x * (y^2 - 1) vanishes on V
but its terms have degree 3 so the constraint is infeasible.
The degree can be increased with the maxdegree keyword:
@constraint(model, a * x == y, domain = V, maxdegree = 3)or equivalently with SemialgebraicSets.truncated:
@constraint(model, a * x == y, domain = SemialgebraicSets.truncated(V, 3))Alternatively, the Gröbner basis can be computed before adding the constraint, in which case the remainder of the polynomial modulo the Gröbner basis is constrained to be zero:
SemialgebraicSets.compute_gröbner_basis!(ideal(V))
@constraint(model, a * x == y, domain = V)Both constraints are satisfied by a = 1.
PolyJuMP allows encoding a constraint that a polynomial should be nonnegative for all values of some
symbolic variables defined with DynamicPolynomials.@polyvar or TypedPolynomials.@polyvar as follows.
For instance, the following constrains the JuMP decision variable a to be such that
a * x * y^2 + y^3 - a * x is nonnegative for all real values of x and y:
using DynamicPolynomials
@polyvar x y
using JuMP
model = Model()
@variable(model, a)
@constraint(model, a * x * y^2 + y^3 >= a * x)Determining the nonnegativity of a multivariate polynomial is however NP-hard so sufficient conditions are used instead. You need to specify which sufficient condition is used explicitly. To use Sum-of-Arithmetic-Geometric-Exponentials (SAGE), use
import PolyJuMP
PolyJuMP.setpolymodule!(model, PolyJuMP.SAGE)To use Sum-of-Squares (SOS), use
import SumOfSquares
PolyJuMP.setpolymodule!(model, SumOfSquares)or replace model = Model() by model = SOSModel().
Alternatively, the nonnegativity constraint can be explicit:
@constraint(model, a * x * y^2 + y^3 - a * x in PolyJuMP.SAGE.Polynomials())
@constraint(model, a * x * y^2 + y^3 - a * x in SumOfSquares.SOSCone())This allows mixing SAGE and SOS constraints in the same model.
PolyJuMP also allows solving polynomial optimization problems using the QCQP, KKT and SAGE solvers.
Polynomial optimization problems do not involve any symbolic variables from DynamicPolynomials or TypedPolynomials,
instead all variables are JuMP decision variables.
The QCQP solver is parametrized by a nonconvex QCQP inner solver.
It reformulates the polynomial optimization problem into a nonconvex QCQP
and relies on the inner solver to solve it.
For instance, to use the QCQP solver with JuMP with Gurobi.Optimizer as inner solver, use:
using JuMP, PolyJuMP, Gurobi
model = Model(() -> PolyJuMP.QCQP.Optimizer(Gurobi.Optimizer))The KKT solver is parametrized by an inner solver of algebraic systems of equations implementing the SemialgebraicSets interface.
It reformulates the polynomial optimization problem into a system of polynomial equations
and relies on the inner solver to solve it.
For instance, to use the QCQP solver with JuMP with
HomotopyContinuation.SemialgebraicSetsHCSolver as inner solver, use:
using JuMP, PolyJuMP, HomotopyContinuation
model = Model(optimizer_with_attributes(
PolyJuMP.KKT.Optimizer,
"solver" => HomotopyContinuation.SemialgebraicSetsHCSolver(),
))The SAGE solver computes a bound on the optimal objective value using the
SAGE relaxation of the problem [CP16, MCW21]: it certifies the nonnegativity
of the Lagrangian with the SAGE cone, using one SAGE multiplier for each
inequality constraint and one free polynomial multiplier for each equality
constraint.
It is parametrized by an inner solver for the resulting relative entropy
program. For instance, to compute a lower bound on the minimum of the Motzkin
polynomial with ECOS.Optimizer as inner solver, use:
using JuMP, PolyJuMP, ECOS
model = Model(() -> PolyJuMP.SAGE.Optimizer(ECOS.Optimizer))
@variable(model, x)
@variable(model, y)
@objective(model, Min, x^4 * y^2 + x^2 * y^4 + 1 - 3 * x^2 * y^2)
optimize!(model)
objective_bound(model) # ≈ 0The bound is returned as MOI.ObjectiveBound. In addition, candidate
solutions are recovered from the dual of the SAGE constraint, which is a
vector of pseudo-moments, following [MCW21, Section 4.2] (see also its
reference implementation poly_solrec in
sageopt); result_count(model)
gives the number of candidates found, sorted by feasibility and objective
value. In the example above, the four minimizers (±1, ±1) are recovered:
value(x; result = 1), value(y; result = 1) # ≈ (1, 1)The maximum degree of the multiplier of a constraint is chosen with the
PolyJuMP.MultiplierMaxdegree constraint attribute:
@constraint(model, con, x^2 >= 1)
MOI.set(model, PolyJuMP.MultiplierMaxdegree(), con, 2)The SumOfSquares.Optimizer of SumOfSquares.jl
is the analogous solver certifying the nonnegativity of the Lagrangian with
the SOS cone instead; increasing the PolyJuMP.MultiplierMaxdegree attributes
then gives the higher levels of the Lasserre hierarchy and the candidate
solutions are recovered from the atoms of the moment matrix given by the dual
of the SOS constraint, using
MultivariateMoments.
[CP16] Chandrasekaran, Venkat, and Parikshit Shah. Relative entropy relaxations for signomial optimization. SIAM Journal on Optimization 26.2 (2016): 1147-1173.
[MCW21] Murray, Riley, Venkat Chandrasekaran, and Adam Wierman. Signomials and polynomial optimization via relative entropy and partial dualization. Mathematical Programming Computation 13 (2021): 257-295. arXiv:1907.00814
Documentation for PolyJuMP.jl is included in the
documentation for SumOfSquares.jl.