least_squares_solver Derived Type

type, public, extends(equation_solver) :: least_squares_solver

@brief Defines a Levenberg-Marquardt based solver for unconstrained least-squares problems. Defines a Levenberg-Marquardt based solver for unconstrained least-squares problems.


Contents


Type-Bound Procedures

procedure, public :: get_fcn_tolerance => es_get_fcn_tol

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

    Gets the convergence on function value tolerance.

    Arguments

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

    The equation_solver object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_gradient_tolerance => es_get_grad_tol

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

    Gets the convergence on slope of the gradient vector tolerance.

    Arguments

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

    The equation_solver object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_max_fcn_evals => es_get_max_eval

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

    Gets the maximum number of function evaluations allowed during a single solve.

    Arguments

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

    The equation_solver object.

    Return Value integer(kind=int32)

    The maximum number of function evaluations.

procedure, public :: get_print_status => es_get_print_status

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

    Gets a logical value determining if iteration status should be printed.

    Arguments

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

    The equation_solver object.

    Return Value logical

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

procedure, public :: get_step_scaling_factor => lss_get_factor

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

    Gets a factor used to scale the bounds on the initial step.

    This factor is used to set the bounds on the initial step such that the initial step is bounded as the product of the factor with the Euclidean norm of the vector resulting from multiplication of the diagonal scaling matrix and the solution estimate. If zero, the factor itself is used.

    Arguments

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

    The least_squares_solver object.

    Return Value real(kind=real64)

    The factor.

procedure, public :: get_var_tolerance => es_get_var_tol

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

    Gets the convergence on change in variable tolerance.

    Arguments

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

    The equation_solver object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: set_fcn_tolerance => es_set_fcn_tol

  • private subroutine es_set_fcn_tol(this, x)

    Sets the convergence on function value tolerance.

    Arguments

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

    The equation_solver object.

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

    The tolerance value.

procedure, public :: set_gradient_tolerance => es_set_grad_tol

  • private subroutine es_set_grad_tol(this, x)

    Sets the convergence on slope of the gradient vector tolerance.

    Arguments

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

    The equation_solver object.

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

    The tolerance value.

procedure, public :: set_max_fcn_evals => es_set_max_eval

  • private subroutine es_set_max_eval(this, n)

    Sets the maximum number of function evaluations allowed during a single solve.

    Arguments

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

    The equation_solver object.

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

    The maximum number of function evaluations.

procedure, public :: set_print_status => es_set_print_status

  • private subroutine es_set_print_status(this, x)

    Sets a logical value determining if iteration status should be printed.

    Arguments

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

    The equation_solver object.

    logical, intent(in) :: x

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

procedure, public :: set_step_scaling_factor => lss_set_factor

  • private subroutine lss_set_factor(this, x)

    Sets a factor used to scale the bounds on the initial step.

    This factor is used to set the bounds on the initial step such that the initial step is bounded as the product of the factor with the Euclidean norm of the vector resulting from multiplication of the diagonal scaling matrix and the solution estimate. If zero, the factor itself is used.

    Arguments

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

    The least_squares_solver object.

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

    The factor.

procedure, public :: set_var_tolerance => es_set_var_tol

  • private subroutine es_set_var_tol(this, x)

    Sets the convergence on change in variable tolerance.

    Arguments

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

    The equation_solver object.

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

    The tolerance value.

procedure, public :: solve => lss_solve

  • private subroutine lss_solve(this, fcn, x, fvec, ib, err)

    Applies the Levenberg-Marquardt method to solve the nonlinear least-squares problem. This routines is based upon the MINPACK routine LMDIF.

    Arguments

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

    The least_squares_solver object.

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

    The vecfcn_helper object containing the equations to solve.

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

    On input, an N-element array containing an initial estimate to the solution. On output, the updated solution estimate. N is the number of variables.

    real(kind=real64), intent(out), dimension(:) :: fvec

    An M-element array that, on output, will contain the values of each equation as evaluated at the variable values given in 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.