Skip to content

Commit 9d47ff7

Browse files
committed
adjust unfinished integration model
Former-commit-id: 54508d3
1 parent b3291b1 commit 9d47ff7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

examples/integration/jump.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ function build_quadrature(
2727
B_dom::MU.Domain,
2828
ppar,
2929
)
30-
# generate interpolation for K
31-
(U, pts, P0, PWts, _) = MU.interpolate(K_dom, d, sample = true, calc_w = false)
30+
# generate interpolation for B
31+
(U, pts, P0, PWts, w) = MU.interpolate(B_dom, d, sample = true, calc_w = true)
3232

33-
# get quadrature weights for B
33+
# get weights for B
3434
y2 = # TODO
3535

3636
# build JuMP model
3737
model = JuMP.Model(JuMP.with_optimizer(HYP.Optimizer, verbose = true))
38-
JuMP.@variable(model, y1[1:U]) # moments of μ1
39-
JuMP.@objective(model, Max, sum(y1[i] * ppar(pts[i, :]) for i in 1:U))
40-
JuMP.@constraint(model, y1 in HYP.WSOSPolyInterpCone(U, [P0, PWts...], true))
41-
JuMP.@constraint(model, y2 .- y1 in HYP.WSOSPolyInterpCone(U, [P0], true))
38+
JuMP.@variable(model, y[1:U]) # moments of μ1
39+
JuMP.@objective(model, Max, sum(y[i] * ppar(pts[i, :]) for i in 1:U))
40+
JuMP.@constraint(model, y in HYP.WSOSPolyInterpCone(U, [P0, PWts...], true))
41+
JuMP.@constraint(model, w - y in HYP.WSOSPolyInterpCone(U, [P0], true))
4242

43-
return (model, y1, pts)
43+
return (model, y, pts)
4444
end
4545

4646
function integrate_poly(
@@ -51,10 +51,10 @@ function integrate_poly(
5151
ppar, # polynomial as the parameter in objective of moment problem
5252
)
5353
# optimize to get quadrature weights
54-
(model, y1, pts) = build_quadrature(d, K_dom, B_dom, ppar)
54+
(model, y, pts) = build_quadrature(d, K_dom, B_dom, ppar)
5555
JuMP.optimize!(model)
5656

57-
w = JuMP.value.(y1)
57+
w = JuMP.value.(y)
5858
integral = sum(w[i] * p(pts[i, :]) for i in eachindex(w))
5959

6060
println(w)

0 commit comments

Comments
 (0)