nelder_mead Derived Type

type, public, extends(equation_optimizer) :: nelder_mead

Defines a solver based upon Nelder and Mead's simplex algorithm for minimization of functions of multiple variables.


Contents


Type-Bound Procedures

procedure, public :: get_initial_size => nm_get_size

  • private pure function nm_get_size(this) result(x)

    Gets the size of the initial simplex that will be utilized by the Nelder-Mead algorithm in the event that the user does not supply a simplex geometry, or if the user supplies an invalid simplex geometry.

    Arguments

    Type IntentOptional Attributes Name
    class(nelder_mead), intent(in) :: this

    The nelder_mead object.

    Return Value real(kind=real64)

    The size of the simplex (length of an edge).

procedure, public :: get_max_fcn_evals => oe_get_max_eval

  • private pure function oe_get_max_eval(this) result(n)

    Arguments

    Type IntentOptional Attributes Name
    class(equation_optimizer), intent(in) :: this

    The equation_optimizer object.

    Return Value integer(kind=int32)

    The maximum number of function evaluations.

procedure, public :: get_print_status => oe_get_print_status

  • private pure function oe_get_print_status(this) result(x)

    Arguments

    Type IntentOptional Attributes Name
    class(equation_optimizer), intent(in) :: this

    The equation_optimizer object.

    Return Value logical

    True if the iteration status should be printed; else, false.

procedure, public :: get_simplex => nm_get_simplex

  • private pure function nm_get_simplex(this) result(p)

    Gets an N-by-(N+1) matrix containing the current simplex.

    Arguments

    Type IntentOptional Attributes Name
    class(nelder_mead), intent(in) :: this

    The nelder_mead object.

    Return Value real(kind=real64), allocatable, dimension(:,:)

    The N-by-(N+1) matrix containing the simplex. Each vertex of the simplex is stored as its own column of this matrix.

procedure, public :: get_tolerance => oe_get_tol

  • private pure function oe_get_tol(this) result(x)

    Arguments

    Type IntentOptional Attributes Name
    class(equation_optimizer), intent(in) :: this

    The equation_optimizer object.

    Return Value real(kind=real64)

    The tolerance.

procedure, public :: set_initial_size => nm_set_size

  • private subroutine nm_set_size(this, x)

    Sets the size of the initial simplex that will be utilized by the Nelder-Mead algorithm in the event that the user does not supply a simplex geometry, or if the user supplies an invalid simplex geometry.

    Arguments

    Type IntentOptional Attributes Name
    class(nelder_mead), intent(inout) :: this

    The nelder_mead object.

    real(kind=real64), intent(in) :: x

    The size of the simplex (length of an edge).

procedure, public :: set_max_fcn_evals => oe_set_max_eval

  • private subroutine oe_set_max_eval(this, n)

    Arguments

    Type IntentOptional Attributes Name
    class(equation_optimizer), intent(inout) :: this

    The equation_optimizer object.

    integer(kind=int32), intent(in) :: n

    The maximum number of function evaluations.

procedure, public :: set_print_status => oe_set_print_status

  • private subroutine oe_set_print_status(this, x)

    Arguments

    Type IntentOptional Attributes Name
    class(equation_optimizer), intent(inout) :: this

    The equation_optimizer object.

    logical, intent(in) :: x

    True if the iteration status should be printed; else, false.

procedure, public :: set_simplex => nm_set_simplex

  • private subroutine nm_set_simplex(this, x)

    Sets an N-by-(N+1) matrix as the current simplex. Notice, if this matrix is different in size from the problem dimensionallity, the Nelder-Mead routine will replace it with an appropriately sized matrix.

    Arguments

    Type IntentOptional Attributes Name
    class(nelder_mead), intent(inout) :: this

    The nelder_mead object.

    real(kind=real64), dimension(:,:) :: x

    The simplex matrix. Each column of the matrix must contain the coordinates of each vertex of the simplex.

procedure, public :: set_tolerance => oe_set_tol

  • private subroutine oe_set_tol(this, x)

    Arguments

    Type IntentOptional Attributes Name
    class(equation_optimizer), intent(inout) :: this

    The equation_optimizer object.

    real(kind=real64), intent(in) :: x

    The tolerance.

procedure, public :: solve => nm_solve

  • private subroutine nm_solve(this, fcn, x, fout, ib, err)

    Utilizes the Nelder-Mead simplex method for finding a minimum value of the specified function.

    The implementation of the Nelder-Mead algorithm presented here is a slight modification of the original work of Nelder and Mead. The Numerical Recipes implementation is also quite similar. In fact, the Numerical Recipes section relating to reflection, contraction, etc. is leveraged for this implemetation.

    See Also:

    • Nelder, John A.; R. Mead (1965). "A simplex method for function minimization". Computer Journal. 7: 308–313.

    • [Gao, Fuchang, Han, Lixing (2010). "Implementing the Nelder-Mead simplex algorithm with adaptive parameters."] (http://www.webpages.uidaho.edu/~fuchang/res/ANMS.pdf)

    • Wikipedia

    • Numerical Recipes

    Arguments

    Type IntentOptional Attributes Name
    class(nelder_mead), intent(inout) :: this

    The nelder_mead object.

    class(fcnnvar_helper), intent(in) :: fcn

    The fcnnvar_helper object containing the equation to optimize.

    real(kind=real64), intent(inout), dimension(:) :: x

    On input, the initial guess at the optimal point. On output, the updated optimal point estimate.

    real(kind=real64), intent(out), optional :: fout

    An optional output, that if provided, returns the value of the function at x.

    type(iteration_behavior), optional :: ib

    An optional output, that if provided, allows the caller to obtain iteration performance statistics.

    class(errors), intent(inout), optional, target :: err

    An error handling object.