Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange conflict when importing Measurements.jl and BlackBoxOptim.jl in the same program #176

Open
Boxylmer opened this issue Apr 6, 2021 · 8 comments

Comments

@Boxylmer
Copy link

Boxylmer commented Apr 6, 2021

I've been working on optimizing some values that have uncertainties associated with them in Measurements. I wanted to use BlackBoxOptim for this purpose but I'm getting some strange behavior by the Julia compiler (using 1.6.0, and to my knowledge this is also the case in earlier versions (1.5.x) too).

Here's a MWE (ignore the variable names, this was taken from me and a few people over at the Humans of Julia Discord server messing around with the actual project)

using BlackBoxOptim
# using Measurements  # uncomment this after confirming it runs correctly
function solve_volume_uncertainty_bbox(p_uncertainty, v_value, t)
    function target_function(volume_uncertainty_guess_l_mol)
        resulting_pressure = 4
        return (resulting_pressure - p_uncertainty)^2
    end
    res = bboptimize(target_function; SearchRange=(0.0, 10.0), NumDimensions=1, Method=:de_rand_1_bin)  
    return best_candidate(res)[1]
end

bbox = solve_volume_uncertainty_bbox(0.1, 20.08405, 273.15)
println(bbox)

When running without Measurements imported, the program runs fine. If it is imported, however, we get a nasty stackoverflow error, seemingly from the compiler. This error continues to spam your terminal for a bit before it returns the correctly solved value. A formal exception is not actually thrown in the Julia runtime.

I've spoken to the developer of Measurements in JuliaPhysics/Measurements.jl#100 and they narrowed the issue down in a Measurements operation involving logarithms, namely this snippet of code, by cutting things out until including the using Measurements worked without issue:

https://github.com/JuliaPhysics/Measurements.jl/blob/e71f5203ee70fd66057d349855b604db126d4a55/src/math.jl#L619-L622

Would anyone know what exactly is going on here? Note that in the MWE there are no measurement types being created, and the library isn't even being used at all. I would be absolutely thrilled to see compatibility between these two libraries as optimizing uncertainty in iterative functions would be awesome in some of the projects we do in polymer research!

@robertfeldt
Copy link
Owner

Hmm, this is very strange. No clue what can be causing this. I grepped uses of log in BlackBoxOptim and there are quite a few uses but no redefinition or similar. Will investigate more but not really sure where to start and haven't been using Measurements myself. I assume you have tried this also on master (add BlackBoxOptim#master) since there are conflicts with other packages on latest release?

@Boxylmer
Copy link
Author

Boxylmer commented Apr 9, 2021

@robertfeldt Sorry for the delay in response! I'm a bit new to Github issues and haven't made the habit of checking frequently.

Were you able to fully replicate the issue? I'm a bit new to Julia and wasn't aware of that convenience to switching branches like that. So I just took a shot at both (with and without using Measurements) and didn't get the issue in the latter case!

@robertfeldt
Copy link
Owner

No worries.

I'm running on master branch and couldn't replicate. But the only real change between latest release and master is the dependencies on other packages so that none of us can replicate on master indicates to me that the issue is really in some other package. And likely in an older version of some package. Ok, I'll explore some more but likely this "bug" should go away with a new release.

@giordano
Copy link

giordano commented Apr 9, 2021

But the only real change between latest release and master is the dependencies on other packages

I'm not sure git history agrees: v0.5.0...83c8116

@robertfeldt
Copy link
Owner

Point taken, I expressed myself badly. I was thinking of recent commits; could actually be nice to see if the problem reported in this thread was introduced by any of the commits prior to these recent ones. But yes, a new release a really overdue.

@robertfeldt
Copy link
Owner

Hmm, I just removed BBO and Measurements and reinstalled them both on 1.6 (BBO on master) and then I can replicate this problem. Ok, so back to the debug stage 1 again... ;)

@Boxylmer
Copy link
Author

Any updates on this? I'd really love to see compatibility between the two libraries as I've wanted to try out BorgMOEA in my project that also uses Measurement uncertainties! (We strip them from the values going in, but just having the two libraries in the same file causes problems)

@robertfeldt
Copy link
Owner

Yeah, I'm not really sure how to start debugging this. I guess we'll have to try excluding files, one by one, and seeing when/if the problem disappears. But likely it is not on a file level and the dependencies might be hard to handle. But yes I can replicate this and the problem remains on Julia 1.6.1 with recent versions of the two packages. Ideas on how to debug this are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants