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 :: xmin
orreal*8 :: xmin(:)
xmin
can be either a scalar or a one-dimensional array, indicating whetherfminsearch
should find the minimum of a one or multi-dimensional function. The subroutine will use the values provided inxmin
as starting guess for finding the minimum. Hence, the closerxmin
is to the actual minimum of the function, the faster and the more reliable will be the minimization process.
-
real*8 :: minimum
orreal*8 :: minimum(:)
minimum
defines the lower bound of the interval in$\mathbb{R}^n$ on whichfminsearch
should search for the minimum of. If
, then
minimum
is just the scalar lower bound of the search interval. If,
minimum
contains the lower bounds in each search dimension ofand therefore marks the lower corner of an
-dimensional hypercube. Note that
minimum
needs to have exactly the same size asxmin
. -
real*8 :: maximum
orreal*8 :: maximum(:)
maximum
defines the upper bound of the interval in$\mathbb{R}^n$ on whichfminsearch
should search for the minimum of. If
, then
maximum
is just the scalar upper bound of the search interval. If,
maximum
contains the upper bounds in each search dimension ofand therefore marks the upper corner of an
-dimensional hypercube. Note that
maximum
needs to have exactly the same size asxmin
. -
function :: func
The inputfunc
is the name of a Fortran function that provides the function thatfminsearch
should find a minimum of. Note that this function needs to be stored somewhere in a module and can not be an element of thecontains
statement the main program. Ifxmin
is 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 :: xmin
orreal*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.xmin
is hence of the typeinout
. -
real*8 :: fret
After the subroutinefminsearch
has 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.f90
prog03_01.f90
prog05_01.f90
prog05_02.f90
prog05_03.f90
prog05_04.f90
prog05_05.f90
prog08_05.f90