QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
endcriteria.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006, 2007 Ferdinando Ametrano
5 Copyright (C) 2007 Marco Bianchetti
6 Copyright (C) 2001, 2002, 2003 Nicolas Di Césaré
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22/*! \file endcriteria.hpp
23 \brief Optimization criteria class
24*/
25
26#ifndef quantlib_optimization_criteria_hpp
27#define quantlib_optimization_criteria_hpp
28
29#include <ql/utilities/null.hpp>
30#include <iosfwd>
31
32namespace QuantLib {
33
34 //! Criteria to end optimization process:
35 /*! - maximum number of iterations AND minimum number of iterations around stationary point
36 - x (independent variable) stationary point
37 - y=f(x) (dependent variable) stationary point
38 - stationary gradient
39 */
41 public:
42 enum Type {None,
50
51 //! Initialization constructor
57
58 // Inspectors
59 Size maxIterations() const;
61 Real rootEpsilon() const;
62 Real functionEpsilon() const;
64
65 /*! Test if the number of iterations is not too big
66 and if a minimum point is not reached */
67 bool operator()(Size iteration,
68 Size& statState,
69 bool positiveOptimization,
70 Real fold,
71 Real normgold,
72 Real fnew,
73 Real normgnew,
74 EndCriteria::Type& ecType) const;
75
76 /*! Test if the number of iteration is below MaxIterations */
77 bool checkMaxIterations(Size iteration, EndCriteria::Type& ecType) const;
78 /*! Test if the root variation is below rootEpsilon */
79 bool checkStationaryPoint(Real xOld,
80 Real xNew,
81 Size& statStateIterations,
82 EndCriteria::Type& ecType) const;
83 /*! Test if the function variation is below functionEpsilon */
85 Real fxNew,
86 Size& statStateIterations,
87 EndCriteria::Type& ecType) const;
88 /*! Test if the function value is below functionEpsilon */
90 bool positiveOptimization,
91 EndCriteria::Type& ecType) const;
92 /*! Test if the gradient norm variation is below gradientNormEpsilon */
93 //bool checkZerGradientNormValue(const Real gNormOld,
94 // const Real gNormNew,
95 // EndCriteria::Type& ecType) const;
96 /*! Test if the gradient norm value is below gradientNormEpsilon */
97 bool checkZeroGradientNorm(Real gNorm, EndCriteria::Type& ecType) const;
98
99 static bool succeeded(EndCriteria::Type ecType);
100 protected:
101 //! Maximum number of iterations
103 //! Maximun number of iterations in stationary state
105 //! root, function and gradient epsilons
107
108 };
109
110 std::ostream& operator<<(std::ostream& out, EndCriteria::Type ecType);
111
112}
113
114#endif
Criteria to end optimization process:
Definition: endcriteria.hpp:40
bool operator()(Size iteration, Size &statState, bool positiveOptimization, Real fold, Real normgold, Real fnew, Real normgnew, EndCriteria::Type &ecType) const
bool checkStationaryFunctionAccuracy(Real f, bool positiveOptimization, EndCriteria::Type &ecType) const
Definition: endcriteria.cpp:95
static bool succeeded(EndCriteria::Type ecType)
Real gradientNormEpsilon() const
bool checkZeroGradientNorm(Real gNorm, EndCriteria::Type &ecType) const
Real functionEpsilon() const
bool checkStationaryPoint(Real xOld, Real xNew, Size &statStateIterations, EndCriteria::Type &ecType) const
Definition: endcriteria.cpp:64
Real rootEpsilon() const
Size maxIterations() const
Size maxStationaryStateIterations_
Maximun number of iterations in stationary state.
bool checkStationaryFunctionValue(Real fxOld, Real fxNew, Size &statStateIterations, EndCriteria::Type &ecType) const
Definition: endcriteria.cpp:79
Real rootEpsilon_
root, function and gradient epsilons
Size maxStationaryStateIterations() const
Size maxIterations_
Maximum number of iterations.
bool checkMaxIterations(Size iteration, EndCriteria::Type &ecType) const
Definition: endcriteria.cpp:56
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:37
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
null values