Integrals.jl icon indicating copy to clipboard operation
Integrals.jl copied to clipboard

maxiters kwarg not functioning

Open agerlach opened this issue 4 years ago • 2 comments

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

agerlach avatar Sep 24 '20 18:09 agerlach

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.

ChrisRackauckas avatar Sep 27 '20 07:09 ChrisRackauckas

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.

agerlach avatar Sep 29 '20 20:09 agerlach

The Cuba algorithms segfault for me. Anyway this is an upstream issue that can't be fixed here.

ArnoStrouwen avatar Dec 21 '22 15:12 ArnoStrouwen

Closing as upstream.

ChrisRackauckas avatar Nov 03 '23 10:11 ChrisRackauckas