Shark machine learning library
About Shark
News!
Contribute
Credits and copyright
Downloads
Getting Started
Installation
Using the docs
Documentation
Tutorials
Quick references
Class list
Global functions
FAQ
Showroom
include
shark
Algorithms
GradientDescent
TrustRegionNewton.h
Go to the documentation of this file.
1
/*!
2
*
3
*
4
* \brief Trust-Region Newton-Step Method
5
*
6
* \author O. Krause
7
* \date 2015
8
*
9
*
10
* \par Copyright 1995-2017 Shark Development Team
11
*
12
* <BR><HR>
13
* This file is part of Shark.
14
* <http://shark-ml.org/>
15
*
16
* Shark is free software: you can redistribute it and/or modify
17
* it under the terms of the GNU Lesser General Public License as published
18
* by the Free Software Foundation, either version 3 of the License, or
19
* (at your option) any later version.
20
*
21
* Shark is distributed in the hope that it will be useful,
22
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
* GNU Lesser General Public License for more details.
25
*
26
* You should have received a copy of the GNU Lesser General Public License
27
* along with Shark. If not, see <http://www.gnu.org/licenses/>.
28
*
29
*/
30
31
#ifndef ALGORITHMS_GRADIENTDESCENT_TRUST_REGION_NEWTON_H
32
#define ALGORITHMS_GRADIENTDESCENT_TRUST_REGION_NEWTON_H
33
34
#include <
shark/Core/DLLSupport.h
>
35
#include <
shark/Algorithms/AbstractSingleObjectiveOptimizer.h
>
36
37
namespace
shark
{
38
39
/// \brief Simple Trust-Region method based on the full Hessian matrix
40
///
41
/// While normal Newton methods compute the Newton steps and perform a line-search
42
/// In the Newton direction, trust region methods first choose a maximal step-length and
43
/// then try to find an approximate best point of the second order tailor expansion in that
44
/// region. more formally, we solve
45
/// \f[ \min_{p} m(p) = p^T B p +g^Tp, ||p||<\delta \f]
46
/// where \f$B\f$ is the Hessian and \f$g\f$ the gradient of the current point \f$x\f$.
47
/// Given this step, we compute how much the model agrees with the actual function, i.e.
48
/// \f[ \rho = \frac{ f(x+p)-f(p) }{m(p)} \f]
49
/// If this value is large, that is, the improvement in function value is approximately as
50
/// large or larger as the model predicted, we increase \f$\delta\f$ to make larger steps
51
/// possible, otherwise we decrease it, if the model predicted a much larger improvement
52
/// than observed - in the worst case, the new point is worse than the old one.
53
///
54
/// As a further check, to improve convergence, we do not accept every step, but those
55
/// with \f$ \rho > c > 0 \f$. This ensures that we do not overjump the optimum too much
56
/// and leads to a better (worst case) convergence rate.
57
///
58
/// The optimal step is computed by a conjugate gradient method that stops once a
59
/// target tolerance is reached, or the step approaches the boundary (which happens,
60
/// for example, when the Hessian is indefinite or rank-deficient). Thus, computation
61
/// time is not wasted for steps that are far away from the optimum. The tolerance
62
/// is set by a forcing-schedule so that accuracy increases in the vicinity of the
63
/// optimum, enabling solutions with arbitrary precision.
64
///
65
/// The algorithm is based on
66
/// Jorge Nocedal, Stephen J. Wright
67
/// Numerical Optimization, 2nd Edition
68
/// Algorithm 4.1 with Algorithm 7.2 to solve the sub-problem
69
class
TrustRegionNewton
:
public
AbstractSingleObjectiveOptimizer
<RealVector >
70
{
71
public
:
72
/// \brief Default constructor.
73
SHARK_EXPORT_SYMBOL
TrustRegionNewton
();
74
75
/// \brief Initialize the iterative optimizer with a problem (objective function) and a starting point.
76
///
77
/// The initial trust region radius is set to 0.1
78
void
init
(
ObjectiveFunctionType
& objectiveFunction,
SearchPointType
const
& startingPoint){
79
init
(objectiveFunction,startingPoint,0.1);
80
}
81
/// \brief Initialize the iterative optimizer with a problem (objective function), a starting point and an initial value for the trust-region
82
SHARK_EXPORT_SYMBOL
void
init
(
ObjectiveFunctionType
const
& objectiveFunction,
SearchPointType
const
& startingPoint,
double
initialDelta);
83
using
AbstractSingleObjectiveOptimizer<RealVector >::init
;
84
85
/// \brief From INameable: return the class name.
86
std::string
name
()
const
87
{
return
"TrustRegionNewton"
; }
88
89
/// \brief Minimal improvement ratio (see the algorithm details in the class description).
90
double
minImprovementRatio
()
const
{
91
return
m_minImprovementRatio
;
92
}
93
94
/// \brief Minimal improvement ratio (see the algorithm details in the class description).
95
double
&
minImprovementRatio
(){
96
return
m_minImprovementRatio
;
97
}
98
99
/// \brief Perform one trust region Newton step, update point and trust region radius.
100
SHARK_EXPORT_SYMBOL
void
step
(
ObjectiveFunctionType
const
& objectiveFunction);
101
102
protected
:
103
double
m_delta
;
///< Current trust region size
104
double
m_minImprovementRatio
;
///< Minimal improvement ratio (see the algorithm details in the class description).
105
ObjectiveFunctionType::SecondOrderDerivative
m_derivatives
;
///< First and second derivative of the objective function in the current point.
106
};
107
}
108
#endif