Skip to content

Commit 12a477a

Browse files
authored
Add QCQP polynomial optimization tutorial (#337)
1 parent 36c7849 commit 12a477a

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

docs/src/references.bib

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ @Book{Floudas1999
1010
journal = {Nonconvex Optimization and Its Applications},
1111
}
1212

13+
@Article{Hesse1973,
14+
author = {Hesse, Rick},
15+
journal = {Operations Research},
16+
title = {A Heuristic Search Procedure for Estimating a Global Solution of Nonconvex Programming Problems},
17+
year = {1973},
18+
issn = {1526-5463},
19+
month = dec,
20+
number = {6},
21+
pages = {1267--1280},
22+
volume = {21},
23+
doi = {10.1287/opre.21.6.1267},
24+
publisher = {Institute for Operations Research and the Management Sciences (INFORMS)},
25+
}
26+
1327
@Book{Lasserre2009,
1428
author = {Lasserre, Jean Bernard},
1529
publisher = {Imperial College Press},
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# # Nonconvex quadratically constrained quadratic programs
2+
3+
#md # [![](https://mybinder.org/badge_logo.svg)](@__BINDER_ROOT_URL__/generated/Polynomial Optimization/nonconvex_qcqp.ipynb)
4+
#md # [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](@__NBVIEWER_ROOT_URL__/generated/Polynomial Optimization/nonconvex_qcqp.ipynb)
5+
# **Adapted from**: [Hesse1973](@cite), [Floudas1999; Section 3.4](@cite), [Laurent2008; Example 6.22](@cite) and [Lasserre2009; Table 5.1](@cite)
6+
7+
# We consider the nonconvex Quadratically Constrained Quadratic Programs (QCQP)
8+
# introduced in [H73].
9+
# Consider now the polynomial optimization problem [Laurent2008; Example 6.22](@cite) of
10+
# maximizing the convex quadratic function
11+
# (hence nonconvex since convex programs should either maximize concave functions
12+
# or minimize convex functions)
13+
# $25(x_1 - 2)^2 + (x_2 - 2)^2 + (x_3 - 1)^2 + (x_4 - 4)^2 + (x_5 - 1)^2 + (x_6 - 4)^2$
14+
# over the basic semialgebraic set defined by the nonconvex quadratic inequalities
15+
# $(x_3 - 3)^2 + x_4 \ge 4$,
16+
# $(x_5 - 3)^2 + x_6 \ge 4$,
17+
# and linear inequalities
18+
# $x_1 - 3x_2 \le 2$,
19+
# $-x_1 + x_2 \le 2$,
20+
# $2 \le x_1 + x_2 \le 6$,
21+
# $0 \le x_1, x_2$,
22+
# $1 \le x_3 \le 5$,
23+
# $0 \le x_4 \le 6$,
24+
# $1 \le x_5 \le 5$,
25+
# $0 \le x_6 \le 10$,
26+
# $x_2 \le 4x_1^4 - 32x_1^3 + 88x_1^2 - 96x_1 + 36$ and the box constraints
27+
# $0 \le x_1 \le 3$ and $0 \le x_2 \le 4$,
28+
29+
using Test #src
30+
using DynamicPolynomials
31+
@polyvar x[1:6]
32+
centers = [2, 2, 1, 4, 1, 4]
33+
weights = [25, 1, 1, 1, 1, 1]
34+
p = -weights' * (x .- centers).^2
35+
using SumOfSquares
36+
K = @set x[1] >= 0 && x[2] >= 0 &&
37+
x[3] >= 1 && x[3] <= 5 &&
38+
x[4] >= 0 && x[4] <= 6 &&
39+
x[5] >= 1 && x[5] <= 5 &&
40+
x[6] >= 0 && x[6] <= 10 &&
41+
(x[3] - 3)^2 + x[4] >= 4 &&
42+
(x[5] - 3)^2 + x[6] >= 4 &&
43+
x[1] - 3x[2] <= 2 &&
44+
-x[1] + x[2] <= 2 &&
45+
x[1] + x[2] <= 6 &&
46+
x[1] + x[2] >= 2
47+
48+
# We will now see how to find the optimal solution using Sum of Squares Programming.
49+
# We first need to pick an SDP solver, see [here](https://jump.dev/JuMP.jl/v1.12/installation/#Supported-solvers) for a list of the available choices.
50+
51+
import Clarabel
52+
solver = Clarabel.Optimizer
53+
54+
# A Sum-of-Squares certificate that $p \ge \alpha$ over the domain `S`, ensures that $\alpha$ is a lower bound to the polynomial optimization problem.
55+
# The following function searches for the largest lower bound and finds zero using the `d`th level of the hierarchy`.
56+
57+
function solve(d)
58+
model = SOSModel(solver)
59+
@variable(model, α)
60+
@objective(model, Max, α)
61+
@constraint(model, c, p >= α, domain = K, maxdegree = d)
62+
optimize!(model)
63+
println(solution_summary(model))
64+
return model
65+
end
66+
67+
# The first level of the hierarchy cannot find any lower bound.
68+
69+
model2 = solve(2)
70+
nothing # hide
71+
@test termination_status(model2) == MOI.INFEASIBLE #src
72+
73+
# The second level of the hierarchy finds the lower bound of `-310`.
74+
75+
model3 = solve(4)
76+
nothing # hide
77+
@test termination_status(model3) == MOI.OPTIMAL #src
78+
@test objective_value(model3) -310 rtol=1e-4 #src

0 commit comments

Comments
 (0)