QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
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,
49
50 //! Initialization constructor
56
57 // Inspectors
58 Size maxIterations() const;
60 Real rootEpsilon() const;
61 Real functionEpsilon() const;
63
64 /*! Test if the number of iterations is not too big
65 and if a minimum point is not reached */
66 bool operator()(Size iteration,
67 Size& statState,
68 bool positiveOptimization,
69 Real fold,
70 Real normgold,
71 Real fnew,
72 Real normgnew,
73 EndCriteria::Type& ecType) const;
74
75 /*! Test if the number of iteration is below MaxIterations */
76 bool checkMaxIterations(Size iteration, EndCriteria::Type& ecType) const;
77 /*! Test if the root variation is below rootEpsilon */
78 bool checkStationaryPoint(Real xOld,
79 Real xNew,
80 Size& statStateIterations,
81 EndCriteria::Type& ecType) const;
82 /*! Test if the function variation is below functionEpsilon */
84 Real fxNew,
85 Size& statStateIterations,
86 EndCriteria::Type& ecType) const;
87 /*! Test if the function value is below functionEpsilon */
89 bool positiveOptimization,
90 EndCriteria::Type& ecType) const;
91 /*! Test if the gradient norm variation is below gradientNormEpsilon */
92 //bool checkZerGradientNormValue(const Real gNormOld,
93 // const Real gNormNew,
94 // EndCriteria::Type& ecType) const;
95 /*! Test if the gradient norm value is below gradientNormEpsilon */
96 bool checkZeroGradientNorm(Real gNorm, EndCriteria::Type& ecType) const;
97
98 protected:
99 //! Maximum number of iterations
101 //! Maximun number of iterations in stationary state
103 //! root, function and gradient epsilons
105
106 };
107
108 std::ostream& operator<<(std::ostream& out, EndCriteria::Type ecType);
109
110}
111
112#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
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:35
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
null values