nonlin 1.5.2
A library that provides routines to compute the solutions to systems of nonlinear equations.
Loading...
Searching...
No Matches
nonlin_optimize::bfgs Type Reference

Defines a Broyden–Fletcher–Goldfarb–Shanno (BFGS) solver for minimization of functions of multiple variables. More...

Inheritance diagram for nonlin_optimize::bfgs:
nonlin_optimize::line_search_optimizer nonlin_core::equation_optimizer

Public Member Functions

procedure, public solve bfgs_solve
 Utilizes the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm for finding a minimum value of the specified function.
 
- Public Member Functions inherited from nonlin_optimize::line_search_optimizer
procedure, public get_line_search lso_get_line_search
 Gets the line search module.
 
procedure, public set_line_search lso_set_line_search
 Sets the line search module.
 
procedure, public set_default_line_search lso_set_default
 Establishes a default line_search object for the line search module.
 
procedure, public is_line_search_defined lso_is_line_search_defined
 Tests to see if a line search module is defined.
 
procedure, public get_use_line_search lso_get_use_search
 Gets a value determining if a line-search should be employed.
 
procedure, public set_use_line_search lso_set_use_search
 Sets a value determining if a line-search should be employed.
 
procedure, public get_var_tolerance lso_get_var_tol
 Gets the convergence on change in variable tolerance.
 
procedure, public set_var_tolerance lso_set_var_tol
 Sets the convergence on change in variable tolerance.
 
- Public Member Functions inherited from nonlin_core::equation_optimizer
procedure, public get_max_fcn_evals oe_get_max_eval
 Gets the maximum number of function evaluations allowed.
 
procedure, public set_max_fcn_evals oe_set_max_eval
 Sets the maximum number of function evaluations allowed.
 
procedure, public get_tolerance oe_get_tol
 Gets the tolerance on convergence.
 
procedure, public set_tolerance oe_set_tol
 Sets the tolerance on convergence.
 
procedure, public get_print_status oe_get_print_status
 Gets a logical value determining if iteration status should be printed.
 
procedure, public set_print_status oe_set_print_status
 Sets a logical value determining if iteration status should be printed.
 

Additional Inherited Members

- Public Attributes inherited from nonlin_optimize::line_search_optimizer
logical m_uselinesearch = .true.
 Set to true if a line search should be used regardless of the status of m_lineSearch.
 
real(real64) m_xtol = 1.0d-12
 The convergence criteria on change in variable.
 
- Public Attributes inherited from nonlin_core::equation_optimizer
real(real64) m_tol = 1.0d-12
 The error tolerance used to determine convergence.
 
logical m_printstatus = .false.
 Set to true to print iteration status; else, false.
 

Detailed Description

Defines a Broyden–Fletcher–Goldfarb–Shanno (BFGS) solver for minimization of functions of multiple variables.

Definition at line 404 of file nonlin_optimize.f90.

Member Function/Subroutine Documentation

◆ solve()

procedure, public nonlin_optimize::bfgs::solve
virtual

Utilizes the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm for finding a minimum value of the specified function.

Syntax
subroutine solve(class(bfgs) this, class(fcnnvar_helper) fcn, real(real64) x(:), real(real64) fout, optional type(iteration_behavior) ib, optional class(errors) err)
Parameters
[in,out]thisThe bfgs_mead object.
[in]fcnThe fcnnvar_helper object containing the equation to optimize.
[in,out]xOn input, the initial guess at the optimal point. On output, the updated optimal point estimate.
[out]foutAn optional output, that if provided, returns the value of the function at x.
[out]ibAn optional output, that if provided, allows the caller to obtain iteration performance statistics.
[out]errAn optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.
  • NL_INVALID_OPERATION_ERROR: Occurs if no equations have been defined.
  • NL_INVALID_INPUT_ERROR: Occurs if x is not appropriately sized for the problem as defined in fcn.
  • NL_OUT_OF_MEMORY_ERROR: Occurs if there is insufficient memory available.
  • NL_CONVERGENCE_ERROR: Occurs if the algorithm cannot converge within the allowed number of iterations.
Example
The following example illustrates how to find the minimum of Rosenbrock's function using this BFGS solver.
program example
use nonlin_optimize, only : bfgs
implicit none
! Local Variables
type(bfgs) :: solver
type(fcnnvar_helper) :: obj
procedure(fcnnvar), pointer :: fcn
real(real64) :: x(2), fout
type(iteration_behavior) :: ib
! Initialization
fcn => rosenbrock
call obj%set_fcn(fcn, 2)
! Define an initial guess - the solution is (1, 1)
call random_number(x)
! Call the solver
call solver%solve(obj, x, fout, ib)
! Display the output
print '(AF8.5AF8.5A)', "Rosenbrock Minimum: (", x(1), ", ", x(2), ")"
print '(AE9.3)', "Function Value: ", fout
print '(AI0)', "Iterations: ", ib%iter_count
print '(AI0)', "Function Evaluations: ", ib%fcn_count
contains
! Rosenbrock's Function
function rosenbrock(x) result(f)
real(real64), intent(in), dimension(:) :: x
real(real64) :: f
f = 1.0d2 * (x(2) - x(1)**2)**2 + (x(1) - 1.0d0)**2
end function
end
Describes a function of N variables.
nonlin_core
nonlin_optimize
Defines a type capable of encapsulating an equation of N variables.
Defines a set of parameters that describe the behavior of the iteration process.
Defines a Broyden–Fletcher–Goldfarb–Shanno (BFGS) solver for minimization of functions of multiple va...
The above program yields the following output:
Rosenbrock Minimum: ( 1.00000, 0.99999)
Function Value: 0.200E-10
Iterations: 47
Function Evaluations: 70
See Also

Implements nonlin_core::equation_optimizer.

Definition at line 488 of file nonlin_optimize.f90.


The documentation for this type was generated from the following file: