astamm / nloptr

nloptr provides an R interface to NLopt, a free/open-source library for nonlinear optimization providing a common interface to a number of different optimization routines which can handle nonlinear constraints and lower and upper bounds for the controls.
https://astamm.github.io/nloptr/
Other
105 stars 35 forks source link

Tests for directL fail #138

Closed astamm closed 1 year ago

astamm commented 1 year ago

Running tests locally for NLOPT_GN_DIRECT_L_RAND fail with the following errors:

----- FAILED[data]: test-wrapper-direct.R<139--139>
 call| expect_equal(directLTest$par, directLControl$solution, tolerance = tol)
 diff| Mean relative difference: 0.04548268
 ----- FAILED[data]: test-wrapper-direct.R<140--140>
 call| expect_equal(directLTest$value, directLControl$objective, tolerance = tol)
 diff| Expected '-3.25641760509437', got '-3.32236801141552'

@aadler : I see a comment of yours suggesting you ran into this problem already. Indeed trying to set the seed in advance does not seem to help.

astamm commented 1 year ago

It might be that set.seed() or withr::with_seed() only affects the seed R uses but not on the C side of things. But I am surprised you do not run into this issue anymore.

aadler commented 1 year ago

Hi. @astamm. That's bizarre, since not only did I not run into the issue, none of the Github actions test platforms we use ran into it either. I'll try both increasing the the number of iterations and setting the seed, but you'll have to test it out as it still passes by me.

aadler commented 1 year ago

See https://github.com/astamm/nloptr/pull/142