@@ -27,20 +27,20 @@ function build_quadrature(
27
27
B_dom:: MU.Domain ,
28
28
ppar,
29
29
)
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 )
32
32
33
- # get quadrature weights for B
33
+ # get weights for B
34
34
y2 = # TODO
35
35
36
36
# build JuMP model
37
37
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 ))
42
42
43
- return (model, y1 , pts)
43
+ return (model, y , pts)
44
44
end
45
45
46
46
function integrate_poly (
@@ -51,10 +51,10 @@ function integrate_poly(
51
51
ppar, # polynomial as the parameter in objective of moment problem
52
52
)
53
53
# 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)
55
55
JuMP. optimize! (model)
56
56
57
- w = JuMP. value .(y1 )
57
+ w = JuMP. value .(y )
58
58
integral = sum (w[i] * p (pts[i, :]) for i in eachindex (w))
59
59
60
60
println (w)
0 commit comments