xdem
xdem copied to clipboard
Fix results of `scipy.optimize` between OS
The output of scipy.optimize.basinhopping
varies between operating systems, added TODOs in the tests in #304. It does not look like it's due to the random seed
that seems correctly passed, but the output tolerance.
For scipy.optimize.least_squares
, I managed to have the same results on different OS by rounding the result 100 times above the variable tolerance xtol
provided to the optimize function (not sure if it's 100% robust, need to think more on it).
For basinhopping
and the method we use in it, one can only pass ftol
(cost function) or gtol
(gradient), which does not translate directly into xtol
(variables of interest). So the tolerances might be too low compared to the rounding, hence different results on different OS. The equations of the tolerances are provided in the scipy
doc, so we should be able to work back the influence on the variable tolerance to ensure all results are fixed.
Update: in the PR #304, the output of scipy.optimize.least_squares
after rounding with a lower tolerance than xtol
is the same for Linux and Windows, but not for Mac.
Need to find a way to solve this more robustly...