fminsearch - fabiankindermann/ce-fortran GitHub Wiki
subroutine fminsearch(xmin, fret, minimum, maximum, func)
This subroutine finds the minimum of a one or multi-dimensional function , meaning that it searches for a value
such that
fminsearch will find the global minimum of this function. For solving global minima problems, more sophisticated methods are needed.
-
real*8 :: xminorreal*8 :: xmin(:)
xmincan be either a scalar or a one-dimensional array, indicating whetherfminsearchshould find the minimum of a one or multi-dimensional function. The subroutine will use the values provided inxminas starting guess for finding the minimum. Hence, the closerxminis to the actual minimum of the function, the faster and the more reliable will be the minimization process.
-
real*8 :: minimumorreal*8 :: minimum(:)
minimumdefines the lower bound of the interval in$\mathbb{R}^n$ on whichfminsearchshould search for the minimum of. If
, then
minimumis just the scalar lower bound of the search interval. If,
minimumcontains the lower bounds in each search dimension ofand therefore marks the lower corner of an
-dimensional hypercube. Note that
minimumneeds to have exactly the same size asxmin. -
real*8 :: maximumorreal*8 :: maximum(:)
maximumdefines the upper bound of the interval in$\mathbb{R}^n$ on whichfminsearchshould search for the minimum of. If
, then
maximumis just the scalar upper bound of the search interval. If,
maximumcontains the upper bounds in each search dimension ofand therefore marks the upper corner of an
-dimensional hypercube. Note that
maximumneeds to have exactly the same size asxmin. -
function :: func
The inputfuncis the name of a Fortran function that provides the function thatfminsearchshould find a minimum of. Note that this function needs to be stored somewhere in a module and can not be an element of thecontainsstatement the main program. Ifxminis a scalar, this function must follow exactly the calling conventions:function func(p) implicit none real*8, intent(in) :: p real*8 :: func [......] end function func
If
xmin(:)is a one-dimensional array we havefunction func(p) implicit none real*8, intent(in) :: p(:) real*8 :: func [......] end function func
-
real*8 :: xminorreal*8 :: xmin(:)
Having successfully found the minimum of, the resulting solution
will again be stored in the scalar or array
xmin, such that no additional output argument is needed.xminis hence of the typeinout. -
real*8 :: fret
After the subroutinefminsearchhas finished its iteration process, it stores the function valuein the scalar variable
fret.
- Parts of this routine were copied and adapted from:
- Press, W.H., Teukolsky, S.A., Vetterling, W.T. & Flannery, B.P. (1992). Numerical Recipes in Fortran 90: The Art of Parallel Scientific Computing, 2nd edition. Cambridge: Cambridge Univeristy Press.
- For further reading refer to:
- Brent, R.P. (2003). Algorithms for Minimization without Derivatives. Mineola: Dover Books on Mathematics.
- Acton, F.S. (1997). Numerical Methods that Work. The Mathematical Association of America.
- This routine is used in the following programs:
prog02_11.f90prog03_01.f90prog05_01.f90prog05_02.f90prog05_03.f90prog05_04.f90prog05_05.f90prog08_05.f90