giordano / Cuba.jl

Library for multidimensional numerical integration with four independent algorithms: Vegas, Suave, Divonne, and Cuhre.
https://giordano.github.io/Cuba.jl/stable
MIT License
77 stars 9 forks source link

maxevals produces InexactError() #4

Closed davorh closed 7 years ago

davorh commented 7 years ago

Simple increase in value for maxevals produces error. You can replicate problem with this simple code (Debian Linux, julia 0.5.1, 64 bit kernel)

In[]:= vegas((x,f)->f[1]=cos(0.1*x[1]), maxevals = 1e9) Out[]:= ([0.998335],[4.70961e-5],[-999.0],1000,0,0)

In[]:= vegas((x,f)->f[1]=cos(0.1*x[1]), maxevals = 3e9) Out[]:= InexactError() in dointegrate(::Symbol, ::Ptr{Void}, ::Int64, ::Int64, ::Ptr{Void}, ::Int64, ::Float64, ::Float64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Float64, ::Int64, ::Int64, ::Int64, ::Int64, ::Float64, ::Float64, ::Float64, ::Int64, ::Int64, ::Int64, ::Int64, ::Ptr{Void}, ::Int64, ::String, ::Ptr{Void}) at /home/sageusr/.julia/v0.5/Cuba/src/Cuba.jl:169 in #vegas#1(::Int64, ::Float64, ::Float64, ::Int64, ::Int64, ::Int64, ::Float64, ::Int64, ::Int64, ::Int64, ::Int64, ::String, ::Ptr{Void}, ::Cuba.#vegas, ::##33#34, ::Int64, ::Int64) at /home/sageusr/.julia/v0.5/Cuba/src/Cuba.jl:295 in (::Cuba.#kw##vegas)(::Array{Any,1}, ::Cuba.#vegas, ::Function, ::Int64, ::Int64) at ./:0 (repeats 2 times)

giordano commented 7 years ago

That happens because currently Cuba.jl wraps only the routines with 32-bit integers, so maxevals is limited to be

julia> typemax(Int32)
2147483647

This explains why you can have 1e9 maximum evaluations but not 3e9.

I could wrap the functions with 64-bit integers as well, but not anytime soon.

Anyway, unless you have specific reasons to use Vegas algorithm, I'd suggest you to try cuhre function: in most cases this is much faster and much more accurate than the other integration methods, so you usually need less evaluations to get a good result.

davorh commented 7 years ago

Thanks. Since we need Vegas (due to the high dimensionality) can you steer us in the right direction how to make 64 bit wrapper.

giordano commented 7 years ago

It's not hard to do it (I already did it locally yesterday), but I'm deciding what's the best interface for the user. I have the following options:

giordano commented 7 years ago

I'm working on this. I decided to use follow the second option (define new functions). This is not particularly elegant, but closely tracks how Cuba library works. I hope to be able to tag a new release in a few hours.

davorh commented 7 years ago

Thanks a lot! We are testing Cuhre but Vegas is more suitable in our case.

On 24.1.2017. 16:08, Mosè Giordano wrote:

I'm working on this. I decided to use follow the second options (define new functions). This is not particularly elegant, but closely tracks how Cuba library works. I hope to be able to tag a new release in a few hours.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/giordano/Cuba.jl/issues/4#issuecomment-274830271, or mute the thread https://github.com/notifications/unsubscribe-auth/ASvGj7B-BxaIas_DBGGZDGauuMSDpoWFks5rVhPbgaJpZM4LrFRH.

giordano commented 7 years ago

@davorh Cuba.jl 0.3.0 is now officially registered, you should get it upon updating your packages. Use llvegas instead of vegas, the syntax is just the same but you can specify maxevals up to 2^63 - 1 (but there is no way to overcome this limit). Please, do let me know if it works for you.

davorh commented 7 years ago

Thanks! First tests are working as expected. We will reference your package and add you to Acknowledgments.

On 25.1.2017. 8:06, Mosè Giordano wrote:

@davorh https://github.com/davorh Cuba.jl 0.3.0 is now officially registered, you should get it upon updating your packages. Use |llvegas| instead of |vegas|, the syntax is just the same but you can specify |maxevals| up to 2^63 - 1 (but there is no way to overcome this limit). Please, do let me know if it works for you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/giordano/Cuba.jl/issues/4#issuecomment-275034890, or mute the thread https://github.com/notifications/unsubscribe-auth/ASvGj7MoEpNt0yQA51yFRI2wwlEMhJncks5rVvSFgaJpZM4LrFRH.

giordano commented 7 years ago

Thank you! Please, do cite Thomas Hahn's papers listed in https://github.com/giordano/Cuba.jl#license as well. He wrote all integration functions, I'm only responsible for the Julia interface ;-)

davorh commented 7 years ago

We will of course :) Your Julia interface simpler development/calculation framework.

On 25.1.2017. 12:39, Mosè Giordano wrote:

Thank you! Please, do cite Thomas Hahn's papers listed in https://github.com/giordano/Cuba.jl#license as well. He wrote all integration functions, I'm only responsible for the Julia interface ;-)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/giordano/Cuba.jl/issues/4#issuecomment-275086774, or mute the thread https://github.com/notifications/unsubscribe-auth/ASvGj7_2_7xtVS7NiCuLR1GJubOX45AAks5rVzR0gaJpZM4LrFRH.

giordano commented 7 years ago

With release of v0.4.0, all functions wrap the 64-bit integer versions of integrator routines and the functions named ll* are now deprecated (because they're equivalent to base ones). This is basically the first option I mentioned in this message above.