NuriKit v0.1.0b2
Loading...
Searching...
No Matches
nuri::Bfgs Class Reference

BFGS minimizer. More...

#include <nuri/algo/optim.h>

Public Member Functions

 Bfgs (MutRef< ArrayXd > x)
 Prepare BFGS minimization algorithm.
template<class FuncGrad>
BfgsResult minimize (FuncGrad fg, const double pgtol=1e-5, const double xrtol=0, int maxiter=-1, const int maxls=100, const double ftol=1e-4, const double gtol=0.9, const double xtol=1e-14)
 Minimize a function using BFGS algorithm.

Detailed Description

BFGS minimizer.

See also
bfgs

References:

  • "Broyden-Fletcher-Goldfarb-Shanno algorithm", Wikipedia (Accessed 2024-10-25).

This implementation is based on the Python implementation of BFGS in the SciPy library, with optimized Hessian update step suggested by the linked Wikipedia page. The original implementation is released under the BSD 3-Clause License (included below).

Copyright (c) 2001-2002 Enthought, Inc. 2003-2024, SciPy Developers.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Constructor & Destructor Documentation

◆ Bfgs()

nuri::Bfgs::Bfgs ( MutRef< ArrayXd > x)

Prepare BFGS minimization algorithm.

Parameters
xInitial guess. Will be modified in-place.

Member Function Documentation

◆ minimize()

template<class FuncGrad>
BfgsResult nuri::Bfgs::minimize ( FuncGrad fg,
const double pgtol = 1e-5,
const double xrtol = 0,
int maxiter = -1,
const int maxls = 100,
const double ftol = 1e-4,
const double gtol = 0.9,
const double xtol = 1e-14 )
inline

Minimize a function using BFGS algorithm.

Template Parameters
FuncGradFunction object that computes the function value and gradient. Function value should be returned and gradient should be updated in the input gradient vector.
Parameters
fgFunction object.
pgtolStop when the projected gradient is less than this value.
xrtolStop when the relative change in x is less than this value.
maxiterMaximum number of iterations. If negative, it will be set to 200 times the number of variables.
maxlsMaximum number of line search steps.
ftolTolerance for the relative change in the function value.
gtolGradient tolerance for the line search step.
xtolTolerance for the relative change in x.
Returns
A struct with the result code, number of iterations, final function value, and final gradient.

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