Integrals.jl
Integrals.jl copied to clipboard
maxiters kwarg not functioning
using Quadrature
function f(x,p,c)
c[1]+=1
sum(sin.(x))
end
algs = [HCubatureJL(), CubatureJLh(), CubatureJLp(), CubaSUAVE(), CubaDivonne(), CubaCuhre()]
count_array = zeros(length(algs))
for (i,alg) ∈ enumerate(algs)
try
count = [0]
prob = QuadratureProblem((x,p)->f(x,p,count),ones(2),3ones(2))
sol = solve(prob,alg,reltol=1e-3,abstol=1e-3, maxiter=3)
count_array[i] = count[1]
catch
count_array[i] = NaN
end
end
count_array #[17, 18, 82, NaN, NaN, NaN]. NaN indicates invalid kwarg
It's maxiters:
using Quadrature
function f(x,p,c)
c[1]+=1
sum(sin.(x))
end
algs = [HCubatureJL(), CubatureJLh(), CubatureJLp(), CubaSUAVE(), CubaDivonne(), CubaCuhre()]
count_array = zeros(length(algs))
for (i,alg) ∈ enumerate(algs)
try
count = [0]
prob = QuadratureProblem((x,p)->f(x,p,count),ones(2),3ones(2))
sol = solve(prob,alg,reltol=1e-3,abstol=1e-3, maxiters=3)
count_array[i] = count[1]
catch
count_array[i] = NaN
end
end
count_array #[17, 18, 82, NaN, NaN, NaN]. NaN indicates invalid kwarg
which just gives more NaNs though.
For the first three, Cubature methods need a slack on maxiters. Basically, if you think of something like a Gauss-Kronrod method, 15 evaluations is the minimum for GK, and then adapting needs to go up in those increments. Cubature methods are similar, so you will never be able to get maxiter=3
. I assumed they would always just do their whole next step, so they would overshoot the iterations and then not adapt anymore. I'm not certain though.
It's maxiters:
🤦 Thanks
I knew that some slack was required for maxiters for the various algs. It was the crashes that are the main issue. Its an easy fix, I just wanted to put something here so I didn't forget.
The Cuba algorithms segfault for me. Anyway this is an upstream issue that can't be fixed here.
Closing as upstream.