Foortran Toolkit

Fortran toolkit
Borja Petit


Download toolkit

Back to index

lmmin

subroutine lmmin(func,x,y,iy,exitcode,x0,itermax,damp,tol,shock,usebro,iprint)
  implicit none
  external                             :: func        ! user-supplied function to be minimize
  real(kind=8) , intent(out)           :: x(:)        ! values of "x" at minimum
  real(kind=8) , intent(out)           :: y(:)        ! valuf of "func" at "x"
  integer      , intent(out)           :: iy          ! number of function evaluations
  integer      , intent(out)           :: exitcode    ! indicator of convergence
  real(kind=8) , intent(in)            :: x0(:)       ! initial guess
  real(kind=8) , intent(in) , optional :: shock       ! shock to parameter values (as %)
  real(kind=8) , intent(in) , optional :: damp        ! damping factor
  real(kind=8) , intent(in) , optional :: tol         ! tolerance level
  integer      , intent(in) , optional :: itermax     ! max number of functione valuations
  integer      , intent(in) , optional :: iprint      ! indicator for printing behaviour
  integer      , intent(in) , optional :: usebro      ! indicator for the use of Broyden method to update Jacobian

This subroutine applies the Levenberg–Marquardt algorithm (click here for more information) which minimizes the sum of squared errors of a (possibly nonlinear) system of multivariate equations.

This subroutine applies the Nelder-Mead algorithm (click here for more information).

The user should input the function func and the initial guess x0. The function func must be of the form:

  function func(xvec) result(resid)
    real(kind=8)               :: xvec(:)
    real(kind=8) , allocatable :: resid(:)
    ...
  end function func

The subroutine returns the value(s) of x that makes func smaller than tol (close enoughs to zero), the number of function evaluations (iy), and an indicator, exitcode:

Optionally, the user can also supply:

Note: for constrained optimization problems, one can make use of the normalize and denormalize subroutines.

Internal dependencies: inverse, broyden