OpenMD 3.1
Molecular Dynamics in the Open
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 <config.h>
30
31#include <ostream>
32
33namespace QuantLib {
34
35 //! Criteria to end optimization process:
36 /*! - maximum number of iterations AND minimum number of iterations around
37 stationary point
38 - x (independent variable) stationary point
39 - y=f(x) (dependent variable) stationary point
40 - stationary gradient
41 */
43 public:
44 enum Type {
45 None,
46 MaxIterations,
47 StationaryPoint,
48 StationaryFunctionValue,
49 StationaryFunctionAccuracy,
50 ZeroGradientNorm,
51 Unknown
52 };
53
54 //! Initialization constructor
55 EndCriteria(size_t maxIterations, size_t maxStationaryStateIterations,
56 RealType rootEpsilon, RealType functionEpsilon,
57 RealType gradientNormEpsilon);
58
59 // Inspectors
60 size_t maxIterations() const;
61 size_t maxStationaryStateIterations() const;
62 RealType rootEpsilon() const;
63 RealType functionEpsilon() const;
64 RealType gradientNormEpsilon() const;
65
66 /*! Test if the number of iterations is not too big
67 and if a minimum point is not reached */
68 bool operator()(const size_t iteration, size_t& statState,
69 const bool positiveOptimization, const RealType fold,
70 const RealType normgold, const RealType fnew,
71 const RealType normgnew, EndCriteria::Type& ecType) const;
72
73 /*! Test if the number of iteration is below MaxIterations */
74 bool checkMaxIterations(const size_t iteration,
75 EndCriteria::Type& ecType) const;
76 /*! Test if the root variation is below rootEpsilon */
77 bool checkStationaryPoint(const RealType xOld, const RealType xNew,
78 size_t& statStateIterations,
79 EndCriteria::Type& ecType) const;
80 /*! Test if the function variation is below functionEpsilon */
81 bool checkStationaryFunctionValue(const RealType fxOld,
82 const RealType fxNew,
83 size_t& statStateIterations,
84 EndCriteria::Type& ecType) const;
85 /*! Test if the function value is below functionEpsilon */
86 bool checkStationaryFunctionAccuracy(const RealType f,
87 const bool positiveOptimization,
88 EndCriteria::Type& ecType) const;
89 /*! Test if the gradient norm value is below gradientNormEpsilon */
90 bool checkZeroGradientNorm(const RealType gNorm,
91 EndCriteria::Type& ecType) const;
92
93 protected:
94 //! Maximum number of iterations
96 //! Maximun number of iterations in stationary state
98 //! root, function and gradient epsilons
99 RealType rootEpsilon_, functionEpsilon_, gradientNormEpsilon_;
100 };
101
102 std::ostream& operator<<(std::ostream& out, EndCriteria::Type ecType);
103
104} // namespace QuantLib
105
106#endif
Criteria to end optimization process:
bool checkStationaryPoint(const RealType xOld, const RealType xNew, size_t &statStateIterations, EndCriteria::Type &ecType) const
Test if the root variation is below rootEpsilon.
RealType rootEpsilon_
root, function and gradient epsilons
bool checkStationaryFunctionAccuracy(const RealType f, const bool positiveOptimization, EndCriteria::Type &ecType) const
Test if the function value is below functionEpsilon.
bool operator()(const size_t iteration, size_t &statState, const bool positiveOptimization, const RealType fold, const RealType normgold, const RealType fnew, const RealType normgnew, EndCriteria::Type &ecType) const
Test if the number of iterations is not too big and if a minimum point is not reached.
size_t maxStationaryStateIterations_
Maximun number of iterations in stationary state.
bool checkStationaryFunctionValue(const RealType fxOld, const RealType fxNew, size_t &statStateIterations, EndCriteria::Type &ecType) const
Test if the function variation is below functionEpsilon.
bool checkZeroGradientNorm(const RealType gNorm, EndCriteria::Type &ecType) const
Test if the gradient norm value is below gradientNormEpsilon.
bool checkMaxIterations(const size_t iteration, EndCriteria::Type &ecType) const
Test if the number of iteration is below MaxIterations.
EndCriteria(size_t maxIterations, size_t maxStationaryStateIterations, RealType rootEpsilon, RealType functionEpsilon, RealType gradientNormEpsilon)
Initialization constructor.
size_t maxIterations_
Maximum number of iterations.