diff --git a/ext/IntegralsMCIntegrationExt.jl b/ext/IntegralsMCIntegrationExt.jl index e14233d..c761ff1 100644 --- a/ext/IntegralsMCIntegrationExt.jl +++ b/ext/IntegralsMCIntegrationExt.jl @@ -3,10 +3,10 @@ module IntegralsMCIntegrationExt using MCIntegration, Integrals function Integrals.__solvebp_call(prob::IntegralProblem, alg::VEGASMC, sensealg, domain, p; - reltol = nothing, abstol = nothing, maxiters = 1000) + reltol = nothing, abstol = nothing, maxiters = 10) lb, ub = domain mid = vec(collect((lb + ub) / 2)) - vars = Continuous(vec([tuple(a,b) for (a,b) in zip(lb, ub)])) + var = Continuous(vec([tuple(a,b) for (a,b) in zip(lb, ub)])) if prob.f isa BatchIntegralFunction error("VEGASMC doesn't support batching. See https://github.com/numericalEFT/MCIntegration.jl/issues/29") @@ -33,9 +33,8 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::VEGASMC, sensealg, end end dof = ones(Int, length(f0)) # each composite Continuous var gets 1 dof - res = integrate(f_, inplace=isinplace(prob), var=vars, dof=dof, solver=:vegasmc, - neval=alg.neval, niter=min(maxiters,alg.niter), block=alg.block, adapt=alg.adapt, - gamma=alg.gamma, verbose=alg.verbose, debug=alg.debug, type=eltype(f0), print=-2) + res = integrate(f_; var, dof, inplace=isinplace(prob), type=eltype(f0), + solver=:vegasmc, niter=maxiters, verbose=-2, print=-2, alg.kws...) out, err, chi = if f0 isa Number map(only, (res.mean, res.stdev, res.chi2)) else diff --git a/src/algorithms.jl b/src/algorithms.jl index 972c464..f2c1dfc 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -372,18 +372,16 @@ function ArblibJL(; check_analytic=false, take_prec=false, warn_on_no_convergenc end """ - VEGASMC(; neval=10^4, niter=20, block=16, adapt=true, gamma=1.0, verbose=-2, debug=false) + VEGASMC(; kws...) Markov-chain based Vegas algorithm from MCIntegration.jl + +Refer to +[`MCIntegration.integrate`](https://numericaleft.github.io/MCIntegration.jl/dev/lib/montecarlo/#MCIntegration.integrate-Tuple{Function}) +for documentation on the keywords, which are passed directly to the solver with a set of +defaults that works for conforming integrands. """ -struct VEGASMC <: SciMLBase.AbstractIntegralAlgorithm - neval::Int - niter::Int - block::Int - adapt::Bool - gamma::Float64 - verbose::Int - debug::Bool +struct VEGASMC{K<:NamedTuple} <: SciMLBase.AbstractIntegralAlgorithm + kws::K end -VEGASMC(; neval=10^4, niter=20, block=16, adapt=true, gamma=1.0, verbose=-2, debug=false) = - VEGASMC(neval, niter, block, adapt, gamma, verbose, debug) +VEGASMC(; kws...) = VEGASMC(NamedTuple(kws)) diff --git a/test/interface_tests.jl b/test/interface_tests.jl index 57457e2..1a0137c 100644 --- a/test/interface_tests.jl +++ b/test/interface_tests.jl @@ -18,7 +18,7 @@ alg_req = Dict( max_dim = Inf, allows_iip = true), # VEGAS() => (nout = 1, allows_batch = true, min_dim = 2, max_dim = Inf, # allows_iip = true), - VEGASMC() => (nout = Inf, allows_batch = false, min_dim = 1, max_dim = Inf, + VEGASMC(seed=42) => (nout = Inf, allows_batch = false, min_dim = 1, max_dim = Inf, allows_iip = true), CubatureJLh() => (nout = Inf, allows_batch = true, min_dim = 1, max_dim = Inf, allows_iip = true),