-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: 6d12d36
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#= | ||
Copyright 2018, Chris Coey and contributors | ||
approximate integration (upper bound) of a polynomial over a basic semialgebraic set | ||
adapted from "Approximate volume and integration for basic semialgebraic sets" | ||
by Henrion, Lasserre, & Savorgnan (2009) | ||
https://pdfs.semanticscholar.org/893b/e70a990901d7b6b2f052cbcb5883a043b5d9.pdf | ||
=# | ||
|
||
import Hypatia | ||
const HYP = Hypatia | ||
const CO = HYP.Cones | ||
const MU = HYP.ModelUtilities | ||
|
||
import MathOptInterface | ||
const MOI = MathOptInterface | ||
import JuMP | ||
using LinearAlgebra | ||
import Random | ||
using Test | ||
|
||
function build_quadrature( | ||
d::Int, | ||
p, # polynomial parameter (in objective of moment problem; must be positive on K) | ||
K_dom::MU.Domain, | ||
B_dom::MU.Domain; # canonical set (for which we have quadrature weights) containing K_dom | ||
) | ||
# generate interpolation for K | ||
(U, pts, P0, PWts, _) = MU.interpolate(K_dom, d, sample = true, calc_w = false) | ||
|
||
# get quadrature weights for B | ||
y2 = MU.get_weights(B_dom, pts) | ||
|
||
# build JuMP model | ||
model = JuMP.Model(JuMP.with_optimizer(HYP.Optimizer, verbose = true)) | ||
JuMP.@variable(model, y1[1:U]) # moments of μ1 | ||
JuMP.@objective(model, Max, sum(y1[i] * p(pts[i, :]) for i in 1:U)) | ||
JuMP.@constraint(model, y1 in HYP.WSOSPolyInterpCone(U, [P0, PWts...], true)) | ||
JuMP.@constraint(model, y2 - y1 in HYP.WSOSPolyInterpCone(U, [P0], true)) | ||
|
||
return (model, y1, pts) | ||
end | ||
|
||
|