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

Porting the SciPy tests to Fortran #70

Open
ivan-pi opened this issue May 22, 2022 · 7 comments
Open

Porting the SciPy tests to Fortran #70

ivan-pi opened this issue May 22, 2022 · 7 comments

Comments

@ivan-pi
Copy link
Member

ivan-pi commented May 22, 2022

One of the suggestions in #14 (comment) was to port the MINPACK tests from SciPy to our test suite.

I've tried to locate some of the relevant files:

Note that some of the test may only be testing properties of the SciPy interface, and not have much to do with Fortran at all.

@ilayn
Copy link

ilayn commented May 22, 2022

@mdhaber Is there anything we can provide for numerical stability and edge cases for MINPACK specifically?

@mdhaber
Copy link

mdhaber commented May 22, 2022

Hmm, I don't know of any. Like stress tests for the underlying algorithms?

@ilayn
Copy link

ilayn commented May 22, 2022

Yes mostly testing the edge cases and maybe stress testing that we are sure it doesn't break at the Fortran side

@ivan-pi
Copy link
Member Author

ivan-pi commented May 22, 2022

By edge cases, do you mean for examples things like NaN or infinity in the initial guess? I believe that MINPACK currently doesn't perform such checks. The question is whether to add such input-checking to the Fortran code, or leave it as the responsibility of the caller (or SciPy wrapper) to perform such checks.

A good place to start is maybe to look at the errors that MINPACK detects currently, e.g. in hybrd:

        integer, intent(out) :: info             !! an integer output variable. if the user has
                                            !! terminated execution, `info` is set to the (negative)
                                            !! value of `iflag`. see description of `fcn`. otherwise,
                                            !! `info` is set as follows:
                                            !!
                                            !!  * ***info = 0*** improper input parameters.
                                            !!  * ***info = 1*** relative error between two consecutive iterates
                                            !!    is at most `xtol`.
                                            !!  * ***info = 2*** number of calls to `fcn` has reached or exceeded
                                            !!    `maxfev`.
                                            !!  * ***info = 3*** `xtol` is too small. no further improvement in
                                            !!    the approximate solution `x` is possible.
                                            !!  * ***info = 4*** iteration is not making good progress, as
                                            !!    measured by the improvement from the last
                                            !!    five jacobian evaluations.
                                            !!  * ***info = 5*** iteration is not making good progress, as
                                            !!    measured by the improvement from the last
                                            !!    ten iterations.

and compare with the wrappers in SciPy (https://github.com/scipy/scipy/blob/main/scipy/optimize/_minpack_py.py) and figure out what could be simplified by handling in Fortran.

@ilayn
Copy link

ilayn commented May 22, 2022

Historically, we have been quite successful with finding wrapper bugs. What I had in mind is more like ill-conditioned problems, singularities, getting stuck in while loops and so on. But I don't have concrete examples yet.

@ivan-pi
Copy link
Member Author

ivan-pi commented May 22, 2022

There are a number of test collections including ill-conditioned problems. We have issues open for a few (#10, #35) of them. Here are a few original references:

It's just a lot of effort to create the drivers in Fortran (or Python), and integrate them with the CI/CD in a way that we could track the correctness and speed improvements with time.

@ilayn
Copy link

ilayn commented May 22, 2022

Is there any way that I can make life easier for you folks? CI/CD setup is something we can help you with, since we are doing this very often, though I think we don't have much Fortran knowledge.

Just copy pasting numbers from horrific PDFs to text files is also fine, any way you need help please let us know.

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

No branches or pull requests

3 participants