pythonscipyscipy-optimizescipy-optimize-minimizequadratic-programming

Scipy optimize SLSQP: How is the 'ftol' parameter used?


I am wondering how the 'ftol' paramater in scipy.optimize.minimize(method='SLSQP') is used. In the documentation it just says, that it is the precision goal for the value of f, which could mean different things. I know there is a paper where the original algorithm is explained; you can find it here:

http://yetanothermathprogrammingconsultant.blogspot.com/2022/02/slsqp-original-paper.html

However, I am not able to find the stopping criterion herein. Scipy provides a wrapper to the algorithm explained in that paper, which, I believe, is written in FORTRAN and not easy to read.

Thank you in advance!


Solution

  • Looking at the code in https://github.com/scipy/scipy/blob/v1.13.0/scipy/optimize/_slsqp_py.py, it looks the ftol parameter is passed as the acc parameter to the fortran SLSQP routine in here: https://github.com/scipy/scipy/blob/v1.13.0/scipy/optimize/slsqp/slsqp_optmz.f

    I don't know fortran, but I guess that the termination criteria is defined in this line:

          IF ((ABS(f-f0).LT.acc .OR. dnrm2_(n,s,1).LT.acc) .AND. h3.LT.acc
         *     .AND. .NOT. badlin .AND. f .EQ. f)
    
    

    This implies that acc is used in multiple ways: